chartmuseum icon indicating copy to clipboard operation
chartmuseum copied to clipboard

Image v0.8.2: container has runAsNonRoot and image will run as root

Open RGPosadas opened this issue 7 years ago • 2 comments

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

  1. We set securityContext: {} in the values.yaml file, however the pod was still brought up with:
  securityContext:
    fsGroup: 1000
    supplementalGroups:
    - 1

which did not fix the problem.

  1. We actually were able to fix the container has runAsNonRoot and image will run as root error by changing the chartmuseum user to 1001 instead of 1000 in the Dockerfile.

RGPosadas avatar Jun 12 '19 16:06 RGPosadas

We figured out that the chartmuseum deployment runs if imagePullPolicy: Always. Must be some caching issue, not a chartmuseum issue.

Closing!

RGPosadas avatar Jun 12 '19 18:06 RGPosadas

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

tushi0407 avatar Apr 21 '20 18:04 tushi0407