Creating pods

To configure a pod, do the following steps:
  1. Create a manifest file (pod.yaml) with pod definition referencing the persistent volume claim (PVC). Following is an example of a pod definition for creating a nginx container by using a previously created PVC:
    # cat pod.yaml
    
    apiVersion: v1
    kind: Pod
    metadata:
      name: csi-scale-staticdemo-pod
      labels:
        app: nginx
    spec:
      containers:
       - name: web-server
         image: nginx
         volumeMounts:
           - name: mypvc
             mountPath: /usr/share/nginx/html/scale
         ports:
         - containerPort: 80
      volumes:
       - name: mypvc
         persistentVolumeClaim:
           claimName: [pvc name]
           readOnly: false
    Note: claimName is the PVC name to be used by pod for persistent storage. The readOnly flag can be set to true, in which case the pod mounts the PVC in the read-only mode.
  2. Issue the following command to create the pod:
    kubectl apply -f pod.yaml
For more information about pods, see Configure a Pod to Use a PersistentVolume for Storage in the Kubernetes documentation.