diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index 0811eff5..c496cd77 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -23,7 +23,7 @@ kubernetes_kubeadm_version: 1.21.0-00 #### # Role - keepalived #### -# keepalived_vip: '' +keepalived_vip: '192.168.1.202' # keepalived_interface: "{{ ansible_default_ipv4['interface'] }}" #### @@ -35,7 +35,7 @@ cri_plugin: containerd #### # Role - cni #### -# cni_plugin: 'calico' +cni_plugin: 'cilium' # cni_bgp_peer_address: 192.168.0.1 # cni_bgp_peer_asn: 64512 # cni_cilium_helm_version: 1.9.3 diff --git a/ansible/group_vars/cluster.yml b/ansible/group_vars/cluster.yml index b964d33f..6e200caa 100644 --- a/ansible/group_vars/cluster.yml +++ b/ansible/group_vars/cluster.yml @@ -19,11 +19,11 @@ cluster_profiling: false # provides a maximum of 64 nodes in a cluster and 254 pods per node. # Kubernetes internal network for services, *must* be an unused block of space. -cluster_service_subnet: '10.144.0.0/18' +cluster_service_subnet: '10.125.0.0/18' # Kubernetes internal network. IP's for pods will be drawn from this address # space. *must* be unused in your network infrastructure. -cluster_pod_subnet: '10.144.64.0/18' +cluster_pod_subnet: '10.125.64.0/18' # This sets the network node allocation size. Each node in the cluster is # assigned a subnet of this size. diff --git a/ansible/group_vars/masters.yml b/ansible/group_vars/masters.yml index 93af079a..662a099d 100644 --- a/ansible/group_vars/masters.yml +++ b/ansible/group_vars/masters.yml @@ -13,14 +13,14 @@ # cluster_audit_log_maxbackup: 10 # cluster_audit_log_maxsize: 100 # cluster_pod_subnet: "" -# cluster_kube_proxy_enabled: true +cluster_kube_proxy_enabled: false # cluster_etcd_heartbeat_interval: 100 # cluster_etcd_election_timeout: 1000 #### # Role - cni #### -# cni_plugin: calico +cni_plugin: cilium # cni_bgp_peer_address: 192.168.0.1 # cni_bgp_peer_asn: 64512 # cni_cilium_helm_version: 1.9.3 diff --git a/ansible/inventory b/ansible/inventory index 0f4e752a..4c18b7fd 100644 --- a/ansible/inventory +++ b/ansible/inventory @@ -1,9 +1,9 @@ [all] -k8s-controlplane-01 hostname=k8s-controlplane-01 ansible_host=192.168.1.121 ansible_user=pi -k8s-controlplane-02 hostname=k8s-controlplane-02 ansible_host=192.168.1.122 ansible_user=pi -k8s-controlplane-03 hostname=k8s-controlplane-03 ansible_host=192.168.1.123 ansible_user=pi -k8s-node-01 hostname=k8s-node-01 ansible_host=192.168.1.131 ansible_user=pi -k8s-node-02 hostname=k8s-node-02 ansible_host=192.168.1.132 ansible_user=pi +k8s-controlplane-01 hostname=k8s-controlplane-01 ansible_host=192.168.1.161 ansible_user=pi +k8s-controlplane-02 hostname=k8s-controlplane-02 ansible_host=192.168.1.162 ansible_user=pi +k8s-controlplane-03 hostname=k8s-controlplane-03 ansible_host=192.168.1.163 ansible_user=pi +k8s-node-01 hostname=k8s-node-01 ansible_host=192.168.1.171 ansible_user=pi +k8s-node-02 hostname=k8s-node-02 ansible_host=192.168.1.172 ansible_user=pi [cluster:children] controlplane @@ -19,7 +19,7 @@ k8s-node-01 k8s-node-02 [docker_cache] -registry hostname=registry ansible_host=192.168.1.120 ansible_user=pi +#registry hostname=registry ansible_host=192.168.1.120 ansible_user=pi ; These entires are here for backward compatibility as we transition away from the old names. [k8s:children] @@ -33,4 +33,4 @@ k8s-controlplane-03 [workers] k8s-node-01 -k8s-node-02 +k8s-node-02 \ No newline at end of file diff --git a/ansible/roles/cluster/tasks/join.yml b/ansible/roles/cluster/tasks/join.yml index 5e7238bd..fc049a2c 100644 --- a/ansible/roles/cluster/tasks/join.yml +++ b/ansible/roles/cluster/tasks/join.yml @@ -39,6 +39,10 @@ port: '{{ cluster_apiserver_bind_port }}' timeout: 180 +# - name: Pause for 2 minutes to wait for apiserver +# pause: +# minutes: 2 + - name: 'join | add node to cluster' ansible.builtin.command: | kubeadm join --config /etc/kubernetes/kubeadm-join.yaml diff --git a/ansible/roles/cluster/tasks/main.yml b/ansible/roles/cluster/tasks/main.yml index 78e7c2df..ee76bcf8 100644 --- a/ansible/roles/cluster/tasks/main.yml +++ b/ansible/roles/cluster/tasks/main.yml @@ -67,7 +67,7 @@ - name: pull control plane images command: kubeadm config images pull - when: inventory_hostname == groups["controlplane"] + # when: inventory_hostname == groups["controlplane"] - name: 'initialize | perform cluster initialization on primary control node' include_tasks: 'initialize.yml' diff --git a/ansible/roles/common/tasks/common.yml b/ansible/roles/common/tasks/common.yml index 0c6e79ea..f21c58d2 100644 --- a/ansible/roles/common/tasks/common.yml +++ b/ansible/roles/common/tasks/common.yml @@ -1,17 +1,4 @@ --- -- name: disable swap since kubernetes can't work with swap enabled (1/2) - command: swapoff -a - when: ansible_swaptotal_mb > 0 - -- name: disable swap in /etc/fstab since kubernetes can't work with swap enabled (2/2) - mount: - name: '{{ item }}' - fstype: swap - state: absent - loop: - - swap - - none - - name: start time services service: name: systemd-timesyncd diff --git a/ansible/roles/container-runtime/tasks/uninstall.yml b/ansible/roles/container-runtime/tasks/uninstall.yml deleted file mode 100644 index 7bf235e3..00000000 --- a/ansible/roles/container-runtime/tasks/uninstall.yml +++ /dev/null @@ -1,100 +0,0 @@ ---- -# When nuking a cluster, it may be beneficial to remove the CRI - these tasks will remove any CRI components - -- name: 'uninstall | check if crictl is present' - ansible.builtin.stat: - path: '/usr/local/bin/crictl' - register: crictl - -- name: 'uninstall | check if containerd is running' - ansible.builtin.stat: - path: '/run/containerd/containerd.sock' - register: containerd_sock - -- name: 'uninstall | stop all cri containers' - ansible.builtin.shell: | - set -o pipefail && /usr/local/bin/crictl ps -q | xargs -r /usr/local/bin/crictl -t 60s stop - args: - executable: '/bin/bash' - register: stop_all_containers - retries: 5 - until: stop_all_containers.rc == 0 - delay: 5 - when: - - crictl.stat.exists - - containerd_sock.stat.exists - - cri_plugin == 'containerd' - ignore_errors: true - -- name: 'uninstall | remove all cri containers' - ansible.builtin.command: | - /usr/local/bin/crictl rm -a -f - register: remove_all_containers - retries: 5 - until: remove_all_containers.rc == 0 - delay: 5 - when: - - crictl.stat.exists - - containerd_sock.stat.exists - - cri_plugin == 'containerd' - -- name: 'uninstall | stop all containerd pods' - ansible.builtin.shell: | - set -o pipefail && /usr/local/bin/crictl pods -q | xargs -r /usr/local/bin/crictl -t 60s stopp - args: - executable: '/bin/bash' - register: stop_all_pods - retries: 5 - until: stop_all_pods.rc == 0 - delay: 5 - when: - - crictl.stat.exists - - containerd_sock.stat.exists - - cri_plugin == 'containerd' - ignore_errors: true - -- name: 'uninstall | remove all containerd pods' - ansible.builtin.command: | - /usr/local/bin/crictl rmp -a -f - register: remove_all_pods - retries: 5 - until: remove_all_pods.rc == 0 - delay: 5 - when: - - crictl.stat.exists - - containerd_sock.stat.exists - - cri_plugin == 'containerd' - -# Uninstall ContainerD from Ubuntu/Debian platforms -- name: 'uninstall containerd on debian based platforms' - block: - - name: 'uninstall | stop containerd runtime' - ansible.builtin.systemd: - name: 'containerd' - state: stopped - enabled: false - when: containerd_sock.stat.exists - - name: 'uninstall | uninstall containerd package' - ansible.builtin.package: - name: containerd.io - state: 'absent' - - name: 'uninstall | remove containerd apt pin' - ansible.builtin.file: - path: '/etc/apt/preferences.d/containerd' - state: 'absent' - - name: 'uninstall | ensure containerd configuration directory has been removed' - ansible.builtin.file: - path: '{{ cri_containerd_config_dir }}' - state: 'absent' - when: - - ansible_os_family|lower == 'debian' - - cri_plugin == 'containerd' - -# Archlinux uninstallation of containerd package -- name: 'uninstall | remove containerd package' - pacman: - name: 'containerd' - state: 'absent' - when: - - ansible_os_family|lower == 'archlinux' - - cri_plugin == 'containerd' diff --git a/ansible/roles/kubernetes/tasks/debian.yml b/ansible/roles/kubernetes/tasks/debian.yml index 8fff18dc..ecc5ba29 100644 --- a/ansible/roles/kubernetes/tasks/debian.yml +++ b/ansible/roles/kubernetes/tasks/debian.yml @@ -106,6 +106,21 @@ - 'kubelet' - 'kubeadm' +# Swap disabled. You MUST disable swap in order for the kubelet to work properly. +# https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/ +- name: disable swap since kubernetes can't work with swap enabled + command: swapoff -a + when: ansible_swaptotal_mb > 0 + +- name: disable swap in /etc/fstab since kubernetes can't work with swap enabled + mount: + name: '{{ item }}' + fstype: swap + state: absent + loop: + - swap + - none + # TODO: Move to correct location; Perhaps common for RPI? # Adding required Kubernetes cgroups for Raspberry Pi - name: Enable container features @@ -118,6 +133,5 @@ - 'cgroup_enable=memory' - 'cgroup_memory=1' - 'swapaccount=1' - notify: reboot hosts when: ansible_architecture | regex_search('arm|aarch')