Skip to content

Commit d81dc92

Browse files
authored
Merge pull request #270 from osamamagdy/complete-helm-cleaning
Complete helm cleaning
2 parents ede4466 + 8ce46e2 commit d81dc92

File tree

9 files changed

+57
-35
lines changed

9 files changed

+57
-35
lines changed

helm/wrongsecrets-ctf-party/templates/cleanup/cron-job.yaml

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,25 @@ spec:
2020
helm.sh/chart: {{ include "wrongsecrets-ctf-party.chart" . }}
2121
spec:
2222
serviceAccountName: 'wrongsecrets-cleaner'
23+
{{- if .Values.wrongsecretsCleanup.podSecurityContext.enabled }}
2324
securityContext:
24-
runAsUser: 1000
25-
runAsGroup: 3000
26-
fsGroup: 2000
25+
{{- omit .Values.wrongsecretsCleanup.podSecurityContext "enabled" | toYaml | nindent 12 }}
26+
{{- end }}
2727
containers:
2828
- image: '{{ .Values.wrongsecretsCleanup.repository }}:{{ .Values.wrongsecretsCleanup.tag | default (printf "v%s" .Chart.Version) }}'
2929
imagePullPolicy: {{ .Values.imagePullPolicy | quote }}
30+
{{- if .Values.wrongsecretsCleanup.containerSecurityContext.enabled }}
3031
securityContext:
31-
allowPrivilegeEscalation: false
32-
readOnlyRootFilesystem: true
33-
runAsNonRoot: true
34-
capabilities:
35-
drop:
36-
- ALL
37-
seccompProfile:
38-
type: RuntimeDefault
32+
{{- omit .Values.wrongsecretsCleanup.containerSecurityContext "enabled" | toYaml | nindent 16 }}
33+
{{- end }}
3934
name: 'cleanup-job'
4035
env:
36+
{{- range $k, $v := .Values.wrongsecretsCleanup.env}}
37+
- name: {{ $k }}
38+
value: {{ $v | quote }}
39+
{{- end }}
4140
- name: NAMESPACE
4241
value: {{ .Release.Namespace | quote }}
43-
- name: MAX_INACTIVE_DURATION
44-
value: {{ .Values.wrongsecretsCleanup.gracePeriod }}
45-
- name: SHOULD_DELETE
46-
value: {{ .Values.wrongsecretsCleanup.SHOULD_DELETE | quote }}
4742
restartPolicy: Never
4843
{{- with .Values.nodeSelector }}
4944
nodeSelector:

helm/wrongsecrets-ctf-party/templates/wrongsecrets-balancer/config-map.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ metadata:
77
data:
88
config.json: |
99
{
10-
"port": 3000,
10+
"port": {{ .Values.balancer.containerPort }},
1111
"namespace": {{ .Release.Namespace | quote }},
1212
"deploymentContext": {{ .Release.Name | quote }},
1313
"maxJuiceShopInstances": {{ .Values.wrongsecrets.maxInstances}},
@@ -17,7 +17,7 @@ data:
1717
"secure": {{ .Values.balancer.cookie.secure }}
1818
},
1919
"admin": {
20-
"username": "admin"
20+
"username": {{ .Values.balancer.basicAuth.username | quote }}
2121
},
2222
{{- if .Values.balancer.metrics.enabled }}
2323
"metrics": {

helm/wrongsecrets-ctf-party/templates/wrongsecrets-balancer/deployment.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ spec:
2020
{{- include "wrongsecrets-ctf-party.selectorLabels" . | nindent 8 }}
2121
spec:
2222
serviceAccountName: wrongsecrets-balancer
23-
{{- with .Values.balancer.podSecurityContext }}
23+
{{- if .Values.balancer.podSecurityContext.enabled }}
2424
securityContext:
25-
{{- omit . "enabled" | toYaml | nindent 8 }}
25+
{{- omit .Values.balancer.podSecurityContext "enabled" | toYaml | nindent 8 }}
2626
{{- end }}
2727
containers:
2828
- name: {{ .Chart.Name }}
@@ -70,9 +70,9 @@ spec:
7070
name: wrongsecrets-balancer-secret
7171
key: metricsBasicAuthPassword
7272
{{- end }}
73-
{{- with .Values.balancer.containerSecurityContext }}
73+
{{- if .Values.balancer.containerSecurityContext.enabled }}
7474
securityContext:
75-
{{- omit . "enabled" | toYaml | nindent 12 }}
75+
{{- omit .Values.balancer.containerSecurityContext "enabled" | toYaml | nindent 12 }}
7676
{{- end }}
7777
{{- if .Values.balancer.volumeMounts }}
7878
volumeMounts:

helm/wrongsecrets-ctf-party/templates/wrongsecrets-balancer/secret.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ data:
1313
{{- else }}
1414
cookieParserSecret: {{ randAlphaNum 24 | b64enc | quote }}
1515
{{- end }}
16-
{{- if .Values.balancer.adminPassword }}
17-
adminPassword: {{ .Values.balancer.adminPassword | b64enc | quote }}
16+
{{- if .Values.balancer.basicAuth.adminPassword }}
17+
adminPassword: {{ .Values.balancer.basicAuth.adminPassword | b64enc | quote }}
1818
{{- else }}
1919
adminPassword: {{ randAlphaNum 8 | upper | b64enc | quote }}
2020
{{- end }}

helm/wrongsecrets-ctf-party/templates/wrongsecrets-balancer/service.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ spec:
3030
{{- include "wrongsecrets-ctf-party.selectorLabels" . | nindent 4 }}
3131
ports:
3232
- port: {{ .Values.service.port }}
33-
name: web
33+
name: {{ .Values.service.portName }}

helm/wrongsecrets-ctf-party/templates/wrongsecrets-balancer/servicemonitor.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ spec:
88
matchLabels:
99
{{- include "wrongsecrets-ctf-party.labels" . | nindent 6 }}
1010
endpoints:
11-
- port: web
12-
path: '/balancer/metrics'
11+
- port: {{ .Values.service.portName }}
12+
path: {{ .Values.balancer.metrics.serviceMonitor.path | quote }}
1313
basicAuth:
1414
username:
1515
name: wrongsecrets-balancer-secret

helm/wrongsecrets-ctf-party/templates/wrongsecrets/servicemonitor.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
apiVersion: monitoring.coreos.com/v1
33
kind: ServiceMonitor
44
metadata:
5-
name: juice-shops
5+
name: wrongsecrets-metrics
66
spec:
77
targetLabels:
88
- team
@@ -11,5 +11,5 @@ spec:
1111
app: wrongsecrets
1212
deployment-context: {{ .Release.Name | quote }}
1313
endpoints:
14-
- targetPort: 3000
14+
- targetPort: {{ .Values.balancer.metrics.serviceMonitor.targetPort }}
1515
{{- end }}

helm/wrongsecrets-ctf-party/values.yaml

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ ingress:
2727
service:
2828
type: ClusterIP
2929
port: 3000
30+
portName: web
3031

3132
balancer:
3233
cookie:
@@ -55,6 +56,12 @@ balancer:
5556
loadBalancerSourceRanges: null
5657
# -- IP address to assign to load balancer (if supported)
5758
externalIPs: null
59+
# -- Credentials used in wrongsecrets-balancer-secret to authenticate with the wrongsecrets-api
60+
basicAuth:
61+
# -- Username for the basic auth credentials
62+
username: admin
63+
# -- Password for the basic auth credentials (will be generated if not set)
64+
# adminPassword: admin
5865
# -- Probes settings for the balancer pods
5966
# -- livenessProbe: Checks if the balancer pod is still alive
6067
livenessProbe:
@@ -99,8 +106,12 @@ balancer:
99106
# -- if true, creates a Grafana Dashboard Config Map. (also requires metrics.enabled to be true). These will automatically be imported by Grafana when using the Grafana helm chart, see: https://github.com/helm/charts/tree/main/stable/grafana#sidecar-for-dashboards
100107
enabled: false
101108
serviceMonitor:
102-
# -- If true, creates a Prometheus Operator ServiceMonitor (also requires metrics.enabled to be true). This will also deploy a servicemonitor which monitors metrics from the Juice Shop instances
109+
# -- If true, creates a Prometheus Operator ServiceMonitor (also requires metrics.enabled to be true). This will also deploy a servicemonitor which monitors metrics from the Wrongsecrets instances
103110
enabled: false
111+
# -- Target port for the ServiceMonitor to scrape
112+
targetPort: 3000
113+
# -- Path to scrape for metrics
114+
path: '/balancer/metrics'
104115
basicAuth:
105116
username: prometheus-scraper
106117
# -- Should be changed when metrics are enabled.
@@ -200,9 +211,9 @@ wrongsecrets:
200211

201212
#the virtual desktop for the deploymebt
202213
virtualdesktop:
203-
# -- Specifies how many Wrongsecrets instances MultiJuicer should start at max. Set to -1 to remove the max Juice Shop instance cap
214+
# -- Specifies how many Wrongsecrets instances balancer should start at max. Set to -1 to remove the max Wrongsecrets instance cap
204215
maxInstances: 500
205-
# -- Juice Shop Image to use
216+
# -- Wrongsecrets Image to use
206217
image: jeroenwillemsen/wrongsecrets-desktop-k8s
207218
tag: 1.6.6
208219
repository: commjoenie/wrongSecrets
@@ -267,14 +278,13 @@ wrongsecretsCleanup:
267278
repository: jeroenwillemsen/wrongsecrets-ctf-cleaner
268279
tag: 0.4
269280
enabled: true
270-
# -- Specifies when Juice Shop instances will be deleted when unused for that period.
271-
gracePeriod: 2d
272-
# -- Specifies if the clean up job should delete the outdated namespaces or just report them. Set to false to only report outdated namespaces.
273-
SHOULD_DELETE: false
274281
# -- Cron in which the clean up job is run. Defaults to once in a quarter. Change this if your grace period if shorter than 15 minutes. See "https://crontab.guru/#0,15,30,45_*_*_*_*" for more details.
275282
cron: "0,15,30,45 * * * *"
276283
successfulJobsHistoryLimit: 1
277284
failedJobsHistoryLimit: 1
285+
env:
286+
SHOULD_DELETE: false # -- Specifies if the clean up job should delete the outdated namespaces or just report them. Set to false to only report outdated namespaces.
287+
MAX_INACTIVE_DURATION: 2d # -- Specifies when Wrongsecrets instances will be deleted when unused for that period.
278288
resources:
279289
requests:
280290
memory: 256Mi
@@ -284,3 +294,20 @@ wrongsecretsCleanup:
284294
affinity: {}
285295
# -- Optional Configure kubernetes toleration for the wrongsecretsCleanup Job (see: https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/)
286296
tolerations: []
297+
podSecurityContext:
298+
# -- If true, sets the securityContext on the created pods. This is required for the podSecurityPolicy to work
299+
enabled: true
300+
runAsUser: 1000
301+
runAsGroup: 3000
302+
fsGroup: 2000
303+
containerSecurityContext:
304+
# -- If true, sets the securityContext on the created containers. This is required for the podSecurityPolicy to work
305+
enabled: true
306+
allowPrivilegeEscalation: false
307+
readOnlyRootFilesystem: true
308+
runAsNonRoot: true
309+
capabilities:
310+
drop:
311+
- ALL
312+
seccompProfile:
313+
type: RuntimeDefault

0 commit comments

Comments
 (0)