Skip to content

Commit d288387

Browse files
authored
[sophora-image-ai] enable use of a service account (#197)
1 parent 5109d8a commit d288387

File tree

6 files changed

+45
-3
lines changed

6 files changed

+45
-3
lines changed

charts/sophora-image-ai/Chart.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ apiVersion: v2
22
name: sophora-image-ai
33
description: Sophora Image AI
44
type: application
5-
version: 2.0.0
5+
version: 2.1.0
66
appVersion: 5.1.0
77
sources:
88
- https://github.com/subshell/helm-charts/tree/main/charts/sophora-image-ai
99
annotations:
1010
artifacthub.io/changes: |
11-
- kind: changed
12-
description: Added support for Google Application Default Credentials (ADC). The 'sophora-image-ai-gcp-credentials' secret (name was hard-coded) is no longer required, but a secret containing the credentials can still be used. See values.yaml for details.
11+
- kind: added
12+
description: Enabled the use of a service account.

charts/sophora-image-ai/templates/_helpers.tpl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,14 @@ Usage:
6262
{{- tpl (.value | toYaml) .context }}
6363
{{- end }}
6464
{{- end -}}
65+
66+
{{/*
67+
Create the name of the service account to use
68+
*/}}
69+
{{- define "sophora-image-ai.serviceAccountName" -}}
70+
{{- if .Values.serviceAccount.create }}
71+
{{- default (include "sophora-image-ai.fullname" .) .Values.serviceAccount.name }}
72+
{{- else }}
73+
{{- default "default" .Values.serviceAccount.name }}
74+
{{- end }}
75+
{{- end }}

charts/sophora-image-ai/templates/deployment.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ spec:
2222
imagePullSecrets:
2323
{{- toYaml . | nindent 8 }}
2424
{{- end }}
25+
serviceAccountName: {{ include "sophora-image-ai.serviceAccountName" . }}
2526
containers:
2627
- name: image-ai
2728
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{{- if .Values.serviceAccount.create -}}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: {{ include "sophora-image-ai.serviceAccountName" . }}
6+
labels:
7+
{{- include "sophora-image-ai.labels" . | nindent 4 }}
8+
{{- with .Values.serviceAccount.annotations }}
9+
annotations:
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
13+
{{- end }}

charts/sophora-image-ai/test-values.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ ingress:
4343
hosts:
4444
tls: []
4545

46+
serviceAccount:
47+
create: true
48+
automount: true
49+
annotations:
50+
foo: bar
51+
4652
extraVolumes:
4753
- name: gcp-credentials
4854
secret:

charts/sophora-image-ai/values.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,14 @@ extraVolumes: []
7777
extraVolumeMounts: []
7878

7979
podAnnotations: {}
80+
81+
serviceAccount:
82+
# Specifies whether a service account should be created
83+
create: false
84+
# Automatically mount a ServiceAccount's API credentials?
85+
automount: true
86+
# Annotations to add to the service account
87+
annotations: {}
88+
# The name of the service account to use.
89+
# If not set and create is true, a name is generated using the fullname template
90+
name: ""

0 commit comments

Comments
 (0)