Friday, September 13, 2019

Kubernetes kubectl cheatsheet


Cheatsheets:



Kubectl commands
  • Apply/create: create resources
  • Run: run the pod from an image. 
  • Explain: documentation of resources. 
  • Delete: a resource. 
  • Get
    • Deployments
    • Pods
    • Events
    • Nodes
  • Describe: display detailed information. 
  • exec: similar to docker exec (executes a command on the container). 
  • Logs: view logs of a container. 
  • Config
  • Cluster-info
  • Expose
  • Scale

Minikube start
minikube start --cpus 4 --memory 8192

Minikube stop
Minikube delete
Minikube ip
Minikube status
Minikube dashboard

#namespaces
Kubectl get ns
Kubectl get po -n default
kubectl get all -n kube-system

Nslookup <servicename>.<namespace>

#ssh
kubectl exec -it pod/webapp-669ddb74b6-gbxhl sh


Kubectl apply -f first-pod.yml
Kubectl get all
kubectl exec webapp ls
kubectl -it exec webapp sh
kubectl describe pod webapp

# delete pod
kubectl delete pods --all
Kubectl delete pod webapp-release-0-5
kubectl delete rs webapp

#rollouts
kubectl rollout history deploy webapp
Kubectl rollout undo deploy web app —to-revision=2

# describe:
Kubectl describe replicaset webapp

#Logs
Kubectl logs 

kubectl describe service fleetman-webapp
kubectl delete po webapp-release-0-5


No comments:

Post a Comment