Skip to content

Commit 85fa195

Browse files
kamiiieljgiovaresco
authored andcommitted
feat: add separate SA for each component
1 parent b2884e5 commit 85fa195

File tree

8 files changed

+69
-10
lines changed

8 files changed

+69
-10
lines changed

helm/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33

44
This file documents all notable changes to [Gravitee.io API Management 3.x](https://github.com/gravitee-io/helm-charts/tree/master/apim/3.x) Helm Chart. The release numbering uses [semantic versioning](http://semver.org).
55

6+
### 3.20.12
7+
8+
- Add support for managed Service Account for each product
9+
10+
### 3.19.17
11+
12+
- Add support for managed Service Account for each product
13+
14+
### 3.18.28
15+
16+
- Add support for managed Service Account for each product
17+
618
### 3.20.11
719

820
- Change APIM charts versioning

helm/Chart.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
apiVersion: v1
22
name: apim
3-
# When the version: 3.20.11
43
# Also update CHANGELOG.md
5-
version: 3.20.11
4+
version: 3.20.12
65
appVersion: 3.20.x-latest
76
description: Official Gravitee.io Helm chart for API Management
87
home: https://gravitee.io
@@ -20,5 +19,4 @@ annotations:
2019
# List of changes for the release in artifacthub.io
2120
# https://artifacthub.io/packages/helm/graviteeio/apim?modal=changelog
2221
artifacthub.io/changes: |
23-
- Change the version 3.20.11
24-
- Remove duplicate annotation in ui deployment
22+
- Add support for managed Service Account for each product

helm/templates/api/api-deployment.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,11 @@ spec:
8686
{{- end }}
8787
{{- end }}
8888
spec:
89-
{{- if $serviceAccount }}
89+
{{- if not (eq .Values.api.deployment.serviceAccount "") }}
90+
serviceAccountName: {{ .Values.api.deployment.serviceAccount }}
91+
{{- else if $serviceAccount }}
9092
serviceAccountName: {{ $serviceAccount }}
91-
{{ end }}
93+
{{- end }}
9294
affinity: {{ toYaml .Values.api.deployment.affinity | nindent 8 }}
9395
nodeSelector: {{ toYaml .Values.api.deployment.nodeSelector | nindent 8 }}
9496
topologySpreadConstraints: {{ toYaml .Values.api.deployment.topologySpreadConstraints | nindent 8 }}

helm/templates/api/api-upgrader-job.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,11 @@ spec:
6767
{{- end }}
6868
spec:
6969
restartPolicy: Never
70-
{{- if $serviceAccount }}
70+
{{- if not (eq .Values.api.deployment.serviceAccount "") }}
71+
serviceAccountName: {{ .Values.api.deployment.serviceAccount }}
72+
{{- else if $serviceAccount }}
7173
serviceAccountName: {{ $serviceAccount }}
72-
{{ end }}
74+
{{- end }}
7375
affinity: {{ toYaml .Values.api.deployment.affinity | nindent 8 }}
7476
nodeSelector: {{ toYaml .Values.api.deployment.nodeSelector | nindent 8 }}
7577
topologySpreadConstraints: {{ toYaml .Values.api.deployment.topologySpreadConstraints | nindent 8 }}

helm/templates/gateway/gateway-deployment.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,11 @@ spec:
8383
{{- end }}
8484
{{- end }}
8585
spec:
86-
{{- if $serviceAccount }}
86+
{{- if not (eq .Values.gateway.deployment.serviceAccount "") }}
87+
serviceAccountName: {{ .Values.gateway.deployment.serviceAccount }}
88+
{{- else if $serviceAccount }}
8789
serviceAccountName: {{ $serviceAccount }}
88-
{{ end }}
90+
{{- end }}
8991
affinity: {{ toYaml .Values.gateway.deployment.affinity | nindent 8 }}
9092
nodeSelector: {{ toYaml .Values.gateway.deployment.nodeSelector | nindent 8 }}
9193
topologySpreadConstraints: {{ toYaml .Values.gateway.deployment.topologySpreadConstraints | nindent 8 }}

helm/tests/api/deployment_test.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,24 @@ tests:
148148
path: spec.template.spec.serviceAccountName
149149
value: "test-sa"
150150

151+
- it: Deploy with component specific ServiceAccount
152+
template: api/api-deployment.yaml
153+
set:
154+
apim:
155+
managedServiceAccount: true
156+
serviceAccount: "test-sa"
157+
api:
158+
deployment:
159+
serviceAccount: "apim-api"
160+
asserts:
161+
- hasDocuments:
162+
count: 1
163+
- isKind:
164+
of: Deployment
165+
- equal:
166+
path: spec.template.spec.serviceAccountName
167+
value: "apim-api"
168+
151169
- it: Deploy with long api name
152170
template: api/api-deployment.yaml
153171
set:

helm/tests/gateway/deployment_test.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,24 @@ tests:
174174
path: spec.template.spec.serviceAccountName
175175
value: "test-sa"
176176

177+
- it: Deploy with component specific ServiceAccount
178+
template: gateway/gateway-deployment.yaml
179+
set:
180+
apim:
181+
managedServiceAccount: true
182+
serviceAccount: "test-sa"
183+
gateway:
184+
deployment:
185+
serviceAccount: "apim-gateway"
186+
asserts:
187+
- hasDocuments:
188+
count: 1
189+
- isKind:
190+
of: Deployment
191+
- equal:
192+
path: spec.template.spec.serviceAccountName
193+
value: "apim-gateway"
194+
177195
- it: Deploy with long api name
178196
template: gateway/gateway-deployment.yaml
179197
set:

helm/values.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ apim:
1111
managedServiceAccount: true
1212

1313
# Custom service account override that the pod will use
14+
# if customer provides a dedicated SA for any component, that will have the priority
1415
serviceAccount: ""
1516

1617
roleRules:
@@ -413,6 +414,9 @@ api:
413414
securityContext:
414415
runAsUser: 1001
415416
runAsNonRoot: true
417+
418+
# Dedicated Service account provided for this component
419+
serviceAccount: ""
416420
strategy:
417421
type: RollingUpdate
418422
rollingUpdate:
@@ -729,6 +733,9 @@ gateway:
729733
securityContext:
730734
runAsUser: 1001
731735
runAsNonRoot: true
736+
737+
# Dedicated Service account provided for this component
738+
serviceAccount: ""
732739
strategy:
733740
type: RollingUpdate
734741
rollingUpdate:

0 commit comments

Comments
 (0)