Praveen Deshpande

Just a guy trying to make sense of things as he goes.

K8s Log #1 - Setting Up a Local Cluster and Surviving the Confusion

It has been a week learning Kubernetes. I wanted to share few bits of what I understood so far in this post.

Oh and also the anxiety of "Why spend weeks learning what AI spits out in seconds?" is real! but, I'm pushing myself hard on this because execution can be done by AI but the thought process and the engineering decisions are supposed to be done by me. I have shared my view on AI in the previous post - check it out!. AI is a great sidekick, just don't hand it the wheel. Or the keyboard. Or the cluster. 😬

1. Architecture of Kubernetes

k8s-architecture

  1. Everything first hits API server and API server is responsible to communicate to other control plane components. This is the ONLY guy who does the talking to everyone in control plane - no components talk to each other directly (they don't like each other 😜), everything is told to API server and API server further communicates with other components. Think of it as that one manager in office who insists all communications must go through them. Annoying, but it keeps things from falling apart.
  2. etcd -> Kinda like NoSQL DB that holds all the activity history (etcd stores data as simple pairs of keys and values) and this is LIKE version control (Git), it keeps a history of changes or revisions rather than overwriting. It's like that one person in the team who has written down everything in a notebook since day one. Meetings, decisions, who said what.. So the API server is like, why go knocking on every node's door? Let me just ask etcd.
  3. Topics yet to learn further - Controller Manager and Scheduler in depth but in general (this may not be completely accurate - this is just my understanding):
    • Scheduler is constantly on the lookout for newly created pods that have no node assigned and finds the best physical or virtual machine (node) for them to run on. Basically a seating arrangement manager at a wedding - always figuring out who goes where.
    • Controller Manager has controllers running continuously in the background monitoring the current state of the cluster. Let's say your config says minimum 3 replicas must be running and 1 goes down (3-1=2, desired is 3) - Controller Manager will immediately tell the API server to spin up another one. Basically it will make sure your desires are met 😝

2. Pod creation (2 ways):

  1. Imperative: directly run commands to create components - works, but good luck remembering what you typed six months later.
  2. Declarative: using a config file (JSON, YAML) to create components - the prod way. Write it once, version it, forget about it until something breaks at 2am.

3. My setup:

  1. Package manager is Chocolatey - most of the tools and softwares I installed below was using Chocolatey. Windows users, this is your apt-get. You're welcome.
  2. The setup requires containers so I installed Docker Desktop
  3. I'm using Kind (short for K8s IN Docker) to setup K8s, there are plenty like Minikube, K3s, Kubeadm (the OG), etc.. but I chose kind as it'll allow me to create multi nodes setup unlike Minikube - what do I mean by this?? It's like a studio apartment - kitchen, bedroom, living room all in one. Kind actually gives you separate rooms. Feels more like the real thing.. i.e. I can create control plane and worker nodes separately in Kind where as Minikube it's all-in-one control plane and worker nodes.
  4. To talk to the cluster I use Kubectl - you may have to download it separately. Why you ask? Kind sets up the cluster. Great. Now try talking to it without Kubectl. You can't. It's like building a server room and then realising you forgot to plug in the keyboard. The cluster exists, you just have no way to say anything to it.

4. References

  1. Kind: https://kind.sigs.k8s.io/docs/user/quick-start/
  2. Kubectl Cheatsheet: https://kubernetes.io/docs/reference/kubectl/quick-reference/

This is my understanding for now.. this is the condensed version of whatever I understood so far, I'm more of a hands-on guy so, I did few labs and setup K8s in my local now.. will comeback with few more stuff soon..

Anything on your mind - questions, topic ideas, random thoughts - I'm open to all of it

tech, kubernetes, k8s-log

⬅ Previous post
AI as a Sidekick and Devs Need to Stay in the Driver's Seat

Next post ➡
Recovering from an accident

Subscribe for more!

You don't have to keep coming back here to read my latest posts. Subscribe via RSS to get updates whenever I publish something new.