Kubernetes Series | Part 1 - Basic Components.

Part 2 of the series can be found here
part 3 of the series can be found
here

From its official site

Kubernetes, also known as K8s, is an open-source system for automating deployment, scaling, and management of containerized applications

It groups containers that make up an application into logical units for easy management and discovery. K8s is developed by Google.

  • K8 is a Opensource, Container Orchestration Framework/tool.
  • Means, K8s used to manage the applications made up by hundreds/thousands of containers in different deployment environments like physical machines, cloud machines etc.

Need of Container Orchestration tool:

  • Usage of microservices increased the possibility of container technologies. Because containerization is the best way to host the small, independent services known as micro-services.
  • Now the raise of containers usage due to the micro-service architecture resulted that each application is depends on hundreds/thousands of containers.
  • Managing these high amount of containers in different environments using script/self made tools is not easy anymore. This actually cause the real need for the orchestration tool that manages the containers of the application. Managing here means giving High Availability, Scalability and Disaster recovery to the applications.

Here comes Kubernetes. Now, lets learn the basic components of K8s.

Pods:

  • Pods are the smallest/basic unit you can create and manage in K8s. Pod is group of one or more containers with shared storage and network resources, have a specification on how to run the containers.
  • Pods are something like a abstraction layer on top of the containers, creates the running environment for them. The abstraction is enforced by K8s because we only need to interact with Its own layers but not with the actual containers. Means that, Existing container images in the Kubernetes can be replaced by any other technology containers easily.
  • Usually one container per Pod is the default scenario unless when the main application needs some small services(tightly coupled) which can be run in the same Pods.

Nodes:

  • Pods runs on a Node. Node is a worker machine either virtual/physical servers. A node can have multiple Pods. K8s master automatically handles scheduling the pods across the Nodes in the cluster.
Image from official website

As seen in the above image, Node consists many Pods. Pods are having its own internal IP address which will be used to communicate between each other. Every Pods having their own storage and container images to be run. These IP address will be static/permanent. When specific Pod is not running, A new pod will be created with the same IP so that the connection configuration no need to be changed.

  • Kubelet, responsible for communication between the Kubernetes Master and the Node; it manages the Pods and the containers running on a machine.
  • There is a components named Service & Ingress plays important role. Service used to give static IPs to the Pods. All the requests from the outside world to your application domain will be coming to Ingest first. Then this Component will forward the the requests to the specific requested Pod.

Till now we have seen very basic components of K8s. We yet to see the real cool features of it.

Config Map & Secret:
Pods can connect to each other using Service feature. To make this connection, logically there should be somewhere the configurations needs to be stored right ? The man is named as configMap.

  • Config Map is an Object used to store non-confidential data as a key-value pair.
  • Pods use this Map to access between each other. This config map can be used as environmental variables, command-line arguments or a configuration files.
  • This config Map allows you to decouple the configuration from your containers to make sure the containers are portable. For example, in your application, you need to replace your Sqlite3 database with Mongo-db database. For this change, you just need to change in the ConfigMap and place your container in the Node and nothing else.
  • Placing secret information like database connection details in ConfigMap is not advisable because this is just a plain text, no encryption applied to the data. For storing this, we can use Secret component.

Volume:
The data our application generating should be persistent, means when container gets restarted, data should not lost. Volumes is the component to achieve that. This can store the data in local machine means the node where the Pod running or to the remote storage outside the K8s cluster (both cloud storage or own storage cluster).

What if my application Pod dies?
Lets take my application Pod is dead and my user accessing it, it shows site cant reachable which is not good thing. To make sure this is not happening, everything in K8s is replicated. Means that, the application pod will be replicated to the another Node based on the configuration we provide. All these replicated Pods connected to the same service(remember IP is permanent). So replicated Pods also can be accessed with the same IP. Service component also does the Load balancing with these replicas.

Deployments:
Deployments are the blue-prints for the Pods. We create deployments to give updates regarding Pods and replicas. We know that, Pods are the abstraction layer for the container images. Deployments are kind of abstraction layers for the Pods. So in practice, most of the time we will work with Deployments not with Pods. With this Deployment, we can replicate the application Pods but not the Database Pods. Because database has state means data. if we replicate the DB Pod, inconsistency between the replicas may occur. StatefulSet is another component is K8s for this purpose.

So all the database applications should be created using StatefulSet but not with Deployments. Statefulset will take care the database is synchronized with the service and its replicas. But, doing this is not so easy in K8s. Common practice is running the database application outside the K8 cluster.

Summarize:

  • Pod component is an abstraction layer for the container image(s) which run in the Node(server). One or more Pods can run in the server.
  • Service component is used to have the communication between the Pods.
  • Ingress component is route the traffic to the K8 cluster.
  • Configuration for the Pods can be stored in the ConfigMap and Secrets.
  • Data storage is happening using Volumes component.
  • Deployments & Statefulsets are for Pods replica configurations.

Yes, there are lot of components available in K8s. But these are very important to start with. With these, we can built very powerful k8s cluster. That’s it for now on the basic components. Will meet you with the Architecture of K8s soon. ta ta.

Regards,
Gobalakrishnan Viswanathan

Yet another Pythonic-Automation guy.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store