mirror of
https://github.com/Expand-sys/kubernetes-rocky9
synced 2025-12-16 15:42:14 +11:00
Create master.yml
This commit is contained in:
parent
1aa772306c
commit
c410f299d7
1 changed files with 43 additions and 0 deletions
43
ansible-deploy-k8s/master.yml
Normal file
43
ansible-deploy-k8s/master.yml
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
- hosts: masters
|
||||||
|
become: yes
|
||||||
|
tasks:
|
||||||
|
- name: initialize the cluster
|
||||||
|
shell: kubeadm init --pod-network-cidr=10.244.0.0/16
|
||||||
|
args:
|
||||||
|
chdir: $HOME
|
||||||
|
creates: cluster_initialized.txt
|
||||||
|
|
||||||
|
- name: create .kube directory
|
||||||
|
become: yes
|
||||||
|
become_user: kube
|
||||||
|
file:
|
||||||
|
path: $HOME/.kube
|
||||||
|
state: directory
|
||||||
|
mode: 0755
|
||||||
|
|
||||||
|
- name: copies admin.conf to user's kube config
|
||||||
|
copy:
|
||||||
|
src: /etc/kubernetes/admin.conf
|
||||||
|
dest: /home/kube/.kube/config
|
||||||
|
remote_src: yes
|
||||||
|
owner: kube
|
||||||
|
|
||||||
|
- name: install Pod network
|
||||||
|
become: yes
|
||||||
|
become_user: kube
|
||||||
|
shell: kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml
|
||||||
|
args:
|
||||||
|
chdir: $HOME
|
||||||
|
|
||||||
|
- name: Get the token for joining the worker nodes
|
||||||
|
become: yes
|
||||||
|
become_user: kube
|
||||||
|
shell: kubeadm token create --print-join-command
|
||||||
|
register: kubernetes_join_command
|
||||||
|
|
||||||
|
- debug:
|
||||||
|
msg: "{{ kubernetes_join_command.stdout }}"
|
||||||
|
|
||||||
|
- name: Copy join command to local file.
|
||||||
|
become: yes
|
||||||
|
local_action: copy content="{{ kubernetes_join_command.stdout_lines[0] }}" dest="/tmp/kubernetes_join_command" mode=0777
|
||||||
Loading…
Reference in a new issue