I have a deployment configuration as follows:
apiVersion: extensions/v1beta1
kind: Deployment
--- REMOVED FOR BREVITY ---
volumes:
- gcePersistentDisk: {fsType: pd-ssd, pdName: devtasker-disk}
name: devtasker-disk
- gcePersistentDisk: {fsType: pd-ssd, pdName: devtasker-pg}
name: devtasker-pg
This works fine, however it requires the persistent volumes to be created manually and then the deployment can take place.
I saw in Kubernetes 1.4 they have released "Dyanmic Provisioning & Storage Classes".
I have added a storage class as follows:
kind: StorageClass
apiVersion: storage.k8s.io/v1beta1
metadata:
name: ssd-storage
provisioner: kubernetes.io/gce-pd
parameters:
type: pd-ssd
I now want to add a PVC to my deployment configuration file mentioned above. The standard PVC for the above storage class goes like this:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
annotations: {volume.beta.kubernetes.io/storage-class: ssd-storage}
name: claim1
spec:
accessModes: [ReadWriteOnce]
resources:
requests: {storage: 30Gi}
Im struggling to get the above PVC into my deployment configuration mentioned in the first code block above.
I tried this:
volumes:
- gcePersistentDisk: {fsType: pd-ssd, pdName: devtasker-disk}
name: devtasker-disk
- gcePersistentDisk: {fsType: pd-ssd, pdName: devtasker-pg}
name: devtasker-pg
- persistentVolumeClaim: {claimName: ssd-storage, annotations: {volume.beta.kubernetes.io/storage-class: ssd-storage}}
name: ssd-storage
.. but I haven't had any luck with many different combinations. I get the following:
error validating "kubernetes/deployment.yml": error validating data: found invalid field annotations for v1.PersistentVolumeClaimVolumeSource; if you choose to ignore these errors, turn validation off with --validate=false
Could anyone please point me in the right direction here?
The storage class tells how to create the PV. The PVC claim requests the actual PV from the underlining infrastructure.
Your deployment should only know about the PVC, so using your example you would end up with the following and remove the gcePersistentDisk
entries:
volumes:
- name: storage
persistentVolumeClaim
claimName: claim1
- name: storage2
persistentVolumeClaim
claimName: claim2