title: Kubernetes: how to do dynamic PersistentVolumeClaim with persistentVolumeReclaimPolicy: Reclaim
body: <p>I have dynamic <code>PersistentVolume</code> provisioning 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: Reclaim</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: "{{ .Release.Name }}-gatling-test"
  spec:
      restartPolicy: Never
      containers:
        - name: {{ .Release.Name }}-gatling-test
          image: ".../services-api-mvn-builder:latest"
          command: ["sh", "-c", 'mvn -B gatling:test -pl csa-testing -DCSA_SERVER={{ template "project.fullname" . }} -DCSA_PORT={{ .Values.service.appPort }}']
          volumeMounts:
            - name: "{{ .Release.Name }}-test-res"
              mountPath: "/tmp/testResults"
  
      volumes:
        - name: "{{ .Release.Name }}-test-res"
          persistentVolumeClaim:
            claimName: "{{ .Release.Name }}-pvc"
            #persistentVolumeReclaimPolicy: Retain  ???
  </code></pre>