<p>I am using OKD4, and I am trying to mount /etc/php.ini in my pods using a ConfigMap.
In order to do so, I am creating the following K8S objects in my project.</p>
<p>Configmap (previously created to Deployment):</p>
<pre><code>  - apiVersion: v1
    kind: ConfigMap
    data:
      php.ini: |-
        [PHP]

        ;;;;;;;;;;;;;;;;;;;
        ; About php.ini   ;
        ;;;;;;;;;;;;;;;;;;;

    metadata:
      name: php-ini
</code></pre>
<p>Deployment object:</p>
<pre><code>  - kind: Deployment
    apiVersion: apps/v1
    metadata:
      name: privatebin
      labels:
        app: privatebin
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: privatebin
      template:
        metadata:
          creationTimestamp: null
          labels:
            app: privatebin
            deploymentconfig: privatebin
        spec:
          containers:
            - name: privatebin
              image: &lt;my container registry&gt;/privatebin:${IMAGE_TAG}
              volumeMounts:
              - name: config-volume
                mountPath: php.ini
              livenessProbe:
                exec:
                  command:
                  - /bin/sh
                  - -c
                  - &quot;[ -f /run/nginx.pid ] &amp;&amp; ps -C nginx &gt;/dev/null 2&gt;&amp;1 &amp;&amp; ps -C php-fpm &gt;/dev/null 2&gt;&amp;1&quot;
                initialDelaySeconds: 10
                periodSeconds: 5
              readinessProbe: 
                httpGet: 
                  scheme: HTTP
                  path: /
                  port: 8080
                  initialDelaySeconds: 10
                  periodSeconds: 5
              ports:
                - containerPort: 8080
                  protocol: TCP
              resources: 
                limits:
                  cpu: &quot;250m&quot; # parameterize in tekton pipeline 
                  memory: &quot;368Mi&quot; # parameterize in tekton pipeline, maybe using template
                requests:
                  cpu: &quot;100m&quot; # parameterize in tekton pipeline, maybe using template
                  memory: &quot;256Mi&quot; # parameterize in tekton pipeline, maybe using template
              securityContext:
                runAsUser: 1000
                fsGroup: 1000
                fsGroupChangePolicy: &quot;OnRootMismatch&quot;
              imagePullPolicy: Always
          restartPolicy: Always
          terminationGracePeriodSeconds: 30
          volumes:
            - name: config-volume
              configMap:
                name: php-ini
      strategy:
        type: RollingUpdate
        rollingUpdate:
          maxUnavailable: 25%
          maxSurge: 25%
</code></pre>
<p>For some reason my pods are missing and there are the following errors:</p>
<ul>
<li>lastTransitionTime: &quot;2021-10-08T12:53:01Z&quot;
lastUpdateTime: &quot;2021-10-08T12:53:01Z&quot;
message: 'pods &quot;privatebin-55678c66c5-&quot; is forbidden: unable to validate against
any security context constraint: [spec.containers[0].securityContext.runAsUser:
Invalid value: 1000: must be in the ranges: [1002460000, 1002469999] spec.volumes[0]:
Invalid value: &quot;configMap&quot;: configMap volumes are not allowed to be used]'</li>
</ul>
<p>ReplicaSet times out also with similar error:
status:
conditions:</p>
<ul>
<li>lastTransitionTime: &quot;2021-10-08T12:53:01Z&quot;
message: 'pods &quot;privatebin-55678c66c5-&quot; is forbidden: unable to validate against
any security context constraint: [spec.containers[0].securityContext.runAsUser:
Invalid value: 1000: must be in the ranges: [1002460000, 1002469999] spec.volumes[0]:
Invalid value: &quot;configMap&quot;: configMap volumes are not allowed to be used]'</li>
</ul>
<p>Why can't I mount the ConfigMap? Is it because of the Securitycontext in the Deployment?</p>
<p>Thanks in advance,</p>

DrunkCoder
<p>(The error has nothing to do with configmaps, but when you get the error resolved you may need to tweak your configmap slightly to accurately drop the file into the directory you want it to land.)</p>
<p>OKD is OpenShift, so it's using SCC (not PSP).</p>
<p>By default you have access to the &quot;restricted&quot; SCC in your namespace.  The UIDs being thrown out in the error are from the namespace annotation (oc get namespace FOO -o yaml) will show them.</p>
<p>To fix:</p>
<ul>
<li>you can change your runAsUser to match the namespace annotation; or (better) just use &quot;runAsNonRoot: true&quot; which forces it to not run as root and takes the first uid in that annotation range.  You may need to update the container image to leverage GROUP membership, not uid, for file access permissions.</li>
<li>you can allow your accounts to use the &quot;nonroot&quot; SCC to run as any uid, meeting your expectation to run as uid=1000.  I would suggest you look at the first option as being the preferable option.</li>
</ul>
