← Back to Drills Elapsed 00:00
  1. Create a namespace named storage-lab

    Solution

    PVC and workload resources live in this namespace. The PV itself is cluster-scoped.

    kubectl create namespace storage-lab
  2. Create a PersistentVolume named data-pv with hostPath /mnt/data, capacity 1Gi, accessMode ReadWriteOnce, storageClassName manual, reclaimPolicy Retain

    Solution

    No imperative command exists for PersistentVolume. In the exam, open the docs at Concepts > Storage > Persistent Volumes and copy the hostPath example. PV is cluster-scoped, no -n flag needed.

    apiVersion: v1
    kind: PersistentVolume
    metadata:
      name: data-pv
    spec:
      capacity:
        storage: 1Gi
      accessModes:
        - ReadWriteOnce
      persistentVolumeReclaimPolicy: Retain
      storageClassName: manual
      hostPath:
        path: /mnt/data
    kubectl apply -f pv.yaml
  3. Create a PersistentVolumeClaim named data-pvc in namespace storage-lab with storageClassName manual, accessMode ReadWriteOnce, and requested storage 500Mi

    Solution

    No imperative command exists for PersistentVolumeClaim. In the exam, open the docs at Concepts > Storage > Persistent Volumes > PersistentVolumeClaims. Save the exemple in a file with nano and update it before applying it. storageClassName and accessModes must match the PV exactly for binding to succeed.

    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: data-pvc
      namespace: storage-lab
    spec:
      storageClassName: manual
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: 500Mi
    kubectl apply -f pvc.yaml
  4. Create pod storage-pod in namespace storage-lab, image busybox:1.36, command sleep 3600, with a volume from PVC data-pvc mounted at /data

    Solution

    Generate a base manifest quickly with kubectl: Then adapt it so pod.yaml matches this final manifest: The name value must be identical in volumes and volumeMounts.

    kubectl run storage-pod -n storage-lab --image=busybox:1.36 --dry-run=client -o yaml -- sleep 3600 > pod.yaml
    apiVersion: v1
    kind: Pod
    metadata:
      name: storage-pod
      namespace: storage-lab
    spec:
      containers:
        - name: storage-pod
          image: busybox:1.36
          command: ["sleep", "3600"]
          volumeMounts:
            - name: data
              mountPath: /data
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: data-pvc
    kubectl apply -f pod.yaml
    kubectl wait --for=condition=Ready pod/storage-pod -n storage-lab --timeout=60s
  5. Write a file inside storage-pod to confirm the volume is writable, then read it back

    Solution

    If the mount is correct, write and read both succeed.

    kubectl exec -n storage-lab storage-pod -- sh -c 'echo cka-ok > /data/probe.txt && cat /data/probe.txt'
Loading terminal…

Contact us