- kubectl get pods -n (namespace) | grep -v Running | grep -v Completed – This will get a list of pods in a problem state.
- kubectl describe pod (pod name) -n (namespace) – This will get additional info on the pod
- kubectl get pods -n (namespace) –sort-by=.status.startTime – This will list pods by age
- watch ‘kubectl get pods -n (namespace) | grep -v Running | grep -v Completed’ This will watch the pods come up and show which ones aren’t running or completed
- kubectl config use-context ## Switch the current context – a context is a set of Kubernetes resources or a cluster
- kebectl get services This will list all the services in the namespace
-
kubectl get pods –all-namespaces ##This will get all the pods in all the namespaces in a specific context
- kubectl cluster-info Get the information on the cluster
- kubectl get nodes Get the information on the nodes on the backend
- kubectl create deployment (name) –image=repo/container
- kubectl expose deployment (name) –port=80 –type=Nodeport
- kubectl cluster-info dump Dumps a ton of information about the cluster
- kubectl get pv (get a list of persistent volumes)
- kubectl get pv -o yaml (get a list of persistent volumes in yaml format)
- spec:
- accessModes:
- – ReadWriteOnce
capacity:
storage: 3Gi
hostPath:
path: /mnt/data3
type: “”
persistentVolumeReclaimPolicy: Retain
storageClassName: manual
volumeMode: Filesystem - kubectl get pv –sort-by=.spec.capacity.storage
- kubectl exec (pod) -n (namespace) — (exec). perform a command in a pod .. for example kubectl exec benspod -n bensnamespace — cat /etc/resolv.conf
- kubectl apply -f deployment.yml (creates a deployment based on a specific yaml file)
- kubectl delete service (name.svc) -n (namespace)
- You can either use Declarative text to spin up a deployment like the previous example or Imperative like this kubectl create deployment (deployment) — image=nginx
- kubectl create deployment (deployment) –image=nginx –dry-run -o yaml
- –dry-run -o yaml (Shows the output without actually creating the object in the cluster)
I just completed the Launch Single Node Kubernetes Cluster scenario on Katacoda! https://www.katacoda.com/courses/kubernetes/launch-single-node-cluster