Skip to content

Commit

Permalink
Allow using Workload Identity with helm chart (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
calind authored Apr 10, 2020
1 parent 11c4df5 commit dcf02c8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ spec:
value: {{ .Values.drainTimeout | quote }}
- name: INTERVAL
value: {{ .Values.interval | quote }}
{{- if not .Values.secret.workloadIdentityServiceAccount }}
- name: GOOGLE_APPLICATION_CREDENTIALS
value: /gcp-service-account/service-account-key.json
{{- end }}
{{- range $key, $value := .Values.extraEnv }}
- name: {{ $key }}
value: {{ $value }}
Expand All @@ -71,14 +73,18 @@ spec:
timeoutSeconds: 5
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- if not .Values.secret.workloadIdentityServiceAccount }}
volumeMounts:
- name: gcp-service-account-secret
mountPath: /gcp-service-account
{{- end }}
terminationGracePeriodSeconds: 300
{{- if not .Values.secret.workloadIdentityServiceAccount }}
volumes:
- name: gcp-service-account-secret
secret:
secretName: {{ include "estafette-gke-preemptible-killer.fullname" . }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand Down
4 changes: 3 additions & 1 deletion helm/estafette-gke-preemptible-killer/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not .Values.secret.workloadIdentityServiceAccount }}
apiVersion: v1
kind: Secret
metadata:
Expand All @@ -18,4 +19,5 @@ data:
{{- else }}
service-account-key.json: {{.Values.secret.googleServiceAccountKeyfileJson | toString | b64enc}}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ metadata:
namespace: {{ .Release.Namespace }}
labels:
{{ include "estafette-gke-preemptible-killer.labels" . | indent 4 }}
{{- if .Values.secret.workloadIdentityServiceAccount }}
annotations:
iam.gke.io/gcp-service-account: {{ .Values.secret.workloadIdentityServiceAccount }}
{{- end }}
{{- end -}}
3 changes: 3 additions & 0 deletions helm/estafette-gke-preemptible-killer/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ secret:
# when using estafette-gcp-service account controller to fetch key files, set this to true and leave googleServiceAccountKeyfileJson empty
useGcpServiceAccountAnnotation: false

# when using workload identity set this to the Google Cloud Service Account
workloadIdentityServiceAccount: ""

# sets a json keyfile for a gcp service account
googleServiceAccountKeyfileJson: '{"type": "service_account"}'

Expand Down

0 comments on commit dcf02c8

Please sign in to comment.