Kubectl Commands
Information Commands
Command | Description |
---|---|
kubectl cluster-info | Display Cluster Info |
kubectl config view | Display Config |
kubectl get pods | List all running pods |
kubectl get services | List all services |
kubectl get nodes | List all nodes |
kubectl get deployments | Deployments view |
kubectl get rc | List replication controllers |
kubectl get pods -o wide | List all pods in ps output format with more information (such as node name). |
kubectl get pods --all-namespaces | List all pods in all namespaces |
kubectl logs <pod> | Display the logs for a service |
kubectl logs -f <pod> | Display the logs for a service |
Actions
Command | Description |
---|---|
kubectl create -f <yaml file> | Create a deployment |
kubectl delete -f <yaml file> | Delete a deployment |
kubectl apply -f <yaml file> | Update a deployment |
kubectl edit -f <yaml file> | Edit and update a deployment |
kubectl exec -it <pod> bash | log into a pod $ kubectl exec -it cloudservice-bcc6c69ff-bnzcv bash |
kubectl scale --replicas=3 deployment/<deployment> | Scale the number of pods for a deployment $ kubectl scale --replicas=3 deployment/cloudservice |
kubectl scale --replicas=1 -f <yaml file> | Scale the number of pods referenced in a yaml file |
kubectl delete deployment <deployment> | Delete all pods for a deployment ie. kubectl delete deployment redis |
kubectl delete pod <pod instance> | Delete a pod |
kubectl expose deployment cloudservice --type=LoadBalancer --name=cloud | Expose deployment |
Minikube Commands
Command | Description |
---|---|
minikube start | Start |
minikube stop | Stop |
minikube dashboard | Display dashboard |
minikube ssh | log into minikube |
| log into minikube |
cat ~/.minikube/machines/minikube/config.json | View minikube config |
ssh -i ~/.minikube/machines/minikube/id_rsa docker@$(minikube ip) -R 5000:localhost:5000 | SSH into minikube and setup a port forwarding to your local docker registry. |
minikube ip | get ip of minikube |
minikube service <service> | Open browser to exposed service |
Reference
Reference | URL |
---|---|
Cheatsheet | https://kubernetes.io/docs/reference/kubectl/cheatsheet/ |
Kubectl for docker users | https://kubernetes.io/docs/reference/kubectl/docker-cli-to-kubectl/ |
Expose external ip | https://kubernetes.io/docs/tutorials/stateless-application/expose-external-ip-address/ |