kubectl (Kube Controller / Command Line tool) basic command cheat sheet
kubectl run hello-minikube --> to deploy an application
kubectl cluster-info --> get information about cluster
kubectl get nodes --> get information about the nodes
kubectl get nodes -o wide --> get detailed info of nodes.
kubectl config view --> get config details of the cluster
kubectl run hello-world --image=hello-world --> (download hello-world container from docker and deploy on a pod)
kubectl get pods --> view the available pods on the node
kubectl describe pods --> gives more details of the pod i.e; node on which pods and image is available, etc.
kubectl describe pod POD_ID --> details of a specific pod
kubectl create -f pod-def.yml --> creates a pod as per the definition in pod-def.yml
kubectl delete pod
kubectl edit pod --> can edit the yaml file of the pod
kubectl create -f replicationcontroller.yml --> creates
replication controller with number of pods as that of replicas in the
yml file
kubectl get replicationcontroller --> lists the replication controller details
kubectl get replicaset--> lists the replicaset details
kubectl replace -f replicaset.yml --> replace with the updated yml file
kubectl scale --replicas=4 -f replicaset.yml -->
To dynamically scale replicas, without updating the yml, scale command can be used. This wont update the base yaml file and will potentially loose this config.
kubectl scale --replicas=4replicaset REPLICASET_NAME
eg: kubectl scale --replicas=4 -f replicaset repset
kubectl delete replicaset repset --> repset is the name of the replicaset
kubectl get all --> display all the pods, replicasets, deployments etc;
kubectl get deployments --> displays the details of deployments
kubectl apply -f DEPLOYMENT_YAML_FILE.YML --> apply any deployment changes
kubectl set image deployment/myapp hello-world --> onverride the image in the existing deployment
kubectl rollout status deployment/app --> deployment status
kubectl rollout history deployment/app --> view deployment revisions
kubectl rollout undo deployment/app --> rollback the deployment
kubectl create -f deployment.yml --record --> records the change cause of deployment which can be seen with the history command
kubectl get services --> view services eg: nodeport service
kubectl get nodes -o wide --> get detailed info of nodes.
kubectl config view --> get config details of the cluster
kubectl run hello-world --image=hello-world --> (download hello-world container from docker and deploy on a pod)
kubectl get pods --> view the available pods on the node
kubectl describe pods --> gives more details of the pod i.e; node on which pods and image is available, etc.
kubectl describe pod
kubectl create -f pod-def.yml --> creates a pod as per the definition in pod-def.yml
kubectl delete pod
kubectl edit pod
kubectl get replicaset--> lists the replicaset details
kubectl replace -f replicaset.yml --> replace with the updated yml file
kubectl scale --replicas=4 -f replicaset.yml -->
To dynamically scale replicas, without updating the yml, scale command can be used. This wont update the base yaml file and will potentially loose this config.
kubectl scale --replicas=4
eg: kubectl scale --replicas=4 -f replicaset repset
kubectl delete replicaset repset --> repset is the name of the replicaset
kubectl get all --> display all the pods, replicasets, deployments etc;
kubectl get deployments --> displays the details of deployments
kubectl apply -f DEPLOYMENT_YAML_FILE.YML --> apply any deployment changes
kubectl set image deployment/myapp hello-world --> onverride the image in the existing deployment
kubectl rollout status deployment/app --> deployment status
kubectl rollout history deployment/app --> view deployment revisions
kubectl rollout undo deployment/app --> rollback the deployment
kubectl create -f deployment.yml --record --> records the change cause of deployment which can be seen with the history command
kubectl get services --> view services eg: nodeport service
No comments:
Post a Comment