From 4eadf3228eee99ba3b37c64665f9f2bc52ceef37 Mon Sep 17 00:00:00 2001 From: Robert Everson Date: Mon, 6 Aug 2018 11:50:48 -0700 Subject: [PATCH] Only add admission plugins if defined --- roles/kubernetes/master/defaults/main.yml | 2 +- roles/kubernetes/master/templates/kubeadm-config.yaml.j2 | 4 ++++ .../master/templates/manifests/kube-apiserver.manifest.j2 | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/roles/kubernetes/master/defaults/main.yml b/roles/kubernetes/master/defaults/main.yml index eda412999..82669e8b3 100644 --- a/roles/kubernetes/master/defaults/main.yml +++ b/roles/kubernetes/master/defaults/main.yml @@ -41,7 +41,7 @@ kube_apiserver_cpu_limit: 800m kube_apiserver_memory_requests: 256M kube_apiserver_cpu_requests: 100m -# Admission control plug-ins +# 1.9 and below Admission control plug-ins kube_apiserver_admission_control: - Initializers - NamespaceLifecycle diff --git a/roles/kubernetes/master/templates/kubeadm-config.yaml.j2 b/roles/kubernetes/master/templates/kubeadm-config.yaml.j2 index 438b900a9..401892ca9 100644 --- a/roles/kubernetes/master/templates/kubeadm-config.yaml.j2 +++ b/roles/kubernetes/master/templates/kubeadm-config.yaml.j2 @@ -37,8 +37,12 @@ apiServerExtraArgs: {% if kube_version | version_compare('v1.10', '<') %} admission-control: {{ kube_apiserver_admission_control | join(',') }} {% else %} +{% if kube_apiserver_enable_admission_plugins|length > 0 %} enable-admission-plugins: {{ kube_apiserver_enable_admission_plugins | join(',') }} +{% endif %} +{% if kube_apiserver_disable_admission_plugins|length > 0 %} disable-admission-plugins: {{ kube_apiserver_disable_admission_plugins | join(',') }} +{% endif %} {% endif %} apiserver-count: "{{ kube_apiserver_count }}" {% if kube_version | version_compare('v1.9', '>=') %} diff --git a/roles/kubernetes/master/templates/manifests/kube-apiserver.manifest.j2 b/roles/kubernetes/master/templates/manifests/kube-apiserver.manifest.j2 index c373ee285..82bd1db93 100644 --- a/roles/kubernetes/master/templates/manifests/kube-apiserver.manifest.j2 +++ b/roles/kubernetes/master/templates/manifests/kube-apiserver.manifest.j2 @@ -48,8 +48,12 @@ spec: {% if kube_version | version_compare('v1.10', '<') %} - --admission-control={{ kube_apiserver_admission_control | join(',') }} {% else %} +{% if kube_apiserver_enable_admission_plugins|length > 0 %} - --enable-admission-plugins={{ kube_apiserver_enable_admission_plugins | join(',') }} +{% endif %} +{% if kube_apiserver_disable_admission_plugins|length > 0 %} - --disable-admission-plugins={{ kube_apiserver_disable_admission_plugins | join(',') }} +{% endif %} {% endif %} - --service-cluster-ip-range={{ kube_service_addresses }} - --service-node-port-range={{ kube_apiserver_node_port_range }}