-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Fix teleport-cluster chart service account logic causing ArgoCD deployments to fail
#49066
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -6,10 +6,48 @@ if serviceAccount is not defined or serviceAccount.name is empty, use .Release.N | |||||
| {{- coalesce .Values.serviceAccount.name .Release.Name -}} | ||||||
| {{- end -}} | ||||||
|
|
||||||
| {{/* | ||||||
| Create the name of the service account to use in the auth config check hook. | ||||||
|
|
||||||
| If the chart is creating service accounts, we know we can create new arbitrary service accounts. | ||||||
| We cannot reuse the same name as the deployment SA because the non-hook sevrice account might | ||||||
| not exist yet. We tried being smart with hooks but ArgoCD doesn't differentiate between install | ||||||
| and upgrade, causing various issues on update and eventually forcing us to use a separate SA. | ||||||
|
|
||||||
| If the chart is not creating service accounts, for backward compatibility we don't want | ||||||
| to force new service account names to existing chart users. We know the SA should already exist, | ||||||
| so we can use the same SA for deployments and hooks. | ||||||
| */}} | ||||||
| {{- define "teleport-cluster.auth.hookServiceAccountName" -}} | ||||||
| {{- include "teleport-cluster.auth.serviceAccountName" . -}} | ||||||
| {{- if .Values.serviceAccount.create -}} | ||||||
| -hook | ||||||
| {{- end}} | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Just for consistency with all other usage. |
||||||
| {{- end -}} | ||||||
|
|
||||||
| {{- define "teleport-cluster.proxy.serviceAccountName" -}} | ||||||
| {{- coalesce .Values.serviceAccount.name .Release.Name -}}-proxy | ||||||
| {{- end -}} | ||||||
|
|
||||||
| {{/* | ||||||
| Create the name of the service account to use in the proxy config check hook. | ||||||
|
|
||||||
| If the chart is creating service accounts, we know we can create new arbitrary service accounts. | ||||||
| We cannot reuse the same name as the deployment SA because the non-hook sevrice account might | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| not exist yet. We tried being smart with hooks but ArgoCD doesn't differentiate between install | ||||||
| and upgrade, causing various issues on update and eventually forcing us to use a separate SA. | ||||||
|
|
||||||
| If the chart is not creating service accounts, for backward compatibility we don't want | ||||||
| to force new service account names to existing chart users. We know the SA should already exist, | ||||||
| so we can use the same SA for deployments and hooks. | ||||||
| */}} | ||||||
| {{- define "teleport-cluster.proxy.hookServiceAccountName" -}} | ||||||
| {{- include "teleport-cluster.proxy.serviceAccountName" . -}} | ||||||
| {{- if .Values.serviceAccount.create -}} | ||||||
| -hook | ||||||
| {{- end}} | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Just for consistency with all other usage. |
||||||
| {{- end -}} | ||||||
|
|
||||||
| {{- define "teleport-cluster.version" -}} | ||||||
| {{- coalesce .Values.teleportVersionOverride .Chart.Version }} | ||||||
| {{- end -}} | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,8 +2,10 @@ suite: Pre-Deploy Config Test Hooks | |||||
| templates: | ||||||
| - auth/predeploy_job.yaml | ||||||
| - auth/predeploy_config.yaml | ||||||
| - auth/predeploy_serviceaccount.yaml | ||||||
| - proxy/predeploy_job.yaml | ||||||
| - proxy/predeploy_config.yaml | ||||||
| - proxy/predeploy_serviceaccount.yaml | ||||||
| tests: | ||||||
| - it: Deploys the auth-test config | ||||||
| template: auth/predeploy_config.yaml | ||||||
|
|
@@ -53,6 +55,7 @@ tests: | |||||
| asserts: | ||||||
| - hasDocuments: | ||||||
| count: 0 | ||||||
|
|
||||||
| - it: should set resources on auth predeploy job when set in values | ||||||
| template: auth/predeploy_job.yaml | ||||||
| values: | ||||||
|
|
@@ -189,41 +192,65 @@ tests: | |||||
| path: metadata.labels.baz | ||||||
| value: overridden | ||||||
|
|
||||||
| - it: should use default serviceAccount name for auth predeploy job SA when not set in values | ||||||
| - it: should use default serviceAccount name suffixed with -hook for auth predeploy job SA when not set in values and we're creating SAs | ||||||
| template: auth/predeploy_job.yaml | ||||||
| set: | ||||||
| clusterName: helm-lint | ||||||
| asserts: | ||||||
| - equal: | ||||||
| path: spec.template.spec.serviceAccountName | ||||||
| value: RELEASE-NAME-hook | ||||||
|
|
||||||
| - it: should use serviceAccount.name suffixed with -hook for auth predeploy job SA when set in values and we're creating SAs | ||||||
| template: auth/predeploy_job.yaml | ||||||
| set: | ||||||
| clusterName: helm-lint | ||||||
| serviceAccount: | ||||||
| name: helm-test-sa | ||||||
| asserts: | ||||||
| - equal: | ||||||
| path: spec.template.spec.serviceAccountName | ||||||
| value: RELEASE-NAME | ||||||
| value: helm-test-sa-hook | ||||||
|
|
||||||
| - it: should use serviceAccount.name for auth predeploy job SA when set in values | ||||||
| - it: should use serviceAccount.name for auth predeploy job SA when set in values and we're not cretaing SAs | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| template: auth/predeploy_job.yaml | ||||||
| set: | ||||||
| clusterName: helm-lint | ||||||
| serviceAccount: | ||||||
| name: helm-test-sa | ||||||
| create: false | ||||||
| asserts: | ||||||
| - equal: | ||||||
| path: spec.template.spec.serviceAccountName | ||||||
| value: helm-test-sa | ||||||
|
|
||||||
| - it: should use default serviceAccount name for proxy predeploy job SA when not set in values | ||||||
| - it: should use default serviceAccount name suffixed with -hook for proxy predeploy job SA when not set in values and we're creating SAs | ||||||
| template: proxy/predeploy_job.yaml | ||||||
| set: | ||||||
| clusterName: helm-lint | ||||||
| asserts: | ||||||
| - equal: | ||||||
| path: spec.template.spec.serviceAccountName | ||||||
| value: RELEASE-NAME-proxy | ||||||
| value: RELEASE-NAME-proxy-hook | ||||||
|
|
||||||
| - it: should use serviceAccount.name suffixed with -hook for proxy predeploy job SA when set in values and we're creating SAs | ||||||
| template: proxy/predeploy_job.yaml | ||||||
| set: | ||||||
| clusterName: helm-lint | ||||||
| serviceAccount: | ||||||
| name: helm-test-sa | ||||||
| asserts: | ||||||
| - equal: | ||||||
| path: spec.template.spec.serviceAccountName | ||||||
| value: helm-test-sa-proxy-hook | ||||||
|
|
||||||
| - it: should use serviceAccount.name for proxy predeploy job SA when set in values | ||||||
| - it: should use serviceAccount.name for proxy predeploy job SA when set in values and we're not cretaing SAs | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| template: proxy/predeploy_job.yaml | ||||||
| set: | ||||||
| clusterName: helm-lint | ||||||
| serviceAccount: | ||||||
| name: helm-test-sa | ||||||
| create: false | ||||||
| asserts: | ||||||
| - equal: | ||||||
| path: spec.template.spec.serviceAccountName | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.