Kubernetes
- Kiazsoft
- Mar 11, 2020
- 1 min read
Updated: May 9, 2020
To get all pods in all namespaces
kubectl get pods --all-namespaces
To get all pods in a particular namespace
kubectl get pods -n <namespaces>
To get details about pod.
kubectl describe pod <pod name>
This will also be useful in case logs are not getting generated due to container start-up failure.
To get logs of a single pod container.
kubectl logs <pod name> -f
flag -f will keep the screen updated with new logs.
To delete a pod
kubectl delete pod <podname>
pod deleted like this will be re-created automatically by kubernetes.
To get all services
kubectl get svc
To get all deployments
kubectl get deployments
To edit existing deployment
kubectl edit deploy <deploy name>
To create a new deployment from file
kubectl create -f <deploy yml file>
To delete a deployment using file.
kubectl delete -f <deploy yml file>
To ssh into pod with single container
kubectl exec -it <pod name> bash
To ssh into one of the container in a pod with multiple container
kubectl exec -it <pod name> -c <container name> bash
To copy files from local to POD
kubectl cp <file> <podname>:/<dest folder>
e.g. kubectl cp /my/foo.bar my-pod:/home/foo/
To find ip addresses of pods which a service points. These will be displayed as endpoints
kubectl get ep <service name>
Sample output
NAME ENDPOINTS AGE
<service> 10.1.0.9:9000 1m
To get node details in json output
kubectl get node <node-name> -o=json
Commentaires