<p>Is it possible to use configMap values for port values like containerPort or targetPort?</p>

<p>Here's the possible example how it could work:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: auth
spec:
  template:
    metadata:
        labels:
          app: auth
    spec:
      containers:
        - name: auth
          image: {{someImage}}
          ports:
            - name: CONTAINER_PORT
              containerPort:
                valueFrom:
                  configMapKeyRef:
                    name: auth-config
                    key: PORT
          env:
            - name: PORT
              valueFrom:
                configMapKeyRef:
                  name: auth-config
                  key: PORT
</code></pre>

<p>No, it is not possible for the <code>ports</code> section.</p>

<p>You can use <code>env</code> keys in container's commands and args. Find more here: <a href="https://github.com/kubernetes/community/blob/master/contributors/design-proposals/expansion.md" rel="noreferrer">https://github.com/kubernetes/community/blob/master/contributors/design-proposals/expansion.md</a></p>

<p>Usually most docker images have static port numbers encoded in the image with <code>EXPOSE</code> keyword, so having a dynamically configurable port is not a best practice from configuration standpoint. Try sticking to fixed port numbers as you can always remap them while exposing the port on Service.</p>
