September 2018
Intermediate to advanced
764 pages
20h 6m
English
We now need to update our stateful-set.yaml file to use the do-block-storage StorageClass. Under the StatefulSet spec (.spec), add a new field called volumeClaimTemplates with the following value:
apiVersion: apps/v1kind: StatefulSetmetadata: ...spec: volumeClaimTemplates: - metadata: name: data spec: accessModes: - ReadWriteOnce resources: requests: storage: 2Gi storageClassName: do-block-storage
This will use the do-block-storage class to dynamically provision 2 GB PersistentVolumeClaim Objects for any containers which mount it. The PVC is given the name data as a reference.
To mount it to a container, add a volumeMounts property under the spec property of the container spec:
apiVersion: apps/v1 ...
Read now
Unlock full access