There's more...

StatefulSet with persistent volume; it requires a StorageClass that provisions a volume dynamically. Because each Pod is created by StatefulSets, it will create a persistent volume claim (PVC) with a different identifier. If your StatefulSets specify a static name of PVC, there will be trouble if multiple Pods try to attach the same PVC.

If you have StorageClass on your cluster, update datanode.yaml to add spec.volumeClaimTemplates as follows:

$ curl https://raw.githubusercontent.com/kubernetes-cookbook/second-edition/master/chapter3/3-4/datanode-pv.yaml...  volumeClaimTemplates:  - metadata:      name: hdfs-data    spec:      accessModes: [ "ReadWriteOnce" ]      resources:        requests:          storage: 10Gi

This tells Kubernetes to create a PVC and PV ...

Get Kubernetes Cookbook, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.