A kubernetes pod may contain a single pod or multiple related pods. There are few use cases where you might want to list the containers in a single pod. One such use case is to get the logs of specific containers.
To get the list of containers inside a pod, use the following command.
kubectl get pods [pod-name-here] -n [namespace] -o jsonpath='{.spec.containers[*].name}*
For example.
kubectl get pods redis-bootstrap -n redis-cluster -o jsonpath='{.spec.containers[*].name}*
Alternatively, you can use the pod to describe the command.
kubectl describe pods redis-bootstrap -n redis-cluster
Bonus: Register for kubernetes CKA/CKAD certification exam today and get 25% discount using a coupon DCUBE20. Plus use cka study guide for reference materials