170 Red Hat OpenShift and IBM Cloud Paks on IBM Power Systems: Volume 1
For a stateful container, you need the PV backing up the PVC requested for the pod. Other 
scenarios showed the FlexVolume use with PowerVC, but this case uses the NFS attachment 
for you to see another supported backend for volumes. This type of backend is still available if 
not in use on any pod. The deployment file is shown in Example 7-11. Also, check the policy 
of the PV is Retain and not Delete so the PVC can be used, even after migrated to another 
cloud. This makes it available if and when the container is brought back.
Example 7-11   Yaml file for NFS backed PV on the Power Systems cluster
apiVersion: v1
kind: PersistentVolume
metadata:
  name: appmongo-ibm-mongodb-dev-datavolume
spec:
  persistentVolumeReclaimPolicy: Retain
  storageClassName: manual
  capacity:
    storage: 2Gi
  accessModes:
    - ReadWriteMany
  nfs:
    server: dcocp1
    path: /nfsmongofs/mongo
To verify the claim bounds to the intended PV, leave the PVC created, as shown in 
Example 7-12. 
Example 7-12   Yaml file for NFS backed PVC on the Power Systems cluster
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: "appmongo-ibm-mongodb-dev-datavolume"
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 2Gi
MongoDB needs users and passwords for the database. To confirm that the password is not 
on the Pod specification, use a secret entry, as shown in Example 7-13. Do not use this hash 
in your environment because this is a password for demonstration purposes only.
Example 7-13   Yaml file for Secret password safeguard
apiVersion: v1
data:
  password: c3RhcnQxMjM0
kind: Secret
metadata:
  labels:
    app: appmongo-ibm-mongodb-dev
  name: appmongo-ibm-mongodb-dev
type: Opaque