Without kubectl, how do you display list of names of available Kubernetes contexts that you can use from the machine?
Experience Level: Junior
Tags: Kubernetes
Answer
Use the following command:
How does it work?
- The configuration data is stored the file ~/.kube/config
- cat command displays the conent of the file
- yq command converts the output from yaml to JSON format
- jq command will iterate over all child elements of element (array) contexts, name property of each child element is displayed.
Related Kubernetes job interview questions
How can you display yaml details of all deployments, pods and services that are present in the current Kubernetes namespace?
Kubernetes JuniorHow can you display all objects that are present in the current Kubernetes namespace?
Kubernetes JuniorUsing kubectl, how do you display list of names of available Kubernetes contexts that you can use from the machine?
Kubernetes JuniorHow do you display current Kubernetes context using kubectl?
Kubernetes JuniorHow can you identify what IP addresses have the nodes assigned in Kubernetes?
Kubernetes Junior