Baakey

May 10, 2021

Kubernetes 101

References

CheatSheet


> List all pods in the namespace
kubectl get pods -o wide

> List all services in the namespace
kubectl get services

> List all deployments in the namespace
kubectl get deployments

> Describe all deployments in the namespace
kubectl describe deployments

> Describe a particular deployment
kubectl describe deployments my-dep

> Describe a particular pod
kubectl describe pods my-pod

> Edit deployment my-dep
kubectl edit deployment my-dep

> Get a my-dep's YAML
kubectl get deployments my-dep -o yaml

> Get a my-pod's YAML
kubectl get pod my-pod -o yaml

> Show logs of my-pod
kubectl logs -f my-pod

> Attach to my-pod
kubectl attach my-pod -i
kubectl exec -it my-pod /bin/bash

> Get ingresses
kubectl get ingresses

> Describe ingress
kubectl describe ingresses my-ingress

> Apply yaml configurations recursively from current folder
kubectl apply -R -f

> Clean namespace 
kubectl delete services example-svc
kubectl delete deployments example-deployment
kubectl delete persistentvolumeclaims example-claim

> Helm setup
export KUBE_USER=“baakeydow"
export KUBE_NAMESPACE=“baakeydow-ns”

> Create alias for helm
alias helm="helm --tiller-namespace $KUBE_NAMESPACE"

> Set it up and running
helm init --service-account $KUBE_USER --history-max 200

> Get the latest list of charts
helm repo update

> List releases
helm list

> List chart repositories
helm repo list

> Install stable/docker-registry
helm install stable/docker-registry --name docker-registry

> Delete stable/docker-registry
helm delete --purge docker-registry