Why (and when) you should use Kubernetes
Tags: kubernetes, devops, programming, productivity
Published: 2022-12-19 18:46:13

Kubernetes is a powerful container management tool that automates the deployment and management of containers. Today, Kubernetes (k8’s) is a popular trend in cloud computing, and it’s easy to see why as businesses migrate their infrastructure and architecture to reflect a cloud-native, data-driven era.

Whether you’re a developer, data scientist, product manager, or something else, it won't hurt to have a little Kubernetes knowledge in your back pocket. It's one of the most sought-after skills by companies of all sizes, so if you're looking to gain a new skill that will stay with you throughout your career, then learning Kubernetes is a great option.

**Today, we will go over:**
* [Why you should use Kubernetes](#why)
* [When you should/should not use Kubernetes](#when)
* [What to learn next](#next) 

![Why kubernetes](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m6q6n1r8c15kbmkfdepg.png)

<a name="why"></a>

## Container orchestration

Containers are incredibly helpful! They provide you with an easy way to package and deploy services, allow for process isolation, immutability, and efficient resource utilization, and are lightweight in creation.

But when it comes to actually running containers in production, you can end up with dozens, even thousands of containers over time. These containers need to be deployed, managed, connected and updated; if you were to do this manually, you’d need an entire team dedicated to this.

It’s not enough to run containers; you need to be able to:
* Integrate and orchestrate these modular parts
* Scale up and scale down based on the demand
* Make them fault tolerant
* Provide communication across a cluster

You might ask: aren’t containers supposed to do all that? The answer is that containers are only a low-level piece of the puzzle. The real benefits are obtained with tools that sit on top of containers — like Kubernetes. These tools are today known as container schedulers.

<br>

## Great for multi-cloud adoption

With many of today’s businesses gearing towards [microservice architecture](https://www.educative.io/blog/microservices-architecture-tutorial-all-you-need-to-get-started?eid=5082902844932096), it’s no surprise that containers and the tools used to manage them have become so popular. 

Microservice architecture makes it easy to split your application into smaller components with containers that can then be run on different cloud environments, giving you the option to choose the best host for your needs. 

What’s great about Kubernetes is that it’s built to be used anywhere so you can deploy to public/private/hybrid clouds, enabling you to reach users where they’re at, with greater availability and security. You can see how Kubernetes can help you avoid potential hazards with “vendor lock-in”.

<br>

## Deploy and update applications at scale for faster time-to-market

Kubernetes allows teams to keep pace with the requirements of modern software development. Without Kubernetes, large teams would have to manually script their own deployment workflows. 

Containers, combined with an orchestration tool, provide management of machines and services for you — improving the reliability of your application while reducing the amount of time and resources spent on DevOps.

Kubernetes has some great features that allow you to deploy applications faster with scalability in mind:
* **Horizontal infrastructure scaling:** New servers can be added or removed easily.
* **Auto-scaling:** Automatically change the number of running containers, based on CPU utilization or other application-provided metrics.
* **Manual scaling:** Manually scale the number of running containers through a command or the interface.
* **Replication controller:** The replication controller makes sure your cluster has an equal amount of pods running. If there are too many pods, the replication controller terminates the extra pods. If there are too few, it starts more pods.
* **Health checks and self-healing:** Kubernetes can check the health of nodes and containers ensuring your application doesn’t run into any failures. Kubernetes also offers self-healing and auto-replacement so you don’t need to worry about if a container or pod fails.
* **Traffic routing and load balancing:** Traffic routing sends requests to the appropriate containers. Kubernetes also comes with built-in load balancers so you can balance resources in order to respond to outages or periods of high traffic.
* **Automated rollouts and rollbacks:** Kubernetes handles rollouts for new versions or updates without downtime while monitoring the containers’ health. In case the rollout doesn’t go well, it automatically rolls back.
* **Canary Deployments:** Canary deployments enable you to test the new deployment in production in parallel with the previous version.

## Better management of your applications

Containers allow applications to be broken down into smaller parts which can then be managed through an orchestration tool like Kubernetes. This makes it easy to manage codebases and test specific inputs and outputs.

As mentioned earlier, Kubernetes has built-in features like self-healing and automated rollouts/rollbacks, effectively managing the containers for you.

To go even further, Kubernetes allows for declarative expressions of the desired state as opposed to an execution of a deployment script, meaning that a scheduler can monitor a cluster and perform actions whenever the actual state does not match the desired. You can think of schedulers as operators who are continually monitoring the system and fixing discrepancies between the desired and actual state.

## Overview/additional benefits

* You can use it to deploy your services, to roll out new releases without downtime, and to scale (or de-scale) those services.
* It is portable.
* It can run on a public or private cloud.
* It can run on-premise or in a hybrid environment.
* You can move a Kubernetes cluster from one hosting vendor to another without changing (almost) any of the deployment and management processes.
* Kubernetes can be easily extended to serve nearly any needs. You can choose which modules you’ll use, and you can develop additional features yourself and plug them in.
* Kubernetes will decide where to run something and how to maintain the state you specify.
* Kubernetes can place replicas of service on the most appropriate server, restart them when needed, replicate them, and scale them.
* Self-healing is a feature included in its design from the start. On the other hand, self-adaptation is coming soon as well.
* Zero-downtime deployments, fault tolerance, high availability, scaling, scheduling, and self-healing add significant value in Kubernetes.
* You can use it to mount volumes for stateful applications.
* It allows you to store confidential information as secrets.
* You can use it to validate the health of your services.
* It can load balance requests and monitor resources.
* It provides service discovery and easy access to logs.

<a name="when"></a>

![No Kubernetes](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ha9icodifj222r0xebyz.png)

## When you should use Kubernetes:

<br>

### If your application uses a microservice architecture

If you have transitioned or are looking to transition to a microservice architecture, then Kubernetes will suit you well because it’s likely you’re already using software like [Docker](https://www.educative.io/blog/docker-kubernetes-beginners-guide?eid=5082902844932096) to containerize your application.

<br>

### If you’re suffering from slow development and deployment

If you’re unable to meet customer demands due to slow development time, then Kubernetes might help. Rather than a team of developers spending their time wrapping their heads around the development and deployment lifecycle, Kubernetes (along with Docker) can effectively manage it for you so the team can spend their time on more meaningful work that gets products out the door.

<br>

### Lower infrastructure costs

Kubernetes uses an efficient resource management model at the container, pod, and cluster levels, helping you lower cloud infrastructure costs by ensuring your clusters always have available resources for running applications.

<br>

## When you shouldn’t use Kubernetes:

<br>

### Simple, lightweight applications

If your application makes use of a monolithic architecture, it may be tough to see the real benefits of containers and the tool used to orchestrate them. 


That’s because the very nature of a monolithic architecture is to have every piece of the application intertwined — from IO to the data processing to rendering, whereas containers are used to separate your application into individual components.

<br>

### Culture doesn’t reflect the changes ahead

Kubernetes notoriously has a steep learning curve, meaning you’ll be spending a good amount of time educating teams and addressing the challenges of a new solution, etc. If you don’t have a team that’s willing to experiment and take risks, then it’s probably not the choice for you.

<br>

<a name="next"></a>

## What to learn next?

Overall, Kubernetes boasts some pretty great features that can have a positive impact on your developing/DevOps teams and for the business as a whole. 

If you’re looking to get started with Kubernetes, you can check out **[A Practical Guide to Kubernetes](https://www.educative.io/courses/practical-guide-to-kubernetes?eid=5082902844932096)**, written by Viktor Farcic, a Developer Advocate at CloudBees, a member of the Google Developer Experts.

This course will help you get familiar with all the basics of Kubernetes through hands-on practice. You'll start with the fundamentals of Kubernetes and what the main components of a cluster look like. You'll then learn how to use those components to build, test, deploy, upgrade applications, and secure your deployments.

<br>

### Continue reading about Kubernetes and DevOps on Educative
* [Kubernetes Tutorial: Getting Started with Container Orchestration](https://www.educative.io/blog/kubernetes-tutorial?eid=5082902844932096)
* [Getting started with Docker and Kubernetes: a beginners guide](https://www.educative.io/blog/docker-kubernetes-beginners-guide?eid=5082902844932096)
* [Microservices Architecture Tutorial: all you need to get started](https://www.educative.io/blog/microservices-architecture-tutorial-all-you-need-to-get-started?eid=5082902844932096)

### Start a discussion
What is your favorite use of Kubernetes in the tech industry? Was this article helpful? Let us know in the comments below!