Image v0.8.2: container has runAsNonRoot and image will run as root
Problem
Even though https://github.com/helm/chartmuseum/pull/167 fixes the container has runAsNonRoot and image will run as root error, it doesn't work when PSPs are enabled and it gives the same error.
Here is our PSP:
apiVersion: extensions/v1beta1
kind: PodSecurityPolicy
metadata:
name: z-default-restrictive-psp
labels:
kubernetes.io/cluster-service: "true"
addonmanager.kubernetes.io/mode: Reconcile
spec:
privileged: false
allowPrivilegeEscalation: false
hostNetwork: false
allowedCapabilities:
- 'IPC_LOCK'
hostIPC: false
hostPID: false
runAsUser:
rule: MustRunAsNonRoot
seLinux:
rule: RunAsAny
fsGroup:
rule: 'MustRunAs'
ranges:
- min: 1
max: 65535
supplementalGroups:
rule: 'MustRunAs'
ranges:
- min: 1
max: 65535
volumes:
- 'secret'
- 'emptyDir'
- 'configMap'
- 'projected'
- 'downwardAPI'
- 'gcePersistentDisk'
- 'persistentVolumeClaim'
Our attempts at a fix
- We set
securityContext: {}in thevalues.yamlfile, however the pod was still brought up with:
securityContext:
fsGroup: 1000
supplementalGroups:
- 1
which did not fix the problem.
- We actually were able to fix the
container has runAsNonRoot and image will run as rooterror by changing thechartmuseumuser to1001instead of1000in the Dockerfile.
We figured out that the chartmuseum deployment runs if imagePullPolicy: Always. Must be some caching issue, not a chartmuseum issue.
Closing!
I am also getting the same issue.But in my case infra is handled by infra team and they make it mandatory to make images as non root user.I am stuck there as i am not sure how i can make my angular app using non root user.Here is my docker file :
FROM docker.com/node:latest as node WORKDIR /app
COPY . . RUN npm install #RUN npm build --prod RUN npm run ng build -- --prod
#stage 2 : to run application FROM docker.com/nginx:alpine COPY --from=node /app/dist/MyApp /usr/share/nginx/html