Skip to content

Commit c7ea029

Browse files
authored
Merge pull request #4 from mariem168/add-securitycontext
SecurityContext to Helm deployment
2 parents 4fe13e6 + 9928df9 commit c7ea029

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

helm/templates/deployment.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,22 @@ spec:
1414
labels:
1515
app: {{ .Release.Name }}
1616
spec:
17+
{{- if .Values.securityContext.enabled }}
18+
# Pod-level security settings
19+
securityContext:
20+
runAsUser: {{ .Values.securityContext.runAsUser }}
21+
runAsGroup: {{ .Values.securityContext.runAsGroup }}
22+
fsGroup: {{ .Values.securityContext.fsGroup }}
23+
{{- end }}
1724
containers:
1825
- name: {{ .Release.Name }}
1926
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
2027
imagePullPolicy: {{ .Values.image.pullPolicy }}
28+
{{- if .Values.securityContext.enabled }}
29+
# Container-level security settings
30+
securityContext:
31+
allowPrivilegeEscalation: {{ .Values.securityContext.allowPrivilegeEscalation }}
32+
{{- end }}
2133
ports:
2234
- containerPort: {{ .Values.service.targetPort }}
2335
env:

helm/values.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ replicaCount: 1
33
image:
44
repository: docker.io/karimzakzouk/graduation-project-devops
55
pullPolicy: IfNotPresent
6-
76
tag: 5ce971613930bb3845550750c0b11cfc28a7d33d
87

98
service:
@@ -13,6 +12,14 @@ service:
1312

1413
namespace: ""
1514

15+
securityContext:
16+
enabled: true
17+
runAsUser: 1000
18+
runAsGroup: 3000
19+
fsGroup: 2000
20+
allowPrivilegeEscalation: false
21+
22+
1623
resources:
1724
requests:
1825
cpu: 100m

0 commit comments

Comments
 (0)