feat: initialise k8s cluster
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
---
|
|
||||||
- name: Initialise Kubernetes cluster
|
- name: Initialise Kubernetes cluster
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
argv:
|
argv:
|
||||||
@@ -9,8 +8,35 @@
|
|||||||
- --upload-certs
|
- --upload-certs
|
||||||
args:
|
args:
|
||||||
creates: /etc/kubernetes/admin.conf
|
creates: /etc/kubernetes/admin.conf
|
||||||
|
run_once: true
|
||||||
|
|
||||||
|
|
||||||
|
- name: Generate Join Command
|
||||||
|
ansible.builtin.command:
|
||||||
|
argv:
|
||||||
|
- kubeadm
|
||||||
|
- token
|
||||||
|
- create
|
||||||
|
- --print-join-command
|
||||||
|
register: kubernetes_control_plane_join_command
|
||||||
|
run_once: true
|
||||||
|
changed_when: true
|
||||||
|
|
||||||
|
|
||||||
|
- name: Get Certificate Key
|
||||||
|
ansible.builtin.shell:
|
||||||
|
cmd: set -o pipefail && kubeadm init phase upload-certs --upload-certs | tail -n 1
|
||||||
|
register: kubernetes_control_plane_certificate_key
|
||||||
|
run_once: true
|
||||||
|
changed_when: true
|
||||||
|
|
||||||
|
|
||||||
|
- name: Join Additional Control Planes
|
||||||
|
ansible.builtin.command:
|
||||||
|
cmd: "{{ kubernetes_control_plane_join_command.stdout }} --control-plane --certificate-key {{ kubernetes_control_plane_certificate_key.stdout }}"
|
||||||
|
args:
|
||||||
|
creates: /etc/kubernetes/admin.conf
|
||||||
|
|
||||||
- name: Copy Kubernetes Admin Config
|
- name: Copy Kubernetes Admin Config
|
||||||
ansible.builtin.command: "{{ item }}"
|
ansible.builtin.command: "{{ item }}"
|
||||||
loop:
|
loop:
|
||||||
@@ -20,6 +46,12 @@
|
|||||||
args:
|
args:
|
||||||
creates: $HOME/.kube/config
|
creates: $HOME/.kube/config
|
||||||
|
|
||||||
|
- name: Install Kubernetes CLI
|
||||||
|
ansible.builtin.apt:
|
||||||
|
pkg:
|
||||||
|
- kubectl
|
||||||
|
state: present
|
||||||
|
|
||||||
# - name: Install Pod Network (Calico)
|
# - name: Install Pod Network (Calico)
|
||||||
# ansible.builtin.shell: kubectl apply -f https://raw.githubusercontent.com/projectcalico/calico/v3.32.0/manifests/calico.yaml > pod_network_setup.txt
|
# ansible.builtin.shell: kubectl apply -f https://raw.githubusercontent.com/projectcalico/calico/v3.32.0/manifests/calico.yaml > pod_network_setup.txt
|
||||||
# args:
|
# args:
|
||||||
|
|||||||
+7
-7
@@ -4,14 +4,14 @@
|
|||||||
- common
|
- common
|
||||||
- kubernetes_common
|
- kubernetes_common
|
||||||
|
|
||||||
# # ========================
|
# ========================
|
||||||
# # SETUP KUBERNETES CLUSTER
|
# Setup Kubernetes Cluster
|
||||||
# # ========================
|
# ========================
|
||||||
|
|
||||||
# - name: Initialise Kubernetes cluster
|
- name: Initialise Kubernetes Cluster
|
||||||
# hosts: masters[0]
|
hosts: masters
|
||||||
# roles:
|
roles:
|
||||||
# - kubernetes_master
|
- kubernetes_control_plane
|
||||||
|
|
||||||
# # =======================
|
# # =======================
|
||||||
# # JOIN MASTERS TO CLUSTER
|
# # JOIN MASTERS TO CLUSTER
|
||||||
|
|||||||
Reference in New Issue
Block a user