podSecurityContext not working as expected on init container

1.4k views Asked by At

For the first time I am trying to set pod security context. I added the following to the pod spec:

securityContext:
  fsGroup: 2000
  runAsNonRoot: true

And when the pod is trying to come up, the init container is stuck in state CreateContainerConfigError with the following message:

Error: container has runAsNonRoot and image has non-numeric user (flyway), cannot verify user is non-root (pod: "mt-test-pod (c0cd-4c99-8501-1f592acae)", container: flyway-db-updater)

As I understand- there's a user named flyway but it is has no uid.

  1. What should be done in order to make all containers in a pod not run as root?
  2. Is there a specific way to define runAsNonRoot on init containers?
1

There are 1 answers

1
P Ekambaram On

Can you update the pod spec as given below

securityContext:
  fsGroup: 2000
  runAsUser: 1000

reference--> https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod