go-zen-chu / ubuntu-k8s-playbook

kubernetes cluster build on ubuntu 22.04
MIT License
1 stars 0 forks source link

Add worker join playbook #3

Closed go-zen-chu closed 2 years ago

go-zen-chu commented 2 years ago

Why

What

QA

$ ansible-playbook -i hosts.yml k8s-worker.yml
SSH password: 
BECOME password[defaults to SSH password]: 

PLAY [k8s_workers] ***************************************************************************************************************************************************

TASK [Gathering Facts] ***********************************************************************************************************************************************
ok: [machine_worker2]
ok: [machine_worker1]

TASK [kubeadm-common : Update apt packages list for getting cache] ***************************************************************************************************
ok: [machine_worker2]
ok: [machine_worker1]

TASK [kubeadm-common : Set swapoff] **********************************************************************************************************************************
changed: [machine_worker2]
changed: [machine_worker1]

TASK [kubeadm-common : Enable overlay module] ************************************************************************************************************************
changed: [machine_worker2]
changed: [machine_worker1]

TASK [kubeadm-common : Enable br_netfilter module] *******************************************************************************************************************
changed: [machine_worker2]
changed: [machine_worker1]

TASK [kubeadm-common : Load kernel module when machine started] ******************************************************************************************************
ok: [machine_worker2]
changed: [machine_worker1]

TASK [kubeadm-common : Set sysctl params when machine started] *******************************************************************************************************
ok: [machine_worker2]
changed: [machine_worker1]

TASK [kubeadm-common : Check netfilter option configured as expected] ************************************************************************************************
changed: [machine_worker2]
changed: [machine_worker1]

TASK [kubeadm-common : Check containerd already installed] ***********************************************************************************************************
changed: [machine_worker2]
changed: [machine_worker1]

TASK [kubeadm-common : Download and extract containerd tar] **********************************************************************************************************
skipping: [machine_worker2]
changed: [machine_worker1]

TASK [kubeadm-common : Ensure /usr/local/lib/systemd/system exists] **************************************************************************************************
ok: [machine_worker2]
changed: [machine_worker1]

TASK [kubeadm-common : Download containerd systemctl service file] ***************************************************************************************************
ok: [machine_worker2]
changed: [machine_worker1]

TASK [kubeadm-common : Check nerdctl already installed] **************************************************************************************************************
changed: [machine_worker2]
changed: [machine_worker1]

TASK [kubeadm-common : Install nerdctl] ******************************************************************************************************************************
skipping: [machine_worker2]
changed: [machine_worker1]

TASK [kubeadm-common : Check runc already installed] *****************************************************************************************************************
changed: [machine_worker2]
changed: [machine_worker1]

TASK [kubeadm-common : Download runc] ********************************************************************************************************************************
skipping: [machine_worker2]
changed: [machine_worker1]

TASK [kubeadm-common : Install runc] *********************************************************************************************************************************
skipping: [machine_worker2]
changed: [machine_worker1]

TASK [kubeadm-common : Remove runc.amd64 file] ***********************************************************************************************************************
skipping: [machine_worker2]
changed: [machine_worker1]

TASK [kubeadm-common : Ensure /opt/cni/bin exists] *******************************************************************************************************************
changed: [machine_worker2]
changed: [machine_worker1]

TASK [kubeadm-common : Check cni plugins already installed] **********************************************************************************************************
changed: [machine_worker2]
changed: [machine_worker1]

TASK [kubeadm-common : Download and extract cni plugins] *************************************************************************************************************
changed: [machine_worker2]
changed: [machine_worker1]

TASK [kubeadm-common : Enable containerd systemctl service] **********************************************************************************************************
changed: [machine_worker2]
changed: [machine_worker1]

TASK [kubeadm-common : Install required libraries] *******************************************************************************************************************
ok: [machine_worker2]
changed: [machine_worker1]

TASK [kubeadm-common : Download the Google Cloud public signing key] *************************************************************************************************
ok: [machine_worker2]
changed: [machine_worker1]

TASK [kubeadm-common : Add kubernetes apt list] **********************************************************************************************************************
ok: [machine_worker2]
changed: [machine_worker1]

TASK [kubeadm-common : Install commands required in kubernetes] ******************************************************************************************************
ok: [machine_worker2]
changed: [machine_worker1]

TASK [kubeadm-common : Check if cgroup v1 is used] *******************************************************************************************************************
changed: [machine_worker2]
changed: [machine_worker1]

TASK [kubeadm-common : Force using cgroup v1 not cgroup v2] **********************************************************************************************************
skipping: [machine_worker2]
changed: [machine_worker1]

TASK [kubeadm-common : Update grub] **********************************************************************************************************************************
skipping: [machine_worker2]
changed: [machine_worker1]

TASK [kubeadm-common : Reboot node] **********************************************************************************************************************************
skipping: [machine_worker2]
changed: [machine_worker1]

TASK [kubeadm-common : Set swapoff] **********************************************************************************************************************************
skipping: [machine_worker2]
changed: [machine_worker1]

TASK [kubeadm-worker : join to kubernetes cluster] *******************************************************************************************************************
changed: [machine_worker1]
changed: [machine_worker2]

PLAY RECAP ***********************************************************************************************************************************************************
machine_worker1            : ok=32   changed=30   unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
machine_worker2            : ok=23   changed=13   unreachable=0    failed=0    skipped=9    rescued=0    ignored=0   

k8s worker nodes are joined

ansible@node1:~$ kubectl get nodes
NAME              STATUS   ROLES           AGE    VERSION
control-plane-1   Ready    control-plane   25m    v1.24.2
worker-1          Ready    <none>          2m2s   v1.24.2
worker-2          Ready    <none>          110s   v1.24.2
ansible@node1:~$ kubectl get pods -A
NAMESPACE      NAME                                      READY   STATUS    RESTARTS   AGE
kube-flannel   kube-flannel-ds-6zfkv                     1/1     Running   0          25m
kube-flannel   kube-flannel-ds-f9sq7                     1/1     Running   0          2m11s
kube-flannel   kube-flannel-ds-fkrwq                     1/1     Running   0          119s
kube-system    coredns-6d4b75cb6d-ll4mw                  1/1     Running   0          25m
kube-system    coredns-6d4b75cb6d-wtdb9                  1/1     Running   0          25m
kube-system    etcd-control-plane-1                      1/1     Running   1283       26m
kube-system    kube-apiserver-control-plane-1            1/1     Running   166        26m
kube-system    kube-controller-manager-control-plane-1   1/1     Running   281        26m
kube-system    kube-proxy-c4pn6                          1/1     Running   0          2m11s
kube-system    kube-proxy-c9ndp                          1/1     Running   0          25m
kube-system    kube-proxy-g2pmz                          1/1     Running   0          119s
kube-system    kube-scheduler-control-plane-1            1/1     Running   266        26m