-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add external spire-controller-managers
Only one external controller manager is supported at a time until spiffe/spire#4898 is resolved. Signed-off-by: Kevin Fox <[email protected]>
- Loading branch information
Showing
7 changed files
with
288 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
142 changes: 142 additions & 0 deletions
142
charts/spire/charts/spire-server/templates/_controller-manager-container.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
{{- define "spire-controller-manager.containers" }} | ||
{{- $root := . }} | ||
{{- $settings := dict }} | ||
{{- $defaults := .Values.controllerManager }} | ||
{{- $webhooksEnabled := .Values.controllerManager.validatingWebhookConfiguration.enabled }} | ||
{{- $startPort := 8082 }} | ||
{{- $reconcileFederation := 0 }} | ||
{{- $reconcileEntries := 0 }} | ||
{{- if eq (.Values.controllerManager.enabled | toString) "true" }} | ||
{{- if .Values.controllerManager.reconcile.clusterFederatedTrustDomains }} | ||
{{- $reconcileFederation = add $reconcileFederation 1 }} | ||
{{- end }} | ||
{{- if or .Values.controllerManager.reconcile.clusterSPIFFEIDs .Values.controllerManager.reconcile.clusterStaticEntries }} | ||
{{- $reconcileEntries = add $reconcileEntries 1 }} | ||
{{- end }} | ||
{{- include "spire-controller-manager.container" (dict "Values" .Values "Chart" .Chart "startPort" $startPort "suffix" "" "settings" $settings "defaults" $defaults "webhooksEnabled" $webhooksEnabled) }} | ||
{{- end }} | ||
{{- if .Values.externalControllerManagers.enabled }} | ||
{{- $clusters := default .Values.kubeConfigs .Values.externalControllerManagers.clusters }} | ||
{{- $clusterDefaults := .Values.externalControllerManagers.defaults }} | ||
{{- range $name, $_ := $clusters }} | ||
{{- $clusterSettings := dict }} | ||
{{- if hasKey $root.Values.externalControllerManagers.clusters $name }} | ||
{{- $clusterSettings = index $root.Values.externalControllerManagers.clusters $name }} | ||
{{- end }} | ||
{{- $suffix := printf "-%s" $name }} | ||
{{- $startPort = add $startPort 2 }} | ||
{{- $kubeConfig := $name }} | ||
{{- if hasKey $clusterSettings "kubeConfigName" }} | ||
{{- $kubeConfig = $clusterSettings.kubeConfigName }} | ||
{{- end }} | ||
{{- $reconcile := dict }} | ||
{{- if hasKey $clusterSettings "reconcile" }} | ||
{{- $reconcile = $clusterSettings.reconcile }} | ||
{{- end }} | ||
{{- if and (hasKey $reconcile "clusterFederatedTrustDomains") $reconcile.clusterFederatedTrustDomains }} | ||
{{- $reconcileFederation = add $reconcileFederation 1 }} | ||
{{- else if $clusterDefaults.reconcile.clusterFederatedTrustDomains }} | ||
{{- $reconcileFederation = add $reconcileFederation 1 }} | ||
{{- end }} | ||
{{- if gt $reconcileFederation 1 }} | ||
{{- fail "You can only have one controller-manager with reconcile.clusterFederatedTrustDomains set to true" }} | ||
{{- end }} | ||
{{- $entryFound := false }} | ||
{{- if and (hasKey $reconcile "clusterSPIFFEIDs") $reconcile.clusterSPIFFEIDs }} | ||
{{- $entryFound = true }} | ||
{{- else if $clusterDefaults.reconcile.clusterSPIFFEIDs }} | ||
{{- $entryFound = true }} | ||
{{- end }} | ||
{{- if and (hasKey $reconcile "clusterStaticEntries") $reconcile.clusterStaticEntries }} | ||
{{- $entryFound = true }} | ||
{{- else if $clusterDefaults.reconcile.clusterStaticEntries }} | ||
{{- $entryFound = true }} | ||
{{- end }} | ||
{{- if $entryFound }} | ||
{{- $reconcileEntries = add $reconcileEntries 1 }} | ||
{{- end }} | ||
{{- if gt $reconcileEntries 1 }} | ||
{{- fail "You can only have one controller-manager reconciling entries with either reconcile.clusterSPIFFEIDs or clusterStaticEntries" }} | ||
{{- end }} | ||
{{- include "spire-controller-manager.container" (dict "Values" $root.Values "Chart" $root.Chart "startPort" $startPort "suffix" $suffix "settings" $clusterSettings "defaults" $clusterDefaults "webhooksEnabled" false "kubeConfig" $kubeConfig ) }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
{{- define "spire-controller-manager.container" }} | ||
{{- $promPort := .startPort }} | ||
{{- $healthPort := add .startPort 1 }} | ||
{{- $extraEnv := .defaults.extraEnv }} | ||
{{- if hasKey .settings "extraEnv" }} | ||
{{- $extraEnv = .settings.extraEnv }} | ||
{{- end }} | ||
{{- $expandEnv := .defaults.expandEnv }} | ||
{{- if hasKey .settings "expandEnv" }} | ||
{{- $extraEnv = .settings.expandEnv }} | ||
{{- end }} | ||
{{- $securityContext := .defaults.securityContext }} | ||
{{- if hasKey .settings "securityContext" }} | ||
{{- $securityContext = mergeOverwrite .defaults.securityContext .settings.securityContext }} | ||
{{- end }} | ||
- name: spire-controller-manager{{ .suffix }} | ||
securityContext: | ||
{{- include "spire-lib.securitycontext-extended" (dict "root" . "securityContext" $securityContext) | nindent 4 }} | ||
image: {{ template "spire-lib.image" (dict "appVersion" .Chart.AppVersion "image" .Values.controllerManager.image "global" .Values.global) }} | ||
imagePullPolicy: {{ .Values.controllerManager.image.pullPolicy }} | ||
args: | ||
{{- if hasKey . "kubeConfig" }} | ||
- --kubeconfig=/kubeconfigs/{{ .kubeConfig }} | ||
{{- end }} | ||
- --config=controller-manager-config{{ .suffix }}.yaml | ||
{{- if $expandEnv }} | ||
- --expand-env | ||
{{- end }} | ||
env: | ||
- name: ENABLE_WEBHOOKS | ||
value: {{ .webhooksEnabled | toString | quote }} | ||
{{- if gt (len $extraEnv) 0 }} | ||
{{- $extraEnv | toYaml | nindent 4 }} | ||
{{- end }} | ||
ports: | ||
{{- if .webhooksEnabled }} | ||
- name: https | ||
containerPort: 9443 | ||
protocol: TCP | ||
{{- end }} | ||
- containerPort: {{ $healthPort }} | ||
name: healthz | ||
{{- if or (dig "telemetry" "prometheus" "enabled" .Values.telemetry.prometheus.enabled .Values.global) (and (dig "spire" "recommendations" "enabled" false .Values.global) (dig "spire" "recommendations" "prometheus" true .Values.global)) }} | ||
- containerPort: {{ $promPort }} | ||
name: prom-cm{{ .suffix }} | ||
{{- end }} | ||
livenessProbe: | ||
httpGet: | ||
path: /healthz | ||
port: healthz | ||
readinessProbe: | ||
httpGet: | ||
path: /readyz | ||
port: healthz | ||
resources: | ||
{{- toYaml .Values.controllerManager.resources | nindent 4 }} | ||
volumeMounts: | ||
- name: spire-server-socket | ||
mountPath: /tmp/spire-server/private | ||
readOnly: true | ||
- name: controller-manager-config | ||
mountPath: /controller-manager-config{{ .suffix }}.yaml | ||
subPath: controller-manager-config{{ .suffix }}.yaml | ||
readOnly: true | ||
{{- with .kubeConfig }} | ||
- name: kubeconfigs | ||
mountPath: /kubeconfigs/{{ . }} | ||
subPath: {{ . }} | ||
readOnly: true | ||
{{- end }} | ||
- name: spire-controller-manager-tmp | ||
mountPath: /tmp | ||
subPath: {{ printf "spire-controller-manager%s" .suffix }} | ||
readOnly: false | ||
{{- if gt (len .Values.extraVolumeMounts) 0 }} | ||
{{- toYaml .Values.extraVolumeMounts | nindent 4 }} | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.