diff --git a/kubernetes-cheatsheet.md b/kubernetes-cheatsheet.md new file mode 100644 index 0000000..f63379c --- /dev/null +++ b/kubernetes-cheatsheet.md @@ -0,0 +1,48 @@ +# Kubernetes Cheatsheet + +## Basics +- Get cluster info: `kubectl cluster-info` +- Get nodes: `kubectl get nodes` +- Get pods: `kubectl get pods` +- Get all resources: `kubectl get all` + +## Contexts and Config +- View config: `kubectl config view` +- Set context: `kubectl config use-context ` +- Set namespace: `kubectl config set-context --current --namespace=` + +## Pods +- Create pod: `kubectl run --image=` +- Describe pod: `kubectl describe pod ` +- Exec into pod: `kubectl exec -it -- /bin/sh` +- Logs: `kubectl logs ` +- Delete pod: `kubectl delete pod ` + +## Deployments +- Create deployment: `kubectl create deployment --image=` +- Get deployments: `kubectl get deployments` +- Scale: `kubectl scale deployment --replicas=` +- Update image: `kubectl set image deployment/ =` +- Delete: `kubectl delete deployment ` + +## Services +- Expose deployment: `kubectl expose deployment --type=NodePort --port=80` +- Get services: `kubectl get services` +- Describe service: `kubectl describe service ` +- Delete service: `kubectl delete service ` + +## Namespaces +- Create namespace: `kubectl create namespace ` +- Get namespaces: `kubectl get namespaces` +- Delete namespace: `kubectl delete namespace ` + +## Apply YAML +- Apply file: `kubectl apply -f ` +- Delete from file: `kubectl delete -f ` + +## Other +- Port forward: `kubectl port-forward 8080:80` +- Get events: `kubectl get events` +- Proxy API: `kubectl proxy` + +For more, refer to official docs: https://kubernetes.io/docs/ \ No newline at end of file