-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaster.yml
49 lines (42 loc) · 1.48 KB
/
master.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
---
- hosts: "masters"
remote_user: centos
become: yes
become_method: sudo
become_user: root
gather_facts: yes
connection: ssh
tasks:
- name: Create kubeadm-config file
shell: |
cat <<EOF | sudo tee /home/centos/kubeadm-config.yaml
kind: ClusterConfiguration
apiVersion: kubeadm.k8s.io/v1beta3
kubernetesVersion: v1.24.0
networking:
podSubnet: 172.31.0.0/16
---
kind: KubeletConfiguration
apiVersion: kubelet.config.k8s.io/v1beta1
cgroupDriver: systemd
EOF
- name: initialize the cluster
shell: cd /home/centos && kubeadm init --config kubeadm-config.yaml
args:
chdir: $HOME
creates: cluster_initialized.txt
- name: export kubeconfig
shell: |
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
export KUBECONFIG=/etc/kubernetes/admin.conf
- name: install Pod network
shell: |
kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')" >> pod_network_setup.txt
args:
chdir: $HOME
creates: pod_network_setup.txt
- name: Control plane enable
shell: |
kubectl taint nodes --all node-role.kubernetes.io/master-