- Containers help to package an application, it’s required libraries and dependencies to run it in any environment.
- It simplifies the packaging and distribution of application and have become increasingly popular as organizations shift to cloud-native development and hybrid multi-cloud environments.
- If i have a web application which needs a java runtime, web server, database and message queue , without containers i will have to install each of the dependencies in every environment and deploy the application code to execute it. This, not only is a time taking and tedious process but if the versions of required libraries are different in each environment, it could lead to inconsistent behavior of applications.
- With containers, i can now package all the required dependency application code in a container and can just ship it .
- In order to run this application all you need is a container run time engine. As all the dependencies required to run the application are already packaged in the container, there will not be any issues of inconsistent behavior due to difference in environment and you don’t have to go through the process of installing each dependencies.
- That is the value which a container technology like Docker brings . It provides features to build, deploy, package and manage an application and it’s dependencies in a standard way.
- But containers only solves the problem of packaging and distributing the application. Enterprise applications should be scalable and run on multiple servers and communicate with each other to serve user requests.
- If you have 4 or 5 servers, how do you deploy these containers efficiently to minimize server disruption and use the resources effectively. If the application does machine learning then how do you pick the server with dedicated GPUs amongst all of the available ones.
- Containers are linux process and by default they cannot connect to other processes running on other servers, so how will these containers running on different servers talk to each other.
- This is what Kubernetes or the container orchestration tool does at a high level. It abstracts the underlying physical servers and helps to efficiently deploy these containers across servers and provides a unified API layer over this infrastructure to efficiently manage these containers.
- You can specify the CPU and memory requirements for your containers and Kubernetes has the algorithm to pick the right infra to deploy these containers.
- It abstracts the underlying infrastructure and acts as the layer through which we can consistently communicate with the infrastructure and manage the container deployment lifecycle
- Kubernetes is the bridge to communicate with the underlying infrastructure and therefore a developer doesn’t have to worry about the difference of cloud in a multi cloud environment as it abstracts it.
- It provides a unified network across the fleet of servers so that containers can communicate with each other no matter where they are deployed.
- It also provides features to roll out updates with zero downtime or if a deployment fails then Kubernetes can roll back the deployment to the previous state.
- You interact with Kubernetes using APIs, for example if you want to deploy a container you call a REST API and upon receiving the request , kubernetes finds the right place for the container to be deployed and deploys it.
- When we deploy an application, we have a router or a public load balancer which then routes the traffic to an internal load balancer and then finally the request reaches the application
- In Kubernetes , the applications are called pods, internal load balancer are services and the router is called ingress
- The traffic that flows to your application or pods has to be first processed by the router and then by the internal load balancer.
- These pods are not deployed manually. A Kubernetes Deployment is used to tell Kubernetes how to create or modify instances of the pods that hold a containerized application.
- Deployments can scale the number of replica pods, enable rollout of updated code in a controlled manner, or roll back to an earlier deployment version if necessary.
- Pods, Deployments, Services and Ingresses are the basic building blocks for deploying apps in Kubernetes.
- You write a YAML file to describe the components of your setup Pods (applications/containers), Services (internal load balancers), Ingresses (external local balancers), Deployments (resource to monitor Pods) and submit to the Kubernetes API.
Thank You ! Please share your comments / feedback.
9 thoughts on “What is Kubernetes and why do you need it ?”
Great article!!! Your content is written in such a way that it creates a desire to keep reading on until the blog is complete. Easy to understand and knowledgeful!!
Thanks a lot for these kind words 🙂
Simple yet effective .. keep sharing !!
Thanks for the constant support and encouragement !!
It’s a great article Rajesh and easy steps to understand a vast concept of Kubernetes with pictorial representation. Kudos to you and looking forward for new posts
Suggestion: Please try to add few more diagrams or examples which explain how Kubernetes works in real time and also difference between Kubernetes and Fargate (may be a new blog). Ignore if not relavent
Thanks Naga. Feedback taken on images,
On the topic of difference between Fargate and K8, Fargate is also a container orchestration tool does the task of deploying and managing containers. Some more details on fargate internals – https://aws.amazon.com/blogs/containers/under-the-hood-fargate-data-plane/
Great Article and simple to understand!!! The way the concept was explained any one can understand with little to vast experience too. Keep going Rajesh bhai and looking for a new blog soon.
Interesting article, thank you. Could you tell me about the second paragraph in more detail?