Skip to content

Commit

Permalink
Merge pull request fluxcd-community#154 from danielvoros-form3/dvoros…
Browse files Browse the repository at this point in the history
…-pod-security-context

feat: allow setting PodSecurityContext for controllers
  • Loading branch information
stefanprodan authored Jan 23, 2023
2 parents a2af157 + 2590da6 commit 50c9e78
Show file tree
Hide file tree
Showing 23 changed files with 129 additions and 15 deletions.
4 changes: 2 additions & 2 deletions charts/flux2/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
annotations:
artifacthub.io/changes: |
- "[Added]: Allow setting install-job securityContext and volumes"
- "[Added]: Allow setting podSecurityContext for controllers"
apiVersion: v2
appVersion: 0.37.0
description: A Helm chart for flux2
name: flux2
sources:
- https://github.com/fluxcd-community/helm-charts
type: application
version: 2.4.1
version: 2.5.0
2 changes: 1 addition & 1 deletion charts/flux2/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# flux2

![Version: 2.4.1](https://img.shields.io/badge/Version-2.4.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.37.0](https://img.shields.io/badge/AppVersion-0.37.0-informational?style=flat-square)
![Version: 2.5.0](https://img.shields.io/badge/Version-2.5.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.37.0](https://img.shields.io/badge/AppVersion-0.37.0-informational?style=flat-square)

A Helm chart for flux2

Expand Down
3 changes: 3 additions & 0 deletions charts/flux2/templates/helm-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ spec:
{{- if .Values.helmController.priorityClassName }}
priorityClassName: {{ .Values.helmController.priorityClassName | quote }}
{{- end }}
{{- if .Values.helmController.podSecurityContext }}
securityContext: {{ toYaml .Values.helmController.podSecurityContext | nindent 8 }}
{{- end }}
serviceAccountName: helm-controller
{{- if .Values.imagePullSecrets }}
imagePullSecrets: {{ toYaml .Values.imagePullSecrets | nindent 6 }}
Expand Down
4 changes: 4 additions & 0 deletions charts/flux2/templates/image-automation-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,12 @@ spec:
{{- if .Values.imageAutomationController.priorityClassName }}
priorityClassName: {{ .Values.imageAutomationController.priorityClassName | quote }}
{{- end }}
{{- if .Values.imageAutomationController.podSecurityContext }}
securityContext: {{ toYaml .Values.imageAutomationController.podSecurityContext | nindent 8 }}
{{- else }}
securityContext:
fsGroup: 1337
{{- end}}
serviceAccountName: image-automation-controller
{{- if .Values.imagePullSecrets }}
imagePullSecrets: {{ toYaml .Values.imagePullSecrets | nindent 6 }}
Expand Down
4 changes: 4 additions & 0 deletions charts/flux2/templates/image-reflector-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,12 @@ spec:
{{- if .Values.imageReflectionController.priorityClassName }}
priorityClassName: {{ .Values.imageReflectionController.priorityClassName | quote }}
{{- end }}
{{- if .Values.imageReflectionController.podSecurityContext }}
securityContext: {{ toYaml .Values.imageReflectionController.podSecurityContext | nindent 8 }}
{{- else }}
securityContext:
fsGroup: 1337
{{- end}}
serviceAccountName: image-reflector-controller
{{- if .Values.imagePullSecrets }}
imagePullSecrets: {{ toYaml .Values.imagePullSecrets | nindent 6 }}
Expand Down
4 changes: 4 additions & 0 deletions charts/flux2/templates/kustomize-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,12 @@ spec:
subPath: {{ .subPath }}
readOnly: {{ .readOnly }}
{{- end }}
{{- if .Values.kustomizeController.podSecurityContext }}
securityContext: {{ toYaml .Values.kustomizeController.podSecurityContext | nindent 8 }}
{{- else }}
securityContext:
fsGroup: 1337
{{- end}}
serviceAccountName: kustomize-controller
{{- if .Values.imagePullSecrets }}
imagePullSecrets: {{ toYaml .Values.imagePullSecrets | nindent 6 }}
Expand Down
3 changes: 3 additions & 0 deletions charts/flux2/templates/notification-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ spec:
{{- if .Values.notificationController.priorityClassName }}
priorityClassName: {{ .Values.notificationController.priorityClassName | quote }}
{{- end }}
{{- if .Values.notificationController.podSecurityContext }}
securityContext: {{ toYaml .Values.notificationController.podSecurityContext | nindent 8 }}
{{- end }}
serviceAccountName: notification-controller
{{- if .Values.imagePullSecrets }}
imagePullSecrets: {{ toYaml .Values.imagePullSecrets | nindent 6 }}
Expand Down
4 changes: 4 additions & 0 deletions charts/flux2/templates/source-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,12 @@ spec:
{{- if .Values.sourceController.priorityClassName }}
priorityClassName: {{ .Values.sourceController.priorityClassName | quote }}
{{- end }}
{{- if .Values.sourceController.podSecurityContext }}
securityContext: {{ toYaml .Values.sourceController.podSecurityContext | nindent 8 }}
{{- else }}
securityContext:
fsGroup: 1337
{{- end}}
serviceAccountName: source-controller
{{- if .Values.imagePullSecrets }}
imagePullSecrets: {{ toYaml .Values.imagePullSecrets | nindent 6 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ should match snapshot of default values:
app.kubernetes.io/part-of: flux
app.kubernetes.io/version: 0.37.0
control-plane: controller
helm.sh/chart: flux2-2.4.1
helm.sh/chart: flux2-2.5.0
name: helm-controller
spec:
replicas: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ should match snapshot of default values:
app.kubernetes.io/part-of: flux
app.kubernetes.io/version: 0.37.0
control-plane: controller
helm.sh/chart: flux2-2.4.1
helm.sh/chart: flux2-2.5.0
name: image-automation-controller
spec:
replicas: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ should match snapshot of default values:
app.kubernetes.io/part-of: flux
app.kubernetes.io/version: 0.37.0
control-plane: controller
helm.sh/chart: flux2-2.4.1
helm.sh/chart: flux2-2.5.0
name: image-reflector-controller
spec:
replicas: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ should match snapshot of default values:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/part-of: flux
app.kubernetes.io/version: 0.37.0
helm.sh/chart: flux2-2.4.1
helm.sh/chart: flux2-2.5.0
name: test1
namespace: NAMESPACE
type: Opaque
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ should match snapshot of default values:
app.kubernetes.io/part-of: flux
app.kubernetes.io/version: 0.37.0
control-plane: controller
helm.sh/chart: flux2-2.4.1
helm.sh/chart: flux2-2.5.0
name: kustomize-controller
spec:
replicas: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ should match snapshot of default values:
app.kubernetes.io/part-of: flux
app.kubernetes.io/version: 0.37.0
control-plane: controller
helm.sh/chart: flux2-2.4.1
helm.sh/chart: flux2-2.5.0
name: notification-controller
spec:
replicas: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ should match snapshot of default values:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/part-of: flux
app.kubernetes.io/version: 0.37.0
helm.sh/chart: flux2-2.4.1
helm.sh/chart: flux2-2.5.0
name: RELEASE-NAME-flux-check
spec:
backoffLimit: 1
Expand All @@ -23,7 +23,7 @@ should match snapshot of default values:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/part-of: flux
app.kubernetes.io/version: 0.37.0
helm.sh/chart: flux2-2.4.1
helm.sh/chart: flux2-2.5.0
name: RELEASE-NAME
spec:
automountServiceAccountToken: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ should match snapshot of default values:
app.kubernetes.io/part-of: flux
app.kubernetes.io/version: 0.37.0
control-plane: controller
helm.sh/chart: flux2-2.4.1
helm.sh/chart: flux2-2.5.0
name: source-controller
spec:
replicas: 1
Expand Down
15 changes: 15 additions & 0 deletions charts/flux2/tests/helm-controller_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,18 @@ tests:
- contains:
path: spec.template.spec.containers[0].args
content: --events-addr=http://notification-controller.$(RUNTIME_NAMESPACE).svc.custom.domain.
- it: should override securityContext
set:
helmController.podSecurityContext:
runAsUser: 2000
helmController.securityContext:
runAsUser: 3000
asserts:
- equal:
path: spec.template.spec.securityContext
value:
runAsUser: 2000
- equal:
path: spec.template.spec.containers[0].securityContext
value:
runAsUser: 3000
15 changes: 15 additions & 0 deletions charts/flux2/tests/image-automation-controller_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,18 @@ tests:
- contains:
path: spec.template.spec.containers[0].args
content: --events-addr=http://notification-controller.$(RUNTIME_NAMESPACE).svc.custom.domain.
- it: should override securityContext
set:
imageAutomationController.podSecurityContext:
runAsUser: 2000
imageAutomationController.securityContext:
runAsUser: 3000
asserts:
- equal:
path: spec.template.spec.securityContext
value:
runAsUser: 2000
- equal:
path: spec.template.spec.containers[0].securityContext
value:
runAsUser: 3000
15 changes: 15 additions & 0 deletions charts/flux2/tests/image-reflector-controller_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,18 @@ tests:
- contains:
path: spec.template.spec.containers[0].args
content: --events-addr=http://notification-controller.$(RUNTIME_NAMESPACE).svc.custom.domain.
- it: should override securityContext
set:
imageReflectionController.podSecurityContext:
runAsUser: 2000
imageReflectionController.securityContext:
runAsUser: 3000
asserts:
- equal:
path: spec.template.spec.securityContext
value:
runAsUser: 2000
- equal:
path: spec.template.spec.containers[0].securityContext
value:
runAsUser: 3000
15 changes: 15 additions & 0 deletions charts/flux2/tests/kustomize-controller_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,18 @@ tests:
- contains:
path: spec.template.spec.containers[0].args
content: --events-addr=http://notification-controller.$(RUNTIME_NAMESPACE).svc.custom.domain.
- it: should override securityContext
set:
kustomizeController.podSecurityContext:
runAsUser: 2000
kustomizeController.securityContext:
runAsUser: 3000
asserts:
- equal:
path: spec.template.spec.securityContext
value:
runAsUser: 2000
- equal:
path: spec.template.spec.containers[0].securityContext
value:
runAsUser: 3000
15 changes: 15 additions & 0 deletions charts/flux2/tests/notification-controller_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,18 @@ tests:
- equal:
path: spec.template.spec.containers[0].imagePullPolicy
value: IfNotPresent
- it: should override securityContext
set:
notificationController.podSecurityContext:
runAsUser: 2000
notificationController.securityContext:
runAsUser: 3000
asserts:
- equal:
path: spec.template.spec.securityContext
value:
runAsUser: 2000
- equal:
path: spec.template.spec.containers[0].securityContext
value:
runAsUser: 3000
8 changes: 5 additions & 3 deletions charts/flux2/tests/pre-install-job_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,13 @@ tests:
value: 1024Mi
- it: should override securityContext
set:
cli.securityContext: {}
cli.securityContext:
runAsNonRoot: false
asserts:
- equal:
path: spec.template.spec.securityContext
value: null
path: spec.template.spec.containers[0].securityContext
value:
runAsNonRoot: false
- it: should set volumes
set:
cli.volumeMounts:
Expand Down
15 changes: 15 additions & 0 deletions charts/flux2/tests/source-controller_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,18 @@ tests:
- contains:
path: spec.template.spec.containers[0].args
content: --storage-adv-addr=source-controller.$(RUNTIME_NAMESPACE).svc.custom.domain.
- it: should override securityContext
set:
sourceController.podSecurityContext:
runAsUser: 2000
sourceController.securityContext:
runAsUser: 3000
asserts:
- equal:
path: spec.template.spec.securityContext
value:
runAsUser: 2000
- equal:
path: spec.template.spec.containers[0].securityContext
value:
runAsUser: 3000

0 comments on commit 50c9e78

Please sign in to comment.