From 300a399afff89c07b8f614a3ebdfc2044e7168ce Mon Sep 17 00:00:00 2001 From: Phil Sphicas Date: Mon, 26 Apr 2021 19:12:42 +0000 Subject: [PATCH] apiserver(-webhook): Allow fileless kube-apiserver command_options The kube-apiserver command line is constructed from a command_prefix array, and in the case of the apiserver chart, an arguments array, both defined in values.yaml. If an option needs to be added to the command line, the entire array needs to be redefined in a values.yaml override, which is sometimes inconvenient. There is an existing interface in the apiserver and apiserver-webhook charts to allow kube-apiserver arguments to be appended, but only when they are associated with a config file that is dynamically included in a configmap. The typical usage is similar to: conf: ignored_key_name: file: filename.yaml content: ... command_options: - --some-file=/etc/kubernetes/apiserver/filename.yaml This change removes the requirement to include a file in the configmap, allowing arbitrary command options to be appended. For example, in the apiserver chart, this is now possible: conf: ignored_key_name: command_options: - --service-account-issuer=apiserver Change-Id: I86283ecedd701c0f061da7b706d6ed54498f27a3 --- charts/apiserver-webhook/templates/config-dynamic-config.yaml | 2 ++ charts/apiserver/templates/configmap-etc.yaml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/charts/apiserver-webhook/templates/config-dynamic-config.yaml b/charts/apiserver-webhook/templates/config-dynamic-config.yaml index da16a437..630c4158 100644 --- a/charts/apiserver-webhook/templates/config-dynamic-config.yaml +++ b/charts/apiserver-webhook/templates/config-dynamic-config.yaml @@ -22,6 +22,7 @@ metadata: name: {{ .Release.Name }}-dynamic-config data: {{- range $key, $val := .Values.conf.apiserver }} +{{- if and (hasKey $val "file") (hasKey $val "content") }} {{ $val.file }}: | {{- if kindIs "string" $val.content }} {{ indent 4 $val.content }} @@ -30,3 +31,4 @@ data: {{- end }} {{- end -}} {{- end }} +{{- end }} diff --git a/charts/apiserver/templates/configmap-etc.yaml b/charts/apiserver/templates/configmap-etc.yaml index c62b45d5..2e957e8e 100644 --- a/charts/apiserver/templates/configmap-etc.yaml +++ b/charts/apiserver/templates/configmap-etc.yaml @@ -29,6 +29,7 @@ data: {{ tuple "etc/_kubeconfig.yaml.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} {{/* Dynamically added config files */}} {{- range $key, $val := .Values.conf }} +{{- if and (hasKey $val "file") (hasKey $val "content") }} {{ $val.file }}: | {{- if kindIs "string" $val.content }} {{ indent 4 $val.content }} @@ -37,3 +38,4 @@ data: {{- end }} {{- end }} {{- end }} +{{- end }}