ratna
ratna

Reputation: 21

Secret mount on Kubernetes container fails with security context (run as non-root user) added

I share a part of the manifest where I added security context added. If I remove the security context, it works fine. I try to use non-root user to up the container. Not sure, what I did wrong below

containers:
        - name: {{ .Chart.Name }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}                             
          securityContext:
            runAsUser: 2000
            allowPrivilegeEscalation: false            
          ports:
            - name: http
              containerPort: 8010
              protocol: TCP                
          volumeMounts:
            - name: mount-jmx-secret
              mountPath: "etc/hello-world"                                                    
      volumes:
        - name: mount-jmx-secret
          secret:
            secretName: jmxsecret
            defaultMode: 0600   

Upvotes: 0

Views: 760

Answers (1)

ratna
ratna

Reputation: 21

I do not know what mistake I made. It worked fine after couple of reinstalls of helm charts. Changes I made, Added a new user to docker file

RUN useradd -u 8877 <user_name>(ram)
USER ram

Upvotes: 1

Related Questions