From a57aa69a3db7806c0874c4ea80fcd7780c0faa59 Mon Sep 17 00:00:00 2001 From: Max Gautier Date: Tue, 12 Oct 2021 09:31:47 +0200 Subject: [PATCH] etcd: deploy container engine if needed (#7532) If the etcd cluster is separate and the etcd_deployment_type is "host", there is no need for a container engine on the etcd nodes Do not rely on a 'default(true)' filter, but define a proper default in kubespray-defaults depending on etcd deployment method and if internal or external etcd is used --- cluster.yml | 2 +- roles/kubespray-defaults/defaults/main/main.yaml | 3 +++ roles/reset/tasks/main.yml | 2 +- scale.yml | 2 +- upgrade-cluster.yml | 6 +++--- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cluster.yml b/cluster.yml index 7fddfb05ca6..b90cf7fb344 100644 --- a/cluster.yml +++ b/cluster.yml @@ -32,7 +32,7 @@ roles: - { role: kubespray-defaults } - { role: kubernetes/preinstall, tags: preinstall } - - { role: "container-engine", tags: "container-engine", when: deploy_container_engine|default(true) } + - { role: "container-engine", tags: "container-engine", when: deploy_container_engine } - { role: download, tags: download, when: "not skip_downloads" } - hosts: etcd diff --git a/roles/kubespray-defaults/defaults/main/main.yaml b/roles/kubespray-defaults/defaults/main/main.yaml index d38ff785b87..4cba6ef8c80 100644 --- a/roles/kubespray-defaults/defaults/main/main.yaml +++ b/roles/kubespray-defaults/defaults/main/main.yaml @@ -240,6 +240,9 @@ kubelet_shutdown_grace_period: 60s # to give normal pods time to be gracefully evacuated kubelet_shutdown_grace_period_critical_pods: 20s +# Whether to deploy the container engine +deploy_container_engine: inventory_hostname in groups['k8s_cluster'] or etcd_deployment_type != 'host' + # Container for runtime container_manager: docker diff --git a/roles/reset/tasks/main.yml b/roles/reset/tasks/main.yml index 5a20e533131..11f6a8165d9 100644 --- a/roles/reset/tasks/main.yml +++ b/roles/reset/tasks/main.yml @@ -100,7 +100,7 @@ when: - crictl.stat.exists - container_manager in ["crio", "containerd"] - - deploy_container_engine|default(true) + - deploy_container_engine - name: reset | stop and disable crio service service: diff --git a/scale.yml b/scale.yml index 42fc20a94e2..11bc40ee649 100644 --- a/scale.yml +++ b/scale.yml @@ -53,7 +53,7 @@ roles: - { role: kubespray-defaults } - { role: kubernetes/preinstall, tags: preinstall } - - { role: container-engine, tags: "container-engine", when: deploy_container_engine|default(true) } + - { role: container-engine, tags: "container-engine", when: deploy_container_engine } - { role: download, tags: download, when: "not skip_downloads" } - { role: etcd, tags: etcd, etcd_cluster_setup: false, when: "not etcd_kubeadm_enabled|default(false)" } diff --git a/upgrade-cluster.yml b/upgrade-cluster.yml index 75f73814b5f..74e32145468 100644 --- a/upgrade-cluster.yml +++ b/upgrade-cluster.yml @@ -57,7 +57,7 @@ serial: "{{ serial | default('20%') }}" roles: - { role: kubespray-defaults } - - { role: container-engine, tags: "container-engine", when: deploy_container_engine|default(true) } + - { role: container-engine, tags: "container-engine", when: deploy_container_engine } - hosts: etcd gather_facts: False @@ -94,7 +94,7 @@ roles: - { role: kubespray-defaults } - { role: upgrade/pre-upgrade, tags: pre-upgrade } - - { role: container-engine, tags: "container-engine", when: deploy_container_engine|default(true) } + - { role: container-engine, tags: "container-engine", when: deploy_container_engine } - { role: kubernetes/node, tags: node } - { role: kubernetes/control-plane, tags: master, upgrade_cluster_setup: true } - { role: kubernetes/client, tags: client } @@ -125,7 +125,7 @@ roles: - { role: kubespray-defaults } - { role: upgrade/pre-upgrade, tags: pre-upgrade } - - { role: container-engine, tags: "container-engine", when: deploy_container_engine|default(true) } + - { role: container-engine, tags: "container-engine", when: deploy_container_engine } - { role: kubernetes/node, tags: node } - { role: kubernetes/kubeadm, tags: kubeadm, when: "kubeadm_enabled" } - { role: kubernetes/node-label, tags: node-label }