Skip to content
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

Added securityContext option to each container's template #4

Merged
merged 3 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion templates/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ spec:
prometheus.io/scrape: 'true'
prometheus.io/port: '{{ .Values.prometheus.port | default 9542 }}'
{{- end }}
labels:
labels:
{{- include "keycloak.labels" $ | nindent 8 }}
spec:
{{- include "image_pull_secrets" $ | indent 6 }}
Expand All @@ -42,10 +42,12 @@ spec:
topologyKey: {{ include "platformSpecificValue" (list $ . ".Values.topologyKey") | default "kubernetes.io/hostname" }}
serviceAccount: ""
serviceAccountName: ""
securityContext: {{ include "platformSpecificValue" (list $ . ".Values.podSecurityContext") | default "{}" | nindent 8 }}
containers:
- name: haproxy
image: {{ .Values.haproxy.image }}
imagePullPolicy: {{ .Values.haproxy.imagePullPolicy | default .Values.global.imagePullPolicy }}
securityContext: {{ include "platformSpecificValue" (list $ . ".Values.haproxy.containerSecurityContext") | default "{}" | nindent 10 }}
ports:
- { containerPort: 9090, protocol: TCP, name: http }
{{- if eq .Values.prometheus.enabled true }}
Expand All @@ -58,6 +60,7 @@ spec:
- name: keycloak
image: {{ .Values.keycloak.image }}
imagePullPolicy: {{ .Values.imagePullPolicy | default .Values.global.imagePullPolicy }}
securityContext: {{ include "platformSpecificValue" (list $ . ".Values.containerSecurityContext") | default "{}" | nindent 10 }}
{{- if .Values.truststore }}
args: ['start --optimized --import-realm --spi-truststore-file-file=/truststore/truststore.jks --spi-truststore-file-password={{ .Values.truststorePassword }} --spi-truststore-file-hostname-verification-policy={{ .Values.hostnameVerificationPolicy }}']
{{- else }}
Expand Down Expand Up @@ -95,6 +98,7 @@ spec:
- name: "check-database"
image: {{ .Values.postgresql.image }}
imagePullPolicy: {{ .Values.postgresql.imagePullPolicy | default .Values.global.imagePullPolicy }}
securityContext: {{ include "platformSpecificValue" (list $ . ".Values.postgresql.containerSecurityContext") | default "{}" | nindent 10 }}
command: ['/bin/bash']
args: ['-c', 'until pg_isready -U {{ .Values.global.database.username }}; do echo waiting for database; sleep 2; done;']
env:
Expand Down
10 changes: 8 additions & 2 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ templateChangeTriggers: []
#fsGroup: 999
#supplementalGroups: 999

#containerSecurityContext: {}
containerSecurityContext: {}
# readOnlyRootFilesystem: true
# runAsNonRoot: true

#topologyKey: kubernetes.io/hostname


Expand Down Expand Up @@ -219,6 +222,9 @@ keycloak:

haproxy:
image: haproxy:2.4.0-alpine

containerSecurityContext: {}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, remove the empty lines

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can remove them sure, just left them there for readability, as security context is not related to either the image nor the resources.

resources:
limits:
memory: 1Gi
Expand All @@ -228,7 +234,7 @@ haproxy:
cpu: 250m

postgresql:
#containerSecurityContext: {}
containerSecurityContext: {}

maxPreparedTransactions: "100"

Expand Down