Kubernetes CKA sample exam question 115 with answer

Question
List all persistent volumes in following format and sort the volumes based on their capacity and save the output to /tmp/pv-capacity.txt:

VOLUME_NAME CAPACITY NAMESPACE
Answer
Use custom-columns with sort-by display options:
kubectl get pv -o=custom-columns=VOLUME_NAME:.metadata.name,CAPACITY:.spec.capacity.storage,NAMESPACE:.metadata.namespace --sort-by=.spec.capacity.storage > /tmp/pv-capacity.txt