nerdexam
Linux_Foundation

CKA · Question #44

Create a new PersistentVolumeClaim • Name: pv-volume • Class: csi-hostpath-sc • Capacity: 10Mi Create a new Pod which mounts the PersistentVolumeClaim as a volume: • Name: web-server • Image: nginx •

The test-taker must use kubectl commands in the provided web terminal to create a PersistentVolumeClaim and a Pod, then expand the PVC's capacity using kubectl edit or kubectl patch.

Submitted by joshua94· May 4, 2026Storage

Question

Create a new PersistentVolumeClaim • Name: pv-volume • Class: csi-hostpath-sc • Capacity: 10Mi Create a new Pod which mounts the PersistentVolumeClaim as a volume: • Name: web-server • Image: nginx • Mount path: /usr/share/nginx/html Configure the new Pod to have ReadWriteOnce access on the volume. Finally, using kubectl edit or kubectl patch expand the PersistentVolumeClaim to a capacity of 70Mi and record that change.

Exhibit

CKA question #44 exhibit

Explanation

The test-taker must use kubectl commands in the provided web terminal to create a PersistentVolumeClaim and a Pod, then expand the PVC's capacity using kubectl edit or kubectl patch.

Approach. The correct approach involves a sequence of kubectl commands to achieve the stated objectives:

  1. Create the PersistentVolumeClaim (PVC): First, define the PVC in a YAML file (e.g., pvc.yaml):

    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: pv-volume
    spec:
      storageClassName: csi-hostpath-sc
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: 10Mi
    

    Then apply it using kubectl apply -f pvc.yaml (or create a file using cat <<EOF > pvc.yaml and then apply).

  2. Create the Pod: Next, define the Pod in a YAML file (e.g., pod.yaml) that mounts the PVC:

    apiVersion: v1
    kind: Pod
    metadata:
      name: web-server
    spec:
      volumes:
        - name: pv-storage
          persistentVolumeClaim:
            claimName: pv-volume
      containers:
        - name: nginx
          image: nginx
          ports:
            - containerPort: 80
          volumeMounts:
            - mountPath: "/usr/share/nginx/html"
              name: pv-storage
    

    Then apply it using kubectl apply -f pod.yaml.

  3. Expand the PersistentVolumeClaim: Modify the PVC's storage capacity using either kubectl edit or kubectl patch:

    • Using kubectl edit: kubectl edit pvc pv-volume This will open the PVC definition in a text editor (commonly vi). Locate the spec.resources.requests.storage field and change 10Mi to 70Mi. Save and exit the editor (e.g., by typing :wq in vi and pressing Enter).
    • Using kubectl patch: kubectl patch pvc pv-volume -p '{"spec":{"resources":{"requests":{"storage":"70Mi"}}}}'

These steps correctly address all requirements: creating the PVC and Pod with specified parameters, mounting the volume, and performing the PVC expansion using the exact methods requested.

Common mistakes.

  • common_mistake. Common mistakes include incorrect YAML syntax (indentation, field names), misspelling resource names or StorageClass, forgetting required fields like accessModes in the PVC or claimName in the Pod's volume definition, or specifying an incorrect mountPath. When expanding the PVC, forgetting to save changes after kubectl edit, or attempting to expand by directly modifying a local YAML file and running kubectl apply again (which may not always trigger expansion for storage capacity without kubectl edit or patch) would be incorrect. Not using the specified kubectl edit or kubectl patch commands for expansion would also be wrong, as the question explicitly mandates these methods. Failure to wait for the PVC to bind (if troubleshooting was necessary) could also lead to issues with the Pod starting correctly, although the question's focus is on the creation and modification commands.

Concept tested. This question tests fundamental Kubernetes concepts related to persistent storage: PersistentVolumeClaims (PVCs), StorageClasses, dynamic volume provisioning, mounting volumes to Pods, access modes (ReadWriteOnce), and volume expansion. It also assesses the test-taker's proficiency in using the kubectl command-line tool for resource creation (apply), modification (edit, patch), and YAML manifest authoring.

Reference. null

Topics

#PersistentVolumeClaim#Volume Expansion#StorageClass#Pod Volume Mount

Community Discussion

No community discussion yet for this question.

Full CKA Practice