If you are here then you probably know Docker 😉
You faced many issues while deploying the those containers, ufff !
Don’t worry we know the pain, so does this Guide 😇
Let me address those issues first 👇
1. We manually need to check if container goes down and then restart it🤦♂️
2. During traffic spike, we need to manually increase no. of containers 🤥
3. There is no way to distribute load to different containers ☹️
But HEY WAIT !
These 3 problems are already addressed by Amazon ECS !!
If you aren’t familiar with Amazon ECS, it does address those issues.
So, Why we need Kuberentes then ? 🤯
To Lose Weight? 😂
While using Amazon ECS, there are ECS specific configurations needed to setup our deployment 🔧
In case we need to switch to different cloud, then these ECS config won’t work and again we need to change all config according to that cloud provider! 🤷♂️
Don’t get triggered, we know setting those config weren’t buttery 😂
Introducing Kubernetes : Just in case you were using Kubernetes, you could have used it’s config file for deployment in any other cloud provider supporting K8’s (kubernetes) 😎
Obviously if someone wants to stick with Amazon ECS or a single cloud provider then you don’t need Kubernetes 🤷♂️
But what does Kubernetes Do ?
Scaling & Load Balancing
Managing your Services for you
Above 3 points will be discussed completely. Don’t worry!
THINGS TO NOTE ✍️
1. Kubernetes is not a cloud Service Provider ! (It’s a open source project)
2. Kubernetes doesn’t replace Docker rather it works with Docker 👬
3. It can be used with any cloud provider which has K8’s support. If it doesn’t have you can manually download K8’s and use it there 🔥
4. It’s not a paid service, it’s FREE to everyone. Specific cloud provider can ask for money although for providing some features 💰
Ah! What’s Kubernetes in one line ?
Think it like Docker-Compose for multiple Machines 🚀
Some basic terms in K8’s 👇
✴️ You know Containers 📦 right? In K8’s we have Pod !
✴️ “Pod” is the smallest unit in Kubernetes.
✴️ A pod basically contains a container.
✴️ Although, pod can have more than one container which are related. (Mostly you will see one)
✴️ Pods are kept inside Worker Node 👉 which is basically a computer or a VM Instance.
✴️ Proxy/Config are inside Worker Node to help the pod with communication. These all are the terms you need to know!
✴️ We can have Multiple Worker Node having our pods or containers ✅️
✴️ Master Node (also a computer or VM Instance) is the one which controls all these Worker Nodes. (We will contact Master Node to control Worker Node).
✴️ Master Node can act as Worker Node if we want. (Not a good time to discuss this)
✴️ This Master Node + Worker Nodes => Cluster
Let’s assume you got it 😃
Ok, So to use Kubernetes What We need to do ? 🤔
🔶 We need to create the cluster and the nodes (Worker + Master).
🔶 Setup API Service, Kubelet(software) and other K8’s software on nodes.
🔶 Other resources like Load Balancers which might be needed.
If we will do all that then what will kubernetes do ? 😂
Kubernetes will :
🟢 Create Pods and manage them.
🟢 Monitor Pods and recreate, scale them.
🟢 use your given resources to apply your config file.
UNDERSTANDING WORKER NODE
✏️ Worker Node contains Pods
✏️ Pods can have single container or multiple containers (closely related).
✏️ A Single Worker Node can have multiple pods.
We already saw these 😴 WHAT ELSE IS THERE ?
✅️ Docker– Worker node have pods < inside which have container < now to run this container Docker is required, hence it must exist in Worker Node.
✅️ Kubelet – handles communication btw Master and Worker Node. Master gives command to Worker Node, so this is the place which listens to command from Master node.
✅️ Kube-Proxy – Helps to create network for pods. I mean obviously pod needs to communicate with other pods or communication to outside world (browser), kube-proxy will do the networking thing for us.
UNDERSTANDING MASTER NODE
Lets see what all Master Node has 😃👇
✳️ API Server: Communication with Kubelet – present in Worker Nodes, discussed above.
✳️ Scheduler – Watches for any command for running new pods, it then selects Worker Nodes to run them. (It chooses that Worker Node which has more resources)
✳️ Kube-Controller-Manager – Watches and controls Worker Node, it will always keeps a check if correct no. of pods are running on them.
✳️ Cloud-Controller-Manager – It’s work is similar like Kube-Controller discussed above but this one is specifically for a cloud provider.
Remember!! you will always be contacting Master Node.
Kubernetes Control or kubectl will help you to do that 😉
CORE COMPONENTS In K8’s
When we say Core Components it’s nothing but the things we already discussed above. Let’s have a look 👇
🔷 Cluster: A set of Master Node + Worker Nodes.
🔷 Nodes: Physical / Virtual Machines which will carry the pods. There were two different types of Nodes we saw. Those were:
🔹 Master Node : Has a Cluster Control Plane( Basically a process that runs in there which controls the entire nodes ) -> we saw Master Node in detail above, not going in depth again ! 😴
🔹 Worker Node : Hosts Pods or basically contains the containers (or services).
🔷 Pods : Holds actual running container + it’s resources (volume) -> you must already know about volume if you had hold it till here 🙂
🔷 Services : A logical set of Pods with a unique, Pod – and container independent IP.
BUT HEY WAIT ! 😳
So to use Kubernetes => we need Kubernetes Cluster => and for that we atleast need 2 nodes(Machines) ? => I mean 1 for Master Node and 1 or more for Worker Nodes ?
where to get so many machines from ? 🙂
If you remember we have mentioned node as machine OR VM(Virtual Machines).
And we know we can run multiple VM on our system, so 1 machine can work as Master Node and 1 as Worker Node. 😎💯
So, everything boiled down to creating just those 2 VM’s and we are ready to do anything on K8’s ? 😮
☝️ YES! Wohhoooo 🎉🥳
But, can you also explain or Step by Step Guide for creating those 2 VM’s ☺️ ?
Introducing ” Minikube “
This will do everything to setup the cluster on your system ! 🥳
Minikube – can be used to setup a cluster in our system (it’s a single node cluster so both Master and Worker Node are in the same system).
BUT What Next ? Cluster is Created but how to send commands to it to create pods/ containers and all ? 🤔
Kubectl needs to be downloaded => this will help you to send commands to your cluster created ! 👍
⚠️ NOTE: Kubernetes works with “Objects” like => “Pods“, “Deployments“, “Service“, “Volumes“, we are currently talking about just “Pods”, but as we move forward everything will come into picture!
Pods Pods Everywhere !
🟢 Pods have a internal cluster IP address.
🟢 Container inside pod can communicate via “localhost“.
🟢 For PODS TO BE MANAGED – a “controller” is required which will manage these pods => this controller is called “Deployment“.
🟢 Pods are designed to be “non persistent” => k8’s will start, stop & replace them as needed.
✅️ Generally, we don’t use Pods directly => but rather “Deployment” => It helps to control Pods and scale them !
✅️ Our work here is limited to providing the end state to get the desired state. Means to create containers and how many containers, we just need to let deployment know about it and rest it takes care !
So, we just have to tell Master Node the state to achieve through a “yaml” file and rest everything is managed on it’s own ? 🤩
YES ! Wohooo 🎉🥳
uff ! Lots of stuff 🥴
Just in case you didn’t skipped any line in this Blog, you already know the things to kickstart the Kubernetes Journey ! 🤩
We mostly need to know about the commands now ! 😇👍
But again a lot to learn, We will be covering remaining in Part 2 !
Be Tuned 💜
Checkout this Kubernetes Book if you want to become a Guru in K8’s 😇
We are following a trend we are building. Hop in if you have the power of words 🔥
Please leave your comments below 😃✌️