CKA Storage Master Reference Link to heading
Domain 1 — Storage Link to heading
Access Modes Link to heading
| Mode | Short | Meaning |
|---|---|---|
| ReadWriteOnce | RWO | One NODE read/write (multiple pods on same node OK) |
| ReadOnlyMany | ROX | Many nodes read-only |
| ReadWriteMany | RWX | Many nodes read/write |
Trap: RWO = one node, NOT one pod. Deployment + Job can both mount RWO PVC if on same node.
PVC Stuck Pending — Access Mode Mismatch Link to heading
k get pv -o yaml # check spec.accessModes
k get pvc -n <ns> -o yaml # check spec.accessModes
# PV must support what PVC requests
# Fix: edit PV to match PVC access mode (question says alter only PV)
PV Reclaim Policies Link to heading
| Policy | What happens when PVC deleted |
|---|---|
Retain | PV stays, data preserved |
Delete | PV auto-deleted, data gone |
Recycle | Deprecated |
StatefulSet PVC Issues Link to heading
PVC Bound to Wrong Node (local-path provisioner) Link to heading
# Scale to 0 first (can't delete PVC while pod uses it)
k -n <ns> scale sts <name> --replicas=0
# Delete PVC (PV auto-deleted if reclaimPolicy: Delete)
k -n <ns> delete pvc <pvc-name>
# Verify PV gone
k get pv
# Scale back — StatefulSet recreates pod + PVC + PV on current node
k -n <ns> scale sts <name> --replicas=1
Key: volumeClaimTemplates causes StatefulSet to recreate PVCs automatically.
Trap: Must scale to 0 first — PVC deletion hangs if pod still mounts it.
PVC Data Migration Link to heading
Pattern: Job with Two PVCs Link to heading
apiVersion: batch/v1
kind: Job
metadata:
name: migrator
namespace: migration
spec:
template:
spec:
restartPolicy: Never
containers:
- name: migrator
image: bash:5
command:
- bash
- -c
- cp -r /old-data/* /new-data/
volumeMounts:
- name: old
mountPath: /old-data
- name: new
mountPath: /new-data
volumes:
- name: old
persistentVolumeClaim:
claimName: app-data
- name: new
persistentVolumeClaim:
claimName: app-data-retain
Switch Deployment to New PVC Link to heading
k edit deploy <name> -n <ns>
# Change claimName in volumes section
# Delete Job first, then old PVC (Job pod still mounts PVC — deletion hangs)
k delete job migrator -n migration
k delete pvc app-data -n migration
StorageClass Link to heading
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: retain-storage
annotations:
storageclass.kubernetes.io/is-default-class: 'true'
provisioner: <provisioner>
reclaimPolicy: Retain
volumeBindingMode: WaitForFirstConsumer
HostPath Volumes Link to heading
volumes:
- name: vol
hostPath:
path: /configurator
volumeMounts:
- name: vol
mountPath: /mount
Write to /mount/config in pod = writes to /configurator/config on node.
Trap: HostPath data persists on node even after pod is deleted. Must rm -rf manually.
Keep Pod Running After One-Shot Write Link to heading
command: ["bash", "-c", "echo <value> > /mount/config && sleep infinity"]
Volume Can’t Be Mounted (drain scenario) Link to heading
# 1. Drain node (evicts pod)
k drain <node> --ignore-daemonsets
# 2. Add toleration to StatefulSet for controlplane taint
k describe node controlplane | grep Taint # get exact taint key
k edit sts <name> -n <ns>
# Add under spec.template.spec:
tolerations:
- key: node-role.kubernetes.io/control-plane
operator: Exists
effect: NoSchedule
# 3. If PVC still stuck (local to old node) — delete PVC
k scale sts <name> -n <ns> --replicas=0
k delete pvc <pvc-name> -n <ns>
k scale sts <name> -n <ns> --replicas=1