Skip to content

Commit b428496

Browse files
committed
feat: updates helm job to run with hardened security contexts
1 parent 3c86543 commit b428496

5 files changed

Lines changed: 17 additions & 4 deletions

File tree

Dockerfile.ci

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ nix \
2424
develop --command run build binary_out=/tmp/plugin-helm-controller
2525
EOF
2626

27-
FROM gcr.io/distroless/static
27+
FROM gcr.io/distroless/static:nonroot
2828
WORKDIR /home/nonroot
29-
USER nonroot:nonroot
3029
COPY --from=builder --chown=nonroot:nonroot /tmp/plugin-helm-controller ./plugin-helm-controller
3130
ENTRYPOINT ["./plugin-helm-controller"]

IMAGES/helm-job-runner/Dockerfile-nix

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ mkdir -p /tmp/nix-store-closure
1515
cp -R $(nix-store -qR /tmp/output/result) /tmp/nix-store-closure
1616
EOF
1717

18-
FROM gcr.io/distroless/static
18+
FROM gcr.io/distroless/static:nonroot
1919
WORKDIR /home/nonroot
20-
USER nonroot:nonroot
2120
COPY --from=builder /tmp/nix-store-closure /nix/store
2221
COPY --from=builder --chown=nonroot:nonroot /tmp/output/ /app/
2322
ENV PATH=/app/result/bin

INSTALL/k8s/setup.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ spec:
8585
- ALL
8686
securityContext:
8787
runAsNonRoot: true
88+
runAsUser: 65532 # nonroot user from gcr.io/distroless/static:nonroot image
89+
runAsGroup: 65532 # nonroot group from gcr.io/distroless/static:nonroot image
90+
allowPrivilegeEscalation: false
8891
serviceAccountName: "plugin-helm-chart"
8992
terminationGracePeriodSeconds: 10
9093

internal/controller/helm_pipeline/templates/helm-pipeline-install-job-spec.yml.tpl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ template:
66
serviceAccountName: {{.ServiceAccountName | toJson }}
77
tolerations: {{ .PodTolerations | default list | toJson }}
88
nodeSelector: {{ .NodeSelector | default dict | toJson }}
9+
10+
securityContext:
11+
runAsNonRoot: true
12+
runAsUser: 65532 # nonroot user from gcr.io/distroless/static:nonroot image
13+
runAsGroup: 65532 # nonroot group from gcr.io/distroless/static:nonroot image
14+
allowPrivilegeEscalation: false
15+
916
containers:
1017
- name: helm
1118
image: {{.Image}}

internal/controller/helm_pipeline/templates/helm-pipeline-uninstall-job-spec.yml.tpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ template:
66
serviceAccountName: {{.ServiceAccountName | toJson }}
77
tolerations: {{ .PodTolerations | default list | toJson }}
88
nodeSelector: {{ .NodeSelector | default dict | toJson }}
9+
securityContext:
10+
runAsNonRoot: true
11+
runAsUser: 65532 # nonroot user from gcr.io/distroless/static:nonroot image
12+
runAsGroup: 65532 # nonroot group from gcr.io/distroless/static:nonroot image
13+
allowPrivilegeEscalation: false
914
containers:
1015
- name: helm
1116
image: {{.Image}}

0 commit comments

Comments
 (0)