Kubernetes
Kubernetes
Architecture:
Master Node: The master node controls the cluster and worker nodes host the
running applications. Each node in the Kubernetes cluster plays a specific role and
runs various components to ensure the proper functioning of the system
o API Server: It’s the entry point to Kubernetes cluster. It exposes the Kubernetes
API, which allows users and other components to interact with the cluster.
Worker nodes:
POD: Smallest unit of Kubernetes
Its an abstraction over container
When pod runs it create a layer over the container to run container runtime
Here in Kubernetes we only interacts with pod layers
Best case scenarios always prefers to run one container (in short your
application)
Inside single POD. Although you can have multiple containers running inside
a POD.
There’s a virtual network set-up in Kubernetes that runs and ensure each
pod do have its own IP. By using this internal IP address PODs can
communicate with each other
If a POD stops working then Kubernetes replace it with newly created POD
along with new IP address
Service:
it’s a permanent IP address that can be attached to each pod.
Lifecycle of service and POD are totally independent. Even if POD dies
service with IP address stays.
Another working is it acts as loadbalancer
Volume:
Its an external storage attached to the POD
This storage could be any remote storage, cloud storage, local storage
Lets say if you have database running inside the POD and it gets restarted
then in order to maintain replica of storage for the safer side we use
volumes.
Because Kubernetes doesn’t ensure persistent data storage
Deployments:
Here in Kubernetes in order to ensures high availability we replicate PODs
Now PODs are actually running on some servers. But in order to maintain
copies of POD we don’t actually create PODs but just BLUEPRINTS of existing
PODs architecture. And blueprints are knows as Deployment
BUT in case of a POD containing database we can’t create Deployment for it
because Databases do have states ( STATE of data). It can lead to data
consistency
So for PODs contains databases we create STATEFULSETS. Statefulsets makes
sure the database reads and writs are synchronized.
So generally its preferable to have database outside of Kubernetes
architecture where we can easily manage deployments
Kubelet: It interacts with the API server (running in Masterode) to manage the PODs
It also reports back to API server about PODs states , worker node state.
KubeProxy: It is a network proxy that runs on each Worker node and maintains
network connectivity of PODS. Also manages the routing , Loadbalancing between
the PODs.
Kubernetes Configuration:
Kubernetes always tries to maintain a balance between Current state and Desired state (what we
have mentioned in specification file). All these info comes from etcd
Kubectl is command line tool for Kubernetes