I have created some Persistent Volumes myself. Is it possible to make the volumeClaimTemplates
in my Stateful Set select those? It seems that it will always provision new persistent volumes, rather than use the existing ones.
Kubernetes: 1.5
You need to use the selector
option. If you label your pv's accordingly, the pods would use the volumes you previously created.
Example From: https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: myclaim
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 8Gi
storageClassName: slow
selector:
matchLabels:
release: "stable"
matchExpressions:
- {key: environment, operator: In, values: [dev]}
Even though it is a PersistentVolumeClaim, it should be applicable to your volumeClaimTemplate