I am looking to retain PVC when the jenkins job is completed.
podTemplate(workspaceVolume: dynamicPVC(requestsSize: "1Gi",storageClassName: 'test'), containers: [
containerTemplate(name: 'jnlp', image: 'jenkins/jnlp-slave:3.35-5-alpine', args: '${computer.jnlpmac} ${computer.name}')
], yaml:'''
spec:
securityContext:
fsGroup: 1000
''') {
node(POD_LABEL) {
container(name: 'jnlp') {
sh 'echo .....'
}
}
}
and My test storage class definition
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: test
provisioner: kubernetes.io/gce-pd
reclaimPolicy: Retain
parameters:
type: pd-ssd
Everything works fine. But PVC is deleted when job is completed. Is there any way to retain the pVC.
you can't today, the PVC is created with an owner reference to the pod, so when the pod is deleted the PVC is deleted too. A new option would be needed