-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
helm: Add serviceAccountName to pre-deploy jobs (#48530)
* helm: Add serviceAccountName to pre-deploy jobs Fixes #48477 * Create separate serviceAccount resources for running pre-deploy hooks * Clarification
- Loading branch information
Showing
5 changed files
with
106 additions
and
1 deletion.
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
34 changes: 34 additions & 0 deletions
34
examples/chart/teleport-cluster/templates/auth/predeploy_serviceaccount.yaml
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,34 @@ | ||
# this is a carbon copy of the regular serviceAccount object which is only used to run pre-deploy jobs | ||
# upon first install of the chart. it will be deleted by Helm after the pre-deploy hooks run, then the | ||
# regular serviceAccount is created with the same name and exists for the lifetime of the release. | ||
{{- $auth := mustMergeOverwrite (mustDeepCopy .Values) .Values.auth -}} | ||
{{- $projectedServiceAccountToken := semverCompare ">=1.20.0-0" .Capabilities.KubeVersion.Version }} | ||
{{- if $auth.serviceAccount.create }} | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: {{ template "teleport-cluster.auth.serviceAccountName" . }} | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
{{- include "teleport-cluster.auth.labels" . | nindent 4 }} | ||
{{- if $auth.extraLabels.serviceAccount }} | ||
{{- toYaml $auth.extraLabels.serviceAccount | nindent 4 }} | ||
{{- end }} | ||
annotations: | ||
# this ServiceAccount resource MUST only be hooked on pre-install, as it would conflict | ||
# with the existing ServiceAccount if hooked on pre-upgrade. | ||
"helm.sh/hook": pre-install | ||
"helm.sh/hook-weight": "3" | ||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded | ||
{{- if or $auth.annotations.serviceAccount $auth.azure.clientID }} | ||
{{- if $auth.annotations.serviceAccount }} | ||
{{- toYaml $auth.annotations.serviceAccount | nindent 4 }} | ||
{{- end }} | ||
{{- if $auth.azure.clientID }} | ||
azure.workload.identity/client-id: "{{ $auth.azure.clientID }}" | ||
{{- end }} | ||
{{- end -}} | ||
{{- if $projectedServiceAccountToken }} | ||
automountServiceAccountToken: false | ||
{{- 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
29 changes: 29 additions & 0 deletions
29
examples/chart/teleport-cluster/templates/proxy/predeploy_serviceaccount.yaml
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,29 @@ | ||
# this is a carbon copy of the regular serviceAccount object which is only used to run pre-deploy jobs | ||
# upon first install of the chart. it will be deleted by Helm after the pre-deploy hooks run, then the | ||
# regular serviceAccount is created with the same name and exists for the lifetime of the release. | ||
{{- $proxy := mustMergeOverwrite (mustDeepCopy .Values) .Values.proxy -}} | ||
{{- $projectedServiceAccountToken := semverCompare ">=1.20.0-0" .Capabilities.KubeVersion.Version }} | ||
{{- if $proxy.serviceAccount.create }} | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: {{ include "teleport-cluster.proxy.serviceAccountName" . }} | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
{{- include "teleport-cluster.proxy.labels" . | nindent 4 }} | ||
{{- if $proxy.extraLabels.serviceAccount }} | ||
{{- toYaml $proxy.extraLabels.serviceAccount | nindent 4 }} | ||
{{- end }} | ||
annotations: | ||
# this ServiceAccount resource MUST only be hooked on pre-install, as it would conflict | ||
# with the existing ServiceAccount if hooked on pre-upgrade. | ||
"helm.sh/hook": pre-install | ||
"helm.sh/hook-weight": "3" | ||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded | ||
{{- if $proxy.annotations.serviceAccount }} | ||
{{- toYaml $proxy.annotations.serviceAccount | nindent 4 }} | ||
{{- end -}} | ||
{{- if $projectedServiceAccountToken }} | ||
automountServiceAccountToken: false | ||
{{- 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