Binding a PersistentVolumeClaim to a Pod resource

Bind a PersistentVolumeClaim to a Pod resource as a raw block device.

Procedure

  1. Bind the Pod to the PVC file created in Creating a PersistentVolumeClaim (PVC), similar to the following raw-block-pod.yaml file.
    kind: Pod
    metadata:
      name: pod-with-raw-block-volume
    spec:
      containers:
      - name:  pod-with-raw-block-volume
        image: busybox
        command: ["sleep", "infinity"]
        volumeMounts:
        - mountPath: /mnt/ceph_rbd
          name: volume
      volumes:
      - name: volume
        persistentVolumeClaim:
          claimName: raw-block-pvc
  2. Apply the Pod, by using the kubectl apply command.
    kubectl apply -f FILENAME.YAML
    The pod/POD_NAME created message is emitted.