Challenge, Easy,  on  Kubernetes

Provision and Configure a PersistentVolume and PersistentVolumeClaim for a Deployment

Scenario

The jupiter namespace has been created for a new project that requires persistent storage. Your job is to provision that storage from scratch using static provisioning: manually create a PersistentVolume, bind a PersistentVolumeClaim to it, and configure a Deployment to use it.

All resources must use consistent names and settings so that Kubernetes can bind the PV and PVC automatically without a StorageClass.


Task

Three resources must be created in the correct order. The PV must exist before the PVC can bind to it, and the Deployment references the PVC by name.

PersistentVolume
PersistentVolumeClaim
Deployment

Create a PersistentVolume named jupiter-project-jupiter-pv with the following spec:

  • Capacity: 1Gi
  • Access mode: ReadWriteOnce
  • HostPath: /Volumes/Data
  • No storageClassName (leave the field empty)
Hint 1 - PersistentVolume manifest

A PersistentVolume is a cluster-scoped resource — it does not belong to a namespace. Create the file and apply it:

kubectl apply -f pv.yaml
kubectl get pv jupiter-project-jupiter-pv

Expected status: Available

The key fields to get right:

spec:
  capacity:
    storage: ___
  accessModes:
    - ___
  hostPath:
    path: ___
  storageClassName: ""

Setting storageClassName: "" is required for static provisioning. Without it, Kubernetes may attempt dynamic provisioning and the PVC will never bind to this PV.

Documentation

In the jupiter namespace, create a PersistentVolumeClaim named jupiter-project-jupiter-pvc with:

  • Requested storage: 1Gi
  • Access mode: ReadWriteOnce
  • No storageClassName (leave the field empty)
  • The claim must reach Bound status against the PV created above
Important

Binding typically completes within 10–15 seconds. If the PVC is still Pending after 20–30 seconds, check your configuration with kubectl describe pvc jupiter-project-jupiter-pvc -n jupiter.

Hint 2 - PersistentVolumeClaim manifest

Create the PVC in the jupiter namespace:

kubectl apply -f pvc.yaml
kubectl get pvc -n jupiter
kubectl get pv jupiter-project-jupiter-pv

Expected: PVC status Bound, PV status Bound.

The key fields:

metadata:
  namespace: jupiter
spec:
  accessModes:
    - ___
  resources:
    requests:
      storage: ___
  storageClassName: ""
  volumeName: ___   # optional but recommended — pins the claim to the correct PV

If the PVC stays Pending, check that storageClassName, accessModes, and storage match the PV exactly.

Documentation

In the jupiter namespace, create a Deployment named project-jupiter with:

  • Image: httpd:alpine
  • The PVC jupiter-project-jupiter-pvc mounted at /tmp inside the container
Hint 3 - Deployment manifest with PVC volume

A Deployment references a PVC through a volume definition in the pod spec and a volumeMount in the container spec. Two separate fields must both be present:

spec:
  template:
    spec:
      containers:
      - name: ___
        image: ___
        volumeMounts:
        - name: ___
          mountPath: ___
      volumes:
      - name: ___
        persistentVolumeClaim:
          claimName: ___

Apply and verify:

kubectl apply -f deployment.yaml
kubectl get pods -n jupiter
kubectl describe pod <pod-name> -n jupiter | grep -A5 Volumes

Documentation

Static provisioning flow: admin creates PV, developer creates PVC, Kubernetes binds them, pod mounts the PVC

Static provisioning flow — the PV must exist before the PVC can bind, and the PVC must be Bound before the pod can start.


⚒ Test Cases