Low Orbit Flux Logo 2 F

Kubernetes Survival Guide

In this doc:

Separate Docs:

Basic how to commands



kubectl get namespace
kubectl config set-context --current --namespace=kube-system


kubectl version
kubectl cluster-info
kubectl cluster-info dump
kubectl config view

kubectl get nodes
kubectl describe nodes           # ton of info about nodes
kubectl get deployments
kubectl describe deployment

kubectl get pod
kubectl get pods
kubectl get pods –output=wide	            # more info, including IPs
kubectl get pod -A                          # all name space
kubectl get pods --namespace=kube-system    # specify name space
kubectl describe pods
kubectl describe pod my_pod1

kubectl get events

kubectl get svc
kubectl get services
kubectl describe services/nginx
kubectl get pod,svc -n kube-system	    # view pod,svc for kube-system
kubectl delete service hello-node
kubectl delete deployment hello-node

kubectl logs my_pod1
kubectl exec my_pod1 -- env	            # run command on pod
kubectl exec -ti my_pod1 -- bash        # get shell on pod
kubectl exec -ti my_pod1 -- /bin/sh     # get shell on pod

kubectl top pods              # show pod CPU / Mem
kubectl top pods -A           # all name spaces
kubectl top pod my_pod1       # specific pod

Deployments and Services



kubectl create deployment nginx --image=nginx
kubectl expose deployment nginx --type=NodePort --port=8080
kubectl expose deployment nginx2 --type=LoadBalancer --port=8080
kubectl delete service nginx



kubectl proxy                        # default 8001 on local host
curl http://localhost:8001/version   # or wherever proxy is located
curl http://localhost:8001/api/v1/namespaces/default/pods           # info about pods
curl 192.168.3.223:8001/api/v1/namespaces/default/pods/nginx-676b6c5bbc  # info about a pod



kubectl label pods nginx-676b6c5bbc version=v1      # label a pod
kubectl get pods -l version=v1                      # get pods with a label
kubectl get services -l version=v1                  # get services with a label
kubectl delete service -l app=nginx




kubectl get rs                       # show replica sets
kubectl scale nginx --replicas=4     # scale up
kubectl scale nginx --replicas=2     # scale down



kubectl set image myapp myapp:v2  # update image for deployment
kubectl rollout status myapp      # check status of rollout
kubectl rollout undo myapp    # roll back if failed

Basic fixes / troubleshooting

Deploy and Expose Apps

Stateful apps and storage locations

nginx ( multiple instances with IDs, update pages, access pages with LB ) mysql postgres awx prometheus/grafana

Helm:



sudo snap install helm --classic

Create my own app and add to kubernetes

Deployments as configs

Architecture and terms

Kubernetes Architecture Kubernetes Pod

How the network fits together

Service types:

Communication:

Differnt address ranges:

Show cluster IP ( pod ) and external IP:



kubectl get services

Show cluster IPs ( pod ) and endpoint IPs ( service ):



kubectl describe service nginx