Kubernetes (K8) Use Cases, Pros and Cons
Kubernetes is an open source system for automating deployment, scaling and management of containerised applications. It has become increasingly popular and widely adopted over the past decade.
As part of my own personal development and upskilling I decided to learn more. I completed a course, spun up an old Linux box to get my hands dirty. I also did some of my own research.
My intention was to learn the tool, so I could use it if required, and also to understand it better from a solution design and architectural view point.
The result is this brief article, in which I will cover;
What is Kubernetes?
What use cases might it suit?
What are the pros (advantages) and cons (disadvantages)?
When might you NOT use Kubernetes?
What is Kubernetes
Kubernetes comes from a Greek word, which means helmsman or ship pilot. Which is rather apt as Kubernetes is an orchestration tool that supports many different container based deployments such as; Docker Engine, CRI-O, Containered, Migrants (Docker Enterprise), and Kublet to name but a few.
Within these containers are hosted applications bundled in with the necessary runtime environments, which means they can run in isolation and take up minimal resources.
Some of its main features include:
Self-healing
Restarts containers that fail, replaces and reschedules containers when nodes die, kills containers that don't respond to your user-defined health check, and doesn't advertise them to clients until they are ready to serve.
Horizontal scaling
Scale your application up and down with a simple command, with a UI, or automatically based on CPU usage.
Service discovery and load balancing
No need to modify your application to use an unfamiliar service discovery mechanism. Kubernetes gives Pods their own IP addresses and a single DNS name for a set of Pods, and can load-balance across them.
Automated rollout and rollbacks
Kubernetes progressively rolls out changes to your application or its configuration, while monitoring application health to ensure it doesn't kill all your instances at the same time. If something goes wrong, Kubernetes will rollback the change for you. Take advantage of a growing ecosystem of deployment solutions.
Kubernetes was developed by Google and was donated to the Cloud Native Computing Foundation (CNCF). It is also sometimes referred to as K8.
Since its release in 2014 Kubernetes has become a fundamental tool in the infrastructure space and it has a healthy ecosystem with new and improved tooling that is continuing to evolve.
The Control Plane manages the overall state of the K8 instance. This includes a key value store (ectd), a Scheduler, an API Server and a Controller Manager.
Kubernetes also use lots of different controllers, a type of object in Kubenetes, to manage the particular elements of cluster state. For example the Deployment and Job controllers come built in. You can also build your own controllers and many third parties have done this to extend new functionality.
An optional “Cloud Controller Manager” can be run to embed specific cloud control logic. This decouples the interoperability logic between Kubernetes and the underlying cloud provider.
The Node container runtime include a daemon Kublet agent that manages the the pods; it makes sure they are healthily, and deploys or kills off instances if required or requested.
Kubernetes use a ‘hub-and-spoke” API patten. All API usage from the nodes (or pods they run) terminates at the API server.
Kubernetes can be accessed by the command line KubeCLI and via HTTPS using the API Server endpoint. The control plan can also be accessed via GUI interfaces such as the dashboard addon, which presents users with a web UI.
Kubernetes Use Cases
The main three use cases I can see for Kubernetes are;
Useful for when multi cloud deployment is a requirement
Packaging your application in containers and using an orchestration tool improves portability and enables you to deploy instances across several cloud providers
This can simplify multi cloud or hybrid deployments
Hosting of applications with long running jobs
Kubernetes is well suited for hosting AI, ML and Big Data workloads. It supports GPU acceleration and distributed computing
There are no limitation on run time execution and and resource intensive workloads can be efficiently managed
Jobs can be scheduled and you can automate backups and data synchronization
Hosting of applications with specific bundling dependencies
Nodes and the pods contained within them can be set up to group specific containers using names spaces. Containers hosted in a pod together will share the same IP and access to external dependencies, whilst also being able to communicate with each other (see below).
A Service can be used to enable specific network access.
The init containers can be used to ensure specific dependencies are available on start up
Pros (Advantages) of Kubernetes (K8):
Open source and backed by major players
Mature ecosystem and supported by the main cloud providers
Advanced load balancing and deployment capabilities
Supports self healing and resilience based patterns
Enables portability and scaling
Below are diagrams that highlight the some of the deployment capabilities and practices Kubernetes supports;
Cons (Disadvantages) of Kubernetes (K8):
Time consuming to learn and administer
Potentially another complex abstraction in your architecture
Sought after and advanced skill to train or hire for
When might you not use Kubernetes?
Kubernetes is great for creating portable and scalable applications. If your use case requires it’s features, then it is worth investing in the toolset.
If you are building something event based with a swift execution time, then consider something simple, like using other cloud native technologies such as serverless functions.
If you are using a single cloud provider, then you might want to leverage the tools they have on offer for supporting scalability and resilience.
By using Kubernetes you are introducing a new an infrastructure based abstraction. Be sure it is the right choice for our organisation and use cases.
Learning and administering Kubernetes takes time. If you introduce it into your ecosystem and making it part of your architecture, then everyone will need to learn the toolset (development usage, administration and security). Everyone will need to become a K8 administrator to varying degrees, which is an investment in time for learning and upskilling.
In some ways Kubernetes is like it’s own cloud based platform, with an eco system and toolset that happens to be supported by most cloud provides and can be hosted on prem. It can be a great way to stay vendor agnostic if that is important to you, with the trade off being additional complexity.
Want to try out Kubernetes for yourself?
Checking out the Hello Minikube tutorial on the main Kubernetes website. There are also some free course you can try.
Be sure to avoid running Kubernetes on a Windows 11 Home operating system. Instead I would use a Linux box if you have one, or spin up a Linux VM in the cloud. Just be sure you pick on that supports virtualisation (Azure / AWS). Gist of useful commands.