<p>I have a dynamic <code>PersistentVolume</code> provisioned using <code>PersistentVolumeClaim</code>.</p>
<p>I would like to keep the PV after the pod is done. So I would like to have what <code>persistentVolumeReclaimPolicy: Retain</code> does.</p>
<p>However, that is applicable to <code>PersistentVolume</code>, not <code>PersistentVolumeClaim</code> (AFAIK).</p>
<p><strong>How can I change this behavior for dynamically provisioned PV's?</strong></p>
<pre><code>kind: PersistentVolumeClaim
apiVersion: v1
metadata:
    name: {{ .Release.Name }}-pvc
spec:
    accessModes:
      - ReadWriteOnce
    storageClassName: gp2
    resources:
        requests:
            storage: 6Gi

---
kind: Pod
apiVersion: v1
metadata:
    name: &quot;{{ .Release.Name }}-gatling-test&quot;
spec:
    restartPolicy: Never
    containers:
      - name: {{ .Release.Name }}-gatling-test
        image: &quot;.../services-api-mvn-builder:latest&quot;
        command: [&quot;sh&quot;, &quot;-c&quot;, 'mvn -B gatling:test -pl csa-testing -DCSA_SERVER={{ template &quot;project.fullname&quot; . }} -DCSA_PORT={{ .Values.service.appPort }}']
        volumeMounts:
          - name: &quot;{{ .Release.Name }}-test-res&quot;
            mountPath: &quot;/tmp/testResults&quot;

    volumes:
      - name: &quot;{{ .Release.Name }}-test-res&quot;
        persistentVolumeClaim:
          claimName: &quot;{{ .Release.Name }}-pvc&quot;
          #persistentVolumeReclaimPolicy: Retain  ???
</code></pre>

Ondra Žižka
<p>Workaround would be to create new StorageClass with <code>reclaimPolicy: Retain</code> and use that StorageClass every where.</p>

<pre><code>kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: gp2-retain
  annotations:
provisioner: kubernetes.io/aws-ebs
parameters:
  type: gp2
  fsType: ext4 
reclaimPolicy: Retain
</code></pre>

<p>PS: The reclaimPolicy of the existing StorageClass can't edited, but you can delete the StorageClass and recreate it with <code>reclaimPolicy: Retain</code></p>
