mirror of
https://github.com/geerlingguy/ansible-role-kubernetes.git
synced 2025-04-21 01:17:04 +02:00
Multi Master
This commit is contained in:
parent
8d331aed43
commit
088ba59cf5
8
tasks/control-plane-aux-setup.yml
Normal file
8
tasks/control-plane-aux-setup.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
- name: Join control node to Kubernetes control plane.
|
||||||
|
shell: >
|
||||||
|
{{ kubernetes_join_command }}
|
||||||
|
--control-plane --certificate-key
|
||||||
|
{{ kubernetes_certificate }}
|
||||||
|
creates=/etc/kubernetes/kubelet.conf
|
||||||
|
tags: ["skip_ansible_lint"]
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
- include_tasks: sysctl-setup.yml
|
- include_tasks: sysctl-setup.yml
|
||||||
|
|
||||||
- include_tasks: kubelet-setup.yml # deprecated
|
- include_tasks: kubelet-setup.yml # deprecated
|
||||||
when: kubernetes_kubelet_extra_args|length > 0
|
when: kubernetes_kubelet_extra_args|length > 0
|
||||||
|
|
||||||
- name: Ensure kubelet is started and enabled at boot.
|
- name: Ensure kubelet is started and enabled at boot.
|
||||||
@ -34,16 +34,23 @@
|
|||||||
path: /etc/kubernetes/admin.conf
|
path: /etc/kubernetes/admin.conf
|
||||||
register: kubernetes_init_stat
|
register: kubernetes_init_stat
|
||||||
|
|
||||||
|
- name: Group the kubernetes Nodes
|
||||||
|
ansible.builtin.group_by:
|
||||||
|
key: k8s_{{ kubernetes_role }}
|
||||||
|
|
||||||
|
- debug:
|
||||||
|
msg: "{{ groups['k8s_control_plane'] }}"
|
||||||
|
|
||||||
# Set up Cilium Client.
|
# Set up Cilium Client.
|
||||||
- include_tasks: cilium-client-setup.yml
|
- include_tasks: cilium-client-setup.yml
|
||||||
when:
|
when:
|
||||||
- kubernetes_role == 'control_plane'
|
- inventory_hostname is in groups['k8s_control_plane']
|
||||||
- kubernetes_pod_network.cni == 'cilium'
|
- kubernetes_pod_network.cni == 'cilium'
|
||||||
|
|
||||||
# Set up hubble Client.
|
# Set up hubble Client.
|
||||||
- include_tasks: hubble-client-setup.yml
|
- include_tasks: hubble-client-setup.yml
|
||||||
when:
|
when:
|
||||||
- kubernetes_role == 'control_plane'
|
- inventory_hostname is in groups['k8s_control_plane']
|
||||||
- kubernetes_pod_network.cni == 'cilium'
|
- kubernetes_pod_network.cni == 'cilium'
|
||||||
- kubernetes_cilium_hubble_client
|
- kubernetes_cilium_hubble_client
|
||||||
- kubernetes_cilium_values.hubble.relay.enabled is defined
|
- kubernetes_cilium_values.hubble.relay.enabled is defined
|
||||||
@ -51,13 +58,20 @@
|
|||||||
|
|
||||||
# Set up control plane.
|
# Set up control plane.
|
||||||
- include_tasks: control-plane-setup.yml
|
- include_tasks: control-plane-setup.yml
|
||||||
when: kubernetes_role == 'control_plane'
|
when: inventory_hostname == groups['k8s_control_plane'][0]
|
||||||
|
|
||||||
|
# Set up nodes.
|
||||||
|
- name: Get the kubeadm join new master certificate key.
|
||||||
|
command: kubeadm init phase upload-certs --upload-certs | tail -1
|
||||||
|
changed_when: false
|
||||||
|
when: inventory_hostname == groups['k8s_control_plane'][0]
|
||||||
|
register: kubernetes_certificate_result
|
||||||
|
|
||||||
# Set up nodes.
|
# Set up nodes.
|
||||||
- name: Get the kubeadm join command from the Kubernetes control plane.
|
- name: Get the kubeadm join command from the Kubernetes control plane.
|
||||||
command: kubeadm token create --print-join-command
|
command: kubeadm token create --print-join-command
|
||||||
changed_when: false
|
changed_when: false
|
||||||
when: kubernetes_role == 'control_plane'
|
when: inventory_hostname == groups['k8s_control_plane'][0]
|
||||||
register: kubernetes_join_command_result
|
register: kubernetes_join_command_result
|
||||||
|
|
||||||
- name: Set the kubeadm join command globally.
|
- name: Set the kubeadm join command globally.
|
||||||
@ -70,5 +84,19 @@
|
|||||||
delegate_facts: true
|
delegate_facts: true
|
||||||
with_items: "{{ groups['all'] }}"
|
with_items: "{{ groups['all'] }}"
|
||||||
|
|
||||||
|
- name: Set the kubeadm join certificate globally.
|
||||||
|
set_fact:
|
||||||
|
kubernetes_certificate: >
|
||||||
|
{{ kubernetes_certificate_result.stdout }}
|
||||||
|
when: kubernetes_certificate_result.stdout is defined
|
||||||
|
delegate_to: "{{ item }}"
|
||||||
|
delegate_facts: true
|
||||||
|
with_items: "{{ groups['all'] }}"
|
||||||
|
|
||||||
- include_tasks: node-setup.yml
|
- include_tasks: node-setup.yml
|
||||||
when: kubernetes_role == 'node'
|
when: kubernetes_role == 'node'
|
||||||
|
|
||||||
|
- include_tasks: control-plane-setup-aux.yml
|
||||||
|
when:
|
||||||
|
- inventory_hostname is in groups['k8s_control_plane']
|
||||||
|
- inventory_hostname != groups['k8s_control_plane'][0]
|
||||||
|
Loading…
Reference in New Issue
Block a user