Kubernetes Basics
What is kubernetes ?
This is an open source container orchestration tool used in automating deployment, scaling and the management of containerized applications. It is a tool developed by Google. They can also be referred to as K8s because it has 8 letters between the K and S.
Kubernetes solves the problem in applications by:
- Converting a monolithic application into a microservices.
- Increased the management of containerized application at scale which leads to high performance of the application.
- High availability of application which implies that no down time for the application.
- Disaster recovery.
Basic Components Of Kubernetes
kubernetes has a lot of components, but we will be discussing the most relevant components.
- Node: This is a physical or virtual server which host the applications
- Pod: It is referred to as the smallest unit in k8s which acts as an abstraction over a container.
- Service: This is a static IP-address assigned to a pod. The main advantage of service is due to the fact that the lifecycle of the pod is not connected to service, even if the pod crashes the pod will be able to communicate after being recovered using the service making our application to communicate with each other easily and thereby making it scalable.
- Ingress: This opens the communication between the node and external traffic.
- ConfigMap: External configuration of the application are stored here. They bind non-sensitive configuration environment to your pod container during run time.
- Secrets: This stores and manage sensitive data such as passwords, token or keys to be used by pod container during run time. They are usually stored in base64 encoded format.
- Volumes: This is a directory which contains datas that are accessible by containers. Datas includes database of an application. We can bind the volume of our kubernetes database to a local machine or a remote server for data persistence because k8s does not manage data persistence.
- Deployment: This takes care of replication of application for scalability, high availability also disaster recovery. It is the abstraction of pods. we mostly use this service in deployment.
- StatefulSet: This is the workload API object used to manage stateful applications with database.
Kubernetes Architecture
This is a built architecture designed in such that it offers a loosely coupled mechanism for service discovery across a cluster. It contains one or more control plane(s) and also one or more worker node(s).
- The control plane(s) manages the worker nodes and the pods in the cluster.
- The worker node(s) holds the pods that are in the component of application workload.
- Cluster contains both the control plane(s) and the worker node(s).
- Cluster = control plane(s) + worker node(s)
Now, let us look at the components of the worker node(s):-
- Container Runtime: This is the software that is responsible for running container.
- Kubelet: This is an agent that runs on each node in a cluster which makes sure that the containers are running in a pod.It does not manage the container which are not created by k8s.
- Kube-proxy: This is a network that runs on each nodes in your cluster, implementing kubernetes service concept. It ensures network communication of pods from network session inside and outside a cluster.
Also, let us take a look at the components of control plane(s)
- Api-Server: This is a cluster gateway and gatekeeper for orchestration of the cluster.
- Scheduler: This helps to watch over the newly created pods with no assigned nodes and then select a node for them to run on. The component of the worker node on which the scheduler interract with is the kubelet.
- Control manager: This helps to detect cluster state changes ranging from its nodes, jobs, endpoints and services.
- etcd: This is a key-value store of a cluster state. We can also refer it to as the cluster brain.