Skip to content

Commit 2e962f5

Browse files
authored
Create trackboard chart (#54)
* Initiate trackboard chart * Update chart * Add comment * Update charts
1 parent ca760cf commit 2e962f5

19 files changed

Lines changed: 554 additions & 7 deletions

.kube-linter.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- run-as-non-root
2121
- sorted-keys
2222
- privileged-ports
23+
- no-rolling-update-strategy
2324
ignorePaths:
2425
- charts/**/charts/**
2526
# disable for now (too many issues for something to rework from the container image)

charts/drupal/CONTRIBUTING.md

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,59 @@
55
Create a `values.mine.yaml` file:
66

77
```yaml
8+
image: drupal
9+
tag: 8.9.20
10+
811
ingress:
912
enabled: true
1013
className: "traefik"
1114
annotations:
1215
cert-manager.io/cluster-issuer: "letsencrypt-prod"
1316
tls:
1417
enabled: true
18+
19+
persistence:
20+
enabled: true
21+
initImage: ghcr.io/devpro/drupal:8.5.0-postinstall
22+
dbType: sqlite
1523
```
1624
1725
Install the chart:
1826
1927
```bash
20-
helm upgrade --install drupal . -f values.yaml -f values.mine.yaml --namespace drupal --create-namespace \
21-
--set ingress.domain="drupal.console.$SANDBOX_ID.instruqt.io"
28+
helm upgrade --install drupal . -f values.yaml -f values.mine.yaml \
29+
--set ingress.domain="drupal.server.$SANDBOX_ID.instruqt.io" \
30+
--namespace drupal --create-namespace
2231
```
2332

2433
Wait for all pods to be ready:
2534

2635
```bash
27-
kubectl get pod,rs,deploy,svc,ingress,certificate -n drupal
36+
kubectl get pod,rs,deploy,svc,ingress,certificate,pvc,pv -n drupal
37+
```
38+
39+
Check init container logs:
40+
41+
```bash
42+
kubectl logs -n drupal -l app=drupal -c init-sites
2843
```
2944

3045
Open the web application in a browser:
3146

3247
```bash
33-
echo https://drupal.console.$SANDBOX_ID.instruqt.io
48+
echo https://drupal.server.$SANDBOX_ID.instruqt.io
49+
```
50+
51+
Cleanup:
52+
53+
```bash
54+
helm uninstall drupal -n drupal
55+
kubectl get pv --watch
56+
kubectl delete namespace drupal
57+
kubectl get pv | grep drupal
3458
```
59+
60+
<!--
61+
on the server if local-path storage class is used
62+
ls /var/lib/rancher/k3s/storage/
63+
!-->

charts/drupal/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
name: drupal
33
description: Drupal Web Application - for container security workshops
44
type: application
5-
version: 1.0.0
6-
appVersion: "1.0.0"
5+
version: 1.0.1
6+
appVersion: "8.5.0"
77
keywords:
88
- security
99
- vulnerable

charts/drupal/templates/deployment.yaml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
kind: Deployment
33
metadata:
44
name: drupal
5+
labels:
6+
app: drupal
57
spec:
68
replicas: {{ .Values.replicaCount }}
79
strategy:
8-
type: RollingUpdate
10+
type: {{ if eq .Values.persistence.dbType "sqlite" }}Recreate{{ else }}RollingUpdate{{ end }}
911
selector:
1012
matchLabels:
1113
app: drupal
@@ -14,6 +16,27 @@ spec:
1416
labels:
1517
app: drupal
1618
spec:
19+
{{- if and .Values.persistence.enabled .Values.persistence.initImage }}
20+
initContainers:
21+
- name: init-sites
22+
image: {{ .Values.persistence.initImage }}
23+
imagePullPolicy: IfNotPresent
24+
command:
25+
- sh
26+
- -c
27+
- |
28+
# only copy if the PVC is empty (first boot)
29+
if [ -z "$(ls -A /mnt/sites)" ]; then
30+
echo "PVC is empty — seeding from image..."
31+
cp -a /var/www/html/sites/. /mnt/sites/
32+
echo "Done."
33+
else
34+
echo "PVC already has data — skipping copy."
35+
fi
36+
volumeMounts:
37+
- name: sites
38+
mountPath: /mnt/sites
39+
{{- end }}
1740
containers:
1841
- name: drupal
1942
image: {{ .Values.image }}:{{ .Values.tag }}
@@ -28,3 +51,15 @@ spec:
2851
port: 80
2952
initialDelaySeconds: 10
3053
periodSeconds: 10
54+
{{- if .Values.persistence.enabled }}
55+
volumeMounts:
56+
- name: sites
57+
mountPath: /var/www/html/sites
58+
{{- end }}
59+
{{- if .Values.persistence.enabled }}
60+
volumes:
61+
- name: sites
62+
persistentVolumeClaim:
63+
claimName: drupal
64+
{{- end }}
65+
restartPolicy: Always

charts/drupal/templates/ingress.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ apiVersion: networking.k8s.io/v1
33
kind: Ingress
44
metadata:
55
name: drupal
6+
labels:
7+
app: drupal
68
{{- with .Values.ingress.annotations }}
79
annotations:
810
{{- toYaml . | nindent 4 }}

charts/drupal/templates/pvc.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{{- if .Values.persistence.enabled }}
2+
apiVersion: v1
3+
kind: PersistentVolumeClaim
4+
metadata:
5+
name: drupal
6+
labels:
7+
app: drupal
8+
spec:
9+
accessModes:
10+
- ReadWriteOnce
11+
{{- if .Values.persistence.storageClass }}
12+
storageClassName: {{ .Values.persistence.storageClass | quote }}
13+
{{- end }}
14+
resources:
15+
requests:
16+
storage: {{ .Values.persistence.size | quote }}
17+
{{- end }}

charts/drupal/values.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
replicaCount: 1
22
image: vulhub/drupal
33
tag: 8.5.0
4+
45
ingress:
56
enabled: false
67
className: "" # traefik
@@ -9,3 +10,10 @@ ingress:
910
# cert-manager.io/cluster-issuer: letsencrypt-prod
1011
tls:
1112
enabled: false
13+
14+
persistence:
15+
enabled: false
16+
storageClass: ""
17+
size: 500Mi
18+
initImage: ""
19+
dbType: ""

charts/trackboard/CONTRIBUTING.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Contribution guide
2+
3+
## Validate on a test cluster
4+
5+
Create the chart configuration file:
6+
7+
```bash
8+
# example with Traefik ingress controller, cert-manager and Let's Encrypt
9+
cat > values.mine.yaml << 'EOF'
10+
ingress:
11+
enabled: true
12+
className: "traefik"
13+
annotations:
14+
cert-manager.io/cluster-issuer: "letsencrypt-prod"
15+
tls:
16+
enabled: true
17+
EOF
18+
```
19+
20+
<!--
21+
helm template trackboard . -f values.yaml -f values.mine.yaml \
22+
--set ingress.domain=trackboard.server.$SANDBOX_ID.instruqt.io \
23+
--set admin.password=mysecretpassword \
24+
--namespace trackboard > temp.yaml
25+
-->
26+
27+
Install the chart:
28+
29+
```bash
30+
helm upgrade --install trackboard . -f values.yaml -f values.mine.yaml \
31+
--set ingress.domain=trackboard.server.$SANDBOX_ID.instruqt.io \
32+
--set admin.password=mysecretpassword \
33+
--namespace trackboard --create-namespace
34+
```
35+
36+
Wait for all pods to be ready:
37+
38+
```bash
39+
kubectl get all -n trackboard
40+
```
41+
42+
Open the web application in a browser.
43+
44+
```bash
45+
echo "https://trackboard.server.${SANDBOX_ID}.instruqt.io"
46+
```

charts/trackboard/Chart.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: v2
2+
name: trackboard
3+
description: Trackboard web application
4+
type: application
5+
version: 0.1.0
6+
appVersion: "0.1.0"
7+
keywords:
8+
- event
9+
- ctf
10+
- dashboard
11+
- live
12+
maintainers:
13+
- name: devpro
14+
email: bertrand@devpro.fr

charts/trackboard/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Trackboard Helm Chart
2+
3+
Helm chart for [Trackboard Web Application](https://github.com/devpro/container-images/tree/main/src/trackboard) — designed for container security workshops.
4+
5+
## Quick Start
6+
7+
Add the chart repository:
8+
9+
```bash
10+
helm repo add devpro https://devpro.github.io/helm-charts
11+
helm repo update
12+
```
13+
14+
Create the `values.yaml` file to override [default values](values.yaml).
15+
16+
Install the chart:
17+
18+
```bash
19+
helm upgrade --install trackboard devpro/trackboard -f values.yaml --namespace trackboard --create-namespace
20+
```
21+
22+
## Uninstall
23+
24+
```bash
25+
helm uninstall trackboard -n trackboard
26+
kubectl delete namespace trackboard
27+
```
28+
29+
## Going further
30+
31+
Check the [contribution guide](CONTRIBUTING.md).
32+
33+
---
34+
> ⚠️ **FOR WORKSHOP USE ONLY** — intentionally vulnerable, never expose to the internet.

0 commit comments

Comments
 (0)