Using configmap for ports

Viewed 2480

Is it possible to use configMap values for port values like containerPort or targetPort?

Here's the possible example how it could work:

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
1 Answers
Related