From 305ac5e34049a497e66bf85653a0459cd85feab3 Mon Sep 17 00:00:00 2001 From: Julien Girardin Date: Mon, 22 Jan 2024 22:34:08 +0100 Subject: [PATCH] Support ignoring preflight check on upgrade --- roles/common_vars/defaults/main.yml | 1 + roles/init_cp/defaults/main.yml | 1 - roles/upgrade_cp/tasks/main.yml | 12 ++++++++++-- roles/upgrade_nodes/tasks/main.yml | 3 +++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/roles/common_vars/defaults/main.yml b/roles/common_vars/defaults/main.yml index 16e3613..188eef5 100644 --- a/roles/common_vars/defaults/main.yml +++ b/roles/common_vars/defaults/main.yml @@ -1,5 +1,6 @@ --- enable_kubeadm_patches: true +kubeadm_ignore_preflight_errors: [] kubeadm_patch_dir: /etc/kubernetes/patches kube_cp_group: kube_control_plane kube_worker_group: kube_workers diff --git a/roles/init_cp/defaults/main.yml b/roles/init_cp/defaults/main.yml index 2423b31..0a59e30 100644 --- a/roles/init_cp/defaults/main.yml +++ b/roles/init_cp/defaults/main.yml @@ -1,4 +1,3 @@ --- -kubeadm_ignore_preflight_errors: [] kubeadm_api_advertise_cidr: '' kubeadm_node_ip_cidr: '' diff --git a/roles/upgrade_cp/tasks/main.yml b/roles/upgrade_cp/tasks/main.yml index b4bf9a5..a617487 100644 --- a/roles/upgrade_cp/tasks/main.yml +++ b/roles/upgrade_cp/tasks/main.yml @@ -1,6 +1,10 @@ --- - name: 'Plan upgrade' - command: kubeadm upgrade plan {{ kubeadm_version.version.split( '-' )|first }} + command: >- + kubeadm upgrade plan {{ kubeadm_version.version.split( '-' )|first }} + {% for error in kubeadm_ignore_preflight_errors %} + --ignore-preflight-errors={{ error }} + {% endfor %} environment: KUBECONFIG: '/etc/kubernetes/admin.conf' register: plan_upgrade @@ -12,7 +16,11 @@ stdout=plan_upgrade.stdout_lines) }} - name: 'Apply upgrade' - command: kubeadm upgrade apply {{ kubeadm_version.version.split( '-' )|first }} -y + command: >- + kubeadm upgrade apply {{ kubeadm_version.version.split( '-' )|first }} -y + {% for error in kubeadm_ignore_preflight_errors %} + --ignore-preflight-errors={{ error }} + {% endfor %} register: apply_upgrade - name: 'Display result of "kubectl upgrade apply"' diff --git a/roles/upgrade_nodes/tasks/main.yml b/roles/upgrade_nodes/tasks/main.yml index 0494a9f..64c0c58 100644 --- a/roles/upgrade_nodes/tasks/main.yml +++ b/roles/upgrade_nodes/tasks/main.yml @@ -16,6 +16,9 @@ {{ kubeadm_patch_dir }} {%- endif %} {%- endif -%} + {% for error in kubeadm_ignore_preflight_errors %} + --ignore-preflight-errors={{ error }} + {% endfor %} register: upgrade_node - name: 'Display result of "kubeadm upgrade node"'