mirror of
https://github.com/geerlingguy/ansible-role-kubernetes.git
synced 2025-06-01 01:17:34 +02:00
Logic to replace kube proxy (or not)
This commit is contained in:
parent
7da0060f92
commit
3fa74ece8c
@ -9,6 +9,14 @@
|
|||||||
src: "kubeadm-kubelet-config.j2"
|
src: "kubeadm-kubelet-config.j2"
|
||||||
dest: "{{ kubernetes_kubeadm_kubelet_config_file_path }}"
|
dest: "{{ kubernetes_kubeadm_kubelet_config_file_path }}"
|
||||||
|
|
||||||
|
- name: Determine if we are deploying kube-proxy
|
||||||
|
set_fact:
|
||||||
|
replace_kube_proxy: >
|
||||||
|
(kubernetes_pod_network.cni == 'cilium') and
|
||||||
|
(kubernetes_cilium_values is defined) and
|
||||||
|
(kubernetes_cilium_values.kubeProxyReplacement is defined) and
|
||||||
|
(kubernetes_cilium_values.kubeProxyReplacement)
|
||||||
|
|
||||||
- name: Initialize Kubernetes control plane with kubeadm init
|
- name: Initialize Kubernetes control plane with kubeadm init
|
||||||
command: >
|
command: >
|
||||||
kubeadm init
|
kubeadm init
|
||||||
@ -18,7 +26,7 @@
|
|||||||
when: >
|
when: >
|
||||||
(not kubernetes_init_stat.stat.exists) and
|
(not kubernetes_init_stat.stat.exists) and
|
||||||
(kubernetes_ignore_preflight_errors is not defined) and
|
(kubernetes_ignore_preflight_errors is not defined) and
|
||||||
(not kubernetes_cilium_values.kubeProxyReplacement)
|
(not replace_kube_proxy)
|
||||||
|
|
||||||
- name: Initialize Kubernetes control plane with kubeadm init and ignore_preflight_errors
|
- name: Initialize Kubernetes control plane with kubeadm init and ignore_preflight_errors
|
||||||
command: >
|
command: >
|
||||||
@ -30,7 +38,7 @@
|
|||||||
when: >
|
when: >
|
||||||
(not kubernetes_init_stat.stat.exists) and
|
(not kubernetes_init_stat.stat.exists) and
|
||||||
(kubernetes_ignore_preflight_errors is defined) and
|
(kubernetes_ignore_preflight_errors is defined) and
|
||||||
(not kubernetes_cilium_values.kubeProxyReplacement)
|
(not replace_kube_proxy)
|
||||||
|
|
||||||
- name: Initialize Kubernetes control plane with kubeadm init without kube-proxy
|
- name: Initialize Kubernetes control plane with kubeadm init without kube-proxy
|
||||||
command: >
|
command: >
|
||||||
@ -42,7 +50,7 @@
|
|||||||
when: >
|
when: >
|
||||||
(not kubernetes_init_stat.stat.exists) and
|
(not kubernetes_init_stat.stat.exists) and
|
||||||
(kubernetes_ignore_preflight_errors is not defined) and
|
(kubernetes_ignore_preflight_errors is not defined) and
|
||||||
(kubernetes_cilium_values.kubeProxyReplacement)
|
(replace_kube_proxy)
|
||||||
|
|
||||||
- name: Initialize Kubernetes control plane with kubeadm init without kube-proxy and ignore_preflight_errors
|
- name: Initialize Kubernetes control plane with kubeadm init without kube-proxy and ignore_preflight_errors
|
||||||
command: >
|
command: >
|
||||||
@ -54,8 +62,8 @@
|
|||||||
register: kubeadmin_init
|
register: kubeadmin_init
|
||||||
when: >
|
when: >
|
||||||
(not kubernetes_init_stat.stat.exists) and
|
(not kubernetes_init_stat.stat.exists) and
|
||||||
(kubernetes_ignore_preflight_errors is defined) and
|
(kubernetes_ignore_preflight_errors is defined)
|
||||||
(kubernetes_cilium_values.kubeProxyReplacement)
|
(replace_kube_proxy)
|
||||||
|
|
||||||
- name: Print the init output to screen.
|
- name: Print the init output to screen.
|
||||||
debug:
|
debug:
|
||||||
@ -146,6 +154,22 @@
|
|||||||
delay: 5
|
delay: 5
|
||||||
|
|
||||||
- name: Configure Cilium networking
|
- name: Configure Cilium networking
|
||||||
|
command: >
|
||||||
|
/usr/local/bin/cilium install
|
||||||
|
--version {{ kubernetes_cilium_version }}
|
||||||
|
--datapath-mode {{ kubernetes_cilium_datapath }}
|
||||||
|
--values /tmp/cilium_helm.yaml
|
||||||
|
when:
|
||||||
|
- kubernetes_pod_network.cni == 'cilium'
|
||||||
|
- not kubernetes_init_stat.stat.exists
|
||||||
|
- not replace_kube_proxy
|
||||||
|
register: cilium_result
|
||||||
|
changed_when: "'Error' not in cilium_result.stdout"
|
||||||
|
until: cilium_result is not failed
|
||||||
|
retries: 20
|
||||||
|
delay: 5
|
||||||
|
|
||||||
|
- name: Configure Cilium networking and replace kube-proxy
|
||||||
command: >
|
command: >
|
||||||
/usr/local/bin/cilium install
|
/usr/local/bin/cilium install
|
||||||
--version {{ kubernetes_cilium_version }}
|
--version {{ kubernetes_cilium_version }}
|
||||||
@ -156,6 +180,8 @@
|
|||||||
when:
|
when:
|
||||||
- kubernetes_pod_network.cni == 'cilium'
|
- kubernetes_pod_network.cni == 'cilium'
|
||||||
- not kubernetes_init_stat.stat.exists
|
- not kubernetes_init_stat.stat.exists
|
||||||
|
- replace_kube_proxy
|
||||||
|
|
||||||
register: cilium_result
|
register: cilium_result
|
||||||
changed_when: "'Error' not in cilium_result.stdout"
|
changed_when: "'Error' not in cilium_result.stdout"
|
||||||
until: cilium_result is not failed
|
until: cilium_result is not failed
|
||||||
|
Loading…
Reference in New Issue
Block a user