loading...

Kubernetes - Refresher Notes

nirmal_kumar profile image Nirmal ・2 min read

This post is for anyone to quickly refresh on the phrases in Kubernetes. If you are starting to explore Kubernetes then this can be used as a checklist on the areas you should be aware of. I have also included some basic commands to work with kubernetes.

Concepts :

  • KUBECONFIG
  • Cluster - Master & Worker
  • Node
  • Node Port
  • ClusterIP
  • Statefulset vs Statetless
  • Deployment
  • Service
  • Pod
  • Namespace
  • Context
  • PersistentVolume
  • PersistentVolumeClaim
  • HostPath (Local)
  • Ingress
  • LoadBalancer
  • ConfigMap
  • Secrets
  • DNS (..svc.cluster.local)
  • KubeAdmin
  • RBAC
  • ServiceAccount
  • Rollout
  • Replica Scale

Scripts

  • Annotations,Labels & Selectors
  • Kustomize (-k vs -f)
  • Apply/Create/Patch

Local Kubernetes Setup :

  • Docker for Desktop Mac
  • MiniKube

Tools

  • Kubernetes Dashboard - web UI for Kubernetes clusters
  • Kubectl and Proxy
  • Kubernetic Desktop - View Cluster Resources, Similar to Kitematic for Docker.
  • Sekret - Encryption Tool for Kubernetes Secrets YAML
  • Kamus - Encryption and Decryption solution for Kubernetes applications
  • Kubectx - Switch faster between clusters and namespaces in kubectl
  • kube-ps1 - Kubernetes prompt info for bash and zsh to see the current cluster context with namespace
  • Kubefwd - Bulk port forwarding Kubernetes services for local development.

Basic Commands

Contexts


# Get all contexts
kubectl config get-contexts 

# Get Current Context
kubectl config current-context


# Set the default context
kubectl config use-context nk-dev-cluster  

kubectl config set-context nk-dev --namespace=rafa-dev --cluster=docker-for-desktop-cluster --user=docker-for-desktop


Describe K8 Resources

# kubectl describe <resource> <resourceName>
kubectl describe pods pod1

# Get the resource definition in yaml
kubectl get pod my-pod -o yaml 

Expose a Service

#expose a app named web-app as a service 

kubectl expose deployment web-app --name=web-app --type=NodePort --target-port=8080


# For Testing Locally
kubectl port-forward servicename 8080:8080

Connect to the running Pod Container


kubectl exec web-app-fcc6b5ddf-k2txq -it -- /bin/sh

Troubleshooting


#Simple Container to quickly run some curl commands to the pods
kubectl run curl-test --image=radial/busyboxplus:curl -i --tty --rm

Thanks for reading this refresher.

Discussion

pic
Editor guide