kubectl - Core Concepts Flashcards
List all namespaces
kubectl get ns
List all pods in all
kubectl get po –all-namespaces
List all the pods in the particular namespace
kubectl get po -n
List all the services in the particular namespace
kubectl get svc -n
List all the pods showing name and namespace with a json path expression
kubectl get pods -o=jsonpath=”{.items[*][‘metadata.name’, ‘metadata.namespace’]}”
Create an nginx pod in a default namespace and verify the pod running
- kubectl run nginx –image=nginx –restart=Never
2. kubectl get po
Create the same nginx pod with a yaml file
- kubectl run nginx –image=nginx –restart=Never –dry-run -o yaml > nginx-pod.yaml
- kubectl create -f nginx-pod.yaml
Output the yaml file of nginx pod
kubectl get po nginx -o yaml
Output yaml of nginx pod without cluster-specific information
kubectl get po nginx -o yaml –export
Get the complete details of the nginx pod
kubectl describe pod nginx
Delete the nginx pod
kubectl delete po nginx
Delete the pod created with example-pod.yaml
kubectl delete -f example-pod.yaml
Force delete nginx pod
kubectl delete po nginx –grace-period=0 –force
Create nginx pod version 1.17.4 and expose port 80
kubectl run nginx –image=nginx:1.17.4 –restart=Never –port=80
Change nginx image to 1.15-alpine and verify
- kubectl set image pod/nginx nginx=nginx:1.15-alpine
2. kubectl describe po nginx