From 37da64cacf40b87ca60e443cfff38bc068bc4ac5 Mon Sep 17 00:00:00 2001 From: michael Date: Mon, 31 Oct 2022 03:01:23 +1300 Subject: [PATCH] kubeadm init --- ansible/roles/k8s_control/defaults/main.yaml | 2 ++ ansible/roles/k8s_control/tasks/main.yaml | 26 +++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 ansible/roles/k8s_control/defaults/main.yaml diff --git a/ansible/roles/k8s_control/defaults/main.yaml b/ansible/roles/k8s_control/defaults/main.yaml new file mode 100644 index 0000000..64f21b2 --- /dev/null +++ b/ansible/roles/k8s_control/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +k8s_control_master_node: kube01.balsillie.net \ No newline at end of file diff --git a/ansible/roles/k8s_control/tasks/main.yaml b/ansible/roles/k8s_control/tasks/main.yaml index c06feb2..5ccd060 100644 --- a/ansible/roles/k8s_control/tasks/main.yaml +++ b/ansible/roles/k8s_control/tasks/main.yaml @@ -19,4 +19,28 @@ regexp: '^(.*)SystemdCgroup = false$' line: ' SystemdCgroup = true' backrefs: true - state: present \ No newline at end of file + state: present + +- name: enable and start containerd service + ansible.builtin.service: + name: containerd + state: restarted + enabled: true + +- name: kubeadm init + when: ansible_host == {{ k8s_control_master_node }} + ansible.builtin.shell: + cmd: | + kubeadm init \ + --apiserver-advertise-address="" \ + --apiserver-cert-extra-sans="" \ + --node-name k8s-master \ + --pod-network-cidr=192.168.0.0/16 + creates: /etc/kubernetes/admin.conf + +- name: join remaining nodes + when: ansible_host != {{ k8s_control_master_node }} + ansible.builtin.shell: + cmd: | + + creates: