<p>I have a config yaml file for a kubernetes deployment that looks like this:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    app: &lt;some_app&gt;
  name: &lt;some_app&gt;
  namespace: dataengineering
spec:
  replicas: 1
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: &lt;some_app&gt;
    spec:
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      containers:
        - image: 127579856528.dkr.ecr.us-west-2.amazonaws.com/dataengineering/&lt;some_app&gt;:latest
          imagePullPolicy: Always
          name: &lt;some_app&gt;
          env:
          - name: ES_HOST
            value: "vpc-some-name-dev-wrfkk5v7kidaro67ozjrv4wdeq.us-west-2.es.amazonaws.com"
          - name: ES_PORT
            value: "443"
          - name: DATALOADER_QUEUE
            valueFrom:
              configMapKeyRef:
                name: &lt;some_name&gt;
                key: DATALOADER_QUEUE
          - name: AWS_DEFAULT_REGION
            value: "us-west-2"
          - name: AWS_ACCESS_KEY_ID
            valueFrom:
              secretKeyRef:
                name: &lt;some_name&gt;
                key: AWS_ACCESS_KEY_ID
          - name: AWS_SECRET_ACCESS_KEY
            valueFrom:
              secretKeyRef:
                name: &lt;some_name&gt;
                key: AWS_SECRET_ACCESS_KEY
 ...
</code></pre>

<p>Currently, this file is in <code>dev/deployment.yaml</code> but I also want a <code>prod/deployment.yaml</code>. Instead of copying this whole file over, is there a better way to DRY up this file so it can be used for both dev and prod clusters? The parts of this file that differ are some of the environment variables (I used a different <code>DATALOADER_QUEUE</code> variable for prod and dev, and the AWS keys. What can be done?</p>

<p>I looked into some options like a configmap. How does one do this? What's a mounted volume? I'm reading this: <code>https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#add-configmap-data-to-a-volume</code> but I'm not sure what it is.... what is a volume? How do I access the data stored in this "volume"?</p>

<p>Can the image be switched from prod to dev? I know that seems odd...</p>

<p>Something like this would help with the env vars:</p>

<pre><code>  envFrom:
  - configMapRef:
      name: myapp-config
  - secretRef:
      name: myapp-secrets
</code></pre>

<p>You can then use different namespaces for dev vs. prod so the references don't have to vary. For handling labels, look at Kustomize overlays and setting labels at the overlay level.</p>
