<p>I've been searching for a while, but I'm pretty new to kustomize. It's taken me a while to get my head around the concept of overlays etc.</p>
<p>I'm trying to use a kustomization file to mount an existing secret into the pod. I can't do it in the deployment because it's a single deployment with 3 different versions of the deployment being handled by kustomize. Each needs a different secret mounting.</p>
<p>So the obvious answer would be to mount the secret as a volume using either a kustomize file in the base or overlay.</p>
<p>I've found information on generating a secret with kustomize, but the secret already exists and is passed in as a kubernetes secret elsewhere.</p>
<p>So to summarize...</p>
<pre><code>base/
├─ kustomization.yaml
├─ statefulset.yaml
├─ service.yaml
├─ instance1/
│  ├─ kustomization.yaml
├─ instance2/
│  ├─ kustomization.yaml
├─ instance3/
│  ├─ kustomization.yaml
</code></pre>
<p>So I'm looking to handle the mounting of the secret to a volume in the instance locations, because the secret will be different for instance 1,2 &amp; 3.</p>
<p>Is this possible?</p>
<p>TIA</p>
<p>EDIT:</p>
<p>I've added a file for the secret (it's for certs hence being different for each instance).</p>
<pre><code>base/
├─ kustomization.yaml
├─ statefulset.yaml
├─ service.yaml
├─ instance1/
│  ├─ kustomization.yaml
│  ├─ pki.yaml
├─ instance2/
│  ├─ kustomization.yaml
├─ instance3/
│  ├─ kustomization.yaml
</code></pre>
<p>My patch file (pki.yaml) looks like this:</p>
<pre><code>apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: de
spec:
  template:
    containers:
    - name: de
      volumeMounts:
        - mountPath: &quot;/opt/de/pki&quot;
          name: pki
          readOnly: true
      volumes:
        - name: pki
          secret:
            secretName: de_1_pki
</code></pre>
<p>Then in <code>./base/instance1/kustomization.yaml</code> I have:</p>
<pre><code>commonLabels:
  app: de-1
resources:
- ../base
nameSuffix: -1
images:
- newName: de-1
  name: de
patches:
  - pki.yaml
</code></pre>
<p>And for completeness my <code>./base/kustomization.yaml</code> file:</p>
<pre><code>kind: Kustomization
apiVersion: kustomize.config.k8s.io/v1beta1
commonLabels:
  app: de
  affinity: directory
resources:
- service.yaml
- statefulset.yaml
</code></pre>
<p>I'm getting an error when deploying the above. So before I dig too deep, just wondering if I'm barking up the right tree?</p>

jonnybinthemix
<p>I managed to fix this with lots of tinkering.</p>
<p>I moved the base specifications for instances to overlays, and then added a patch that way.</p>
<p>Thanks</p>
