Man

Development & AI | Alper Akgun

Kubernetes notes

August, 2023

Kubernetes(k8s) is an open-source container orchestration platform designed to automate the deployment, scaling, management, and maintenance of containerized applications. Originally developed by Google and later donated to the Cloud Native Computing Foundation (CNCF), Kubernetes has become the de facto standard for container orchestration in the world of cloud-native application development.

A lot of app deployments run Kubernetes on one of the hyperclouds like Azure, AWS, and GCP. If you want to run Kubernetes on your laptop, you can use one of the light-weight alternatives like microk8s, k3s, minikube, rancher desktop and alternatives.

Here are some notes I had while installing Rancher and microk8s.



# Cluster info
kubectl cluster-info
kubectl config view
kubectl api-resources
kubectl version
kubectl api-versions


# List everything.  "-A" or "-all-namespaces" or "-n my_namespace"
kubectl get all -A
kubectl get pods -o wide
kubectl get pods -n FOONAMESPACE -o wide
kubectl get pod FOOPOD -o yaml

# Namespaces
kubectl create namespace FOONAMESPACE
kubectl get namespace FOONAMESPACE
kubectl describe namespace FOONAMESPACE
kubectl delete namespace FOONAMESPACE

# Pods
kubectl get pod
kubectl delete pod FOOPOD
kubectl describe pod FOOPOD
kubectl create pod FOOPOD
kubectl exec FOOPOD -c FOOCONTAINER DO_MY_COMMAND
kubectl exec -it FOOPOD /bin/sh
kubectl top pod
kubectl annotate pod
kubectl label pod

# Services
kubectl get services
kubectl describe services
kubectl expose deployment FOODEPLOYMENT

# Secrets
kubectl create secret
kubectl get secret
kubectl describe secret
kubectl delete secret FOOSECRET

# Nodes
kubectl get node
kubectl top node

# Deployments
kubectl get deployment
kubectl describe deployment FOO
kubectl edit deployment FOO
kubectl create deployment FOO
kubectl rollout status deployment FOO

# Logs
kubectl logs FOOPOD
kubectl logs --since=1h FOOPOD
kubectl logs --tail=20 FOOPOD
kubectl logs -f FOOSERVICE [-c FOOCONTAINER]
kubectl logs -f FOOPOD

# manifest files: modify objects
kubectl apply -f FOO.yaml
kubectl apply -d ./FOODIR
kubectl delete -f FOO.yaml


# Daemonsets, events,
kubectl get events --field-selector type=Warning
kubectl get daemonset
kubectl get serviceaccounts