kubectl version
kubectl cluster-info
kubectl get nodes
kubectl run <appname> --image=<imagelocation> --p <portno>
kubectl get deployments
kubectl get pods
kubectl describe pods
kubectl get services
kubectl expose
kubectl describe deployment
kubectl delete service
Deployments
kubectl create deployment <name> --image= <image>
kubectl scale deployment <deployment> --replicas=<number>
kubectl rollout status deployment <deployment>
kubectl rollout restart deployment <deployment>
kubectl rollout history deployment <deployment>
kubectl rollout undo deploy <deployment> --to revision= <revision>
Services
kubectl expose pod/deployment <name> --port x --target-port x
kubectl get services --show-labels
Pods:
kubectl exec -ti $POD_NAME curl www.google.com
kubectl run <pod-name> --image=<image-name>--restart=Never
kubectl exec -ti <pod-name> <command>
kubectl exec -ti <pod-name> -c <container> sh
Secrets:
kubectl create secret generic <name> --from-literal=<key>=<value>
kubectl create secret generic <name> --from-file=key=./file.txt
kubectl get secret <secret-name> -o jsonpath=”{.data.<key-name>}”
Contexts:
kubectl config get-contexts
kubectl config current-context <context-name>
kubectl config use-context <context-name>
kubectl logs <pod_name>
kubectl logs --since=1h <pod_name>
kubectl logs -c <container_name> <pod_name>
kubectl logs --previous <pod_name>
kubectl get events
kubectl get events --field-selector type=Warning
kubectl get events --field-selector involvedObject.kind!=Pod
kubectl get replicasets
kubectl describe replicasets <replicaset_name>
kubectl scale --replicas=[count]
#Services
kubectl get services
kubectl describe services
kubectl expose deployment [deployment_name]
kubectl edit services