From df425ac1438b90017c2a26773ead9e97cd802597 Mon Sep 17 00:00:00 2001 From: forselli-stratio <41321889+forselli-stratio@users.noreply.github.com> Date: Tue, 11 Jan 2022 00:24:25 +0100 Subject: [PATCH] Fix etcd certificates reference to support etcd_kubeadm_enabled:true (#7766) * Fix etcd certificates reference to support etcd_kubeadm_enabled:true * Add retries to ETCD Join Member task * Fix etcd certificates reference when etcd_kubeadm_enabled:true * Fix conflicts --- recover-control-plane.yml | 2 +- roles/network_plugin/canal/tasks/main.yml | 6 +++--- roles/remove-node/remove-etcd-node/tasks/main.yml | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/recover-control-plane.yml b/recover-control-plane.yml index 4d08f3a90..559504a08 100644 --- a/recover-control-plane.yml +++ b/recover-control-plane.yml @@ -16,7 +16,7 @@ environment: "{{ proxy_disable_env }}" roles: - { role: kubespray-defaults} - - { role: recover_control_plane/etcd } + - { role: recover_control_plane/etcd, when: "not etcd_kubeadm_enabled|default(false)" } - hosts: kube_control_plane[0] environment: "{{ proxy_disable_env }}" diff --git a/roles/network_plugin/canal/tasks/main.yml b/roles/network_plugin/canal/tasks/main.yml index 29e4129cc..aa4852135 100644 --- a/roles/network_plugin/canal/tasks/main.yml +++ b/roles/network_plugin/canal/tasks/main.yml @@ -42,9 +42,9 @@ run_once: true environment: ETCDCTL_API: 2 - ETCDCTL_CA_FILE: "{{ etcd_cert_dir }}/ca.pem" - ETCDCTL_CERT_FILE: "{{ etcd_cert_dir }}/admin-{{ groups['etcd'][0] }}.pem" - ETCDCTL_KEY_FILE: "{{ etcd_cert_dir }}/admin-{{ groups['etcd'][0] }}-key.pem" + ETCDCTL_CA_FILE: "{{ kube_cert_dir + '/etcd/ca.crt' if etcd_kubeadm_enabled else etcd_cert_dir + '/ca.pem' }}" + ETCDCTL_CERT_FILE: "{{ kube_cert_dir + '/etcd/server.crt' if etcd_kubeadm_enabled else etcd_cert_dir + '/admin-' + groups['etcd'][0] + '.pem' }}" + ETCDCTL_KEY_FILE: "{{ kube_cert_dir + '/etcd/server.key' if etcd_kubeadm_enabled else etcd_cert_dir + '/admin-' + groups['etcd'][0] + '-key.pem' }}" ETCDCTL_ENDPOINTS: "{{ etcd_access_addresses }}" - name: Canal | Create canal node manifests diff --git a/roles/remove-node/remove-etcd-node/tasks/main.yml b/roles/remove-node/remove-etcd-node/tasks/main.yml index 3d01f332b..6ff7a0f15 100644 --- a/roles/remove-node/remove-etcd-node/tasks/main.yml +++ b/roles/remove-node/remove-etcd-node/tasks/main.yml @@ -34,9 +34,9 @@ - facts environment: ETCDCTL_API: 3 - ETCDCTL_CERT: "{{ etcd_cert_dir }}/admin-{{ groups['etcd']|first }}.pem" - ETCDCTL_KEY: "{{ etcd_cert_dir }}/admin-{{ groups['etcd']|first }}-key.pem" - ETCDCTL_CACERT: "{{ etcd_cert_dir }}/ca.pem" + ETCDCTL_CERT: "{{ kube_cert_dir + '/etcd/server.crt' if etcd_kubeadm_enabled else etcd_cert_dir + '/admin-' + groups['etcd']|first + '.pem' }}" + ETCDCTL_KEY: "{{ kube_cert_dir + '/etcd/server.key' if etcd_kubeadm_enabled else etcd_cert_dir + '/admin-' + groups['etcd']|first + '-key.pem' }}" + ETCDCTL_CACERT: "{{ kube_cert_dir + '/etcd/ca.crt' if etcd_kubeadm_enabled else etcd_cert_dir + '/ca.pem' }}" ETCDCTL_ENDPOINTS: "https://{{ hostvars[groups['etcd']|first]['etcd_access_address'] | default(hostvars[groups['etcd']|first]['ip']) | default(hostvars[groups['etcd']|first]['fallback_ips'][groups['etcd']|first]) }}:2379" @@ -52,9 +52,9 @@ - facts environment: ETCDCTL_API: 3 - ETCDCTL_CERT: "{{ etcd_cert_dir }}/admin-{{ groups['etcd']|first }}.pem" - ETCDCTL_KEY: "{{ etcd_cert_dir }}/admin-{{ groups['etcd']|first }}-key.pem" - ETCDCTL_CACERT: "{{ etcd_cert_dir }}/ca.pem" + ETCDCTL_CERT: "{{ kube_cert_dir + '/etcd/server.crt' if etcd_kubeadm_enabled else etcd_cert_dir + '/admin-' + groups['etcd']|first + '.pem' }}" + ETCDCTL_KEY: "{{ kube_cert_dir + '/etcd/server.key' if etcd_kubeadm_enabled else etcd_cert_dir + '/admin-' + groups['etcd']|first + '-key.pem' }}" + ETCDCTL_CACERT: "{{ kube_cert_dir + '/etcd/ca.crt' if etcd_kubeadm_enabled else etcd_cert_dir + '/ca.pem' }}" ETCDCTL_ENDPOINTS: "https://{{ hostvars[groups['etcd']|first]['etcd_access_address'] | default(hostvars[groups['etcd']|first]['ip']) | default(hostvars[groups['etcd']|first]['fallback_ips'][groups['etcd']|first]) }}:2379"