(Day 23) Task : Understanding Kubernetes From Monoliths to Microservices and Beyond:-

Aditya SharmaAditya Sharma
6 min read

Kubernetes, often referred to as K8s, has become a cornerstone of modern cloud-native application development. As organizations shift from traditional monolithic architectures to microservices, Kubernetes provides the tools to orchestrate, manage, and scale containerized applications efficiently. This article explores Kubernetes in depth, covering its origins, key concepts, installation processes, and its role in solving problems that plagued earlier systems. We'll also compare Kubernetes with Docker Swarm, list platforms and services for running Kubernetes, and highlight its powerful features.

Monolithic vs. Microservices Architecture :-

To understand Kubernetes' significance, we first need to grasp the architectural paradigms it supports: monolithic and microservices architectures.

Monolithic Architecture :

A monolithic application is built as a single, unified unit. All components—user interface, business logic, and data access layers—are tightly coupled and run as a single process. While this approach is straightforward for small applications, it has significant drawbacks:

  • Scalability Challenges: Scaling a monolith requires scaling the entire application, even if only one component needs more resources.

  • Maintenance Difficulty: A large codebase can become unwieldy, making updates and debugging complex.

  • Deployment Risks: A change in one module requires redeploying the entire application, increasing the risk of downtime.

  • Technology Lock-in: Monoliths often rely on a single technology stack, limiting flexibility.

Microservices Architecture :

Microservices break applications into smaller, independent services that communicate over APIs. Each service handles a specific function and can be developed, deployed, and scaled independently. Benefits include:

  • Independent Scaling: Scale only the services that need it, optimising resource use.

  • Easier Maintenance: Smaller codebases are easier to manage and update.

  • Technology Flexibility: Teams can use different languages or frameworks for different services.

  • Resilience: Failure in one service doesn’t necessarily bring down the entire application.

However, microservices introduce complexity in coordination, communication, and deployment. This is where Kubernetes shines, providing a robust framework to manage these distributed systems.

What is Kubernetes ?

Kubernetes (Greek for "helmsman" or "governor") is an open-source platform for automating the deployment, scaling, and management of containerized applications. Originally developed by Google, it was open-sourced in 2014 and is now maintained by the Cloud Native Computing Foundation (CNCF). Kubernetes abstracts the underlying infrastructure, allowing developers to focus on application logic rather than server management.

Why K8s ?

The term "K8s" is a shorthand for Kubernetes, derived by abbreviating the word to its first letter ("K"), last letter ("s"), and the eight letters in between ("ubernete"). This naming convention is common in tech for simplifying long names (e.g., i18n for internationalization). K8s has become the de facto standard for container orchestration due to its scalability, flexibility, and vibrant community.

Problems Before Kubernetes :-

Before Kubernetes, managing containerized applications posed significant challenges:

  • Manual Scaling: Scaling applications required manually provisioning servers or containers, a slow and error-prone process.

  • Downtime During Updates: Deploying updates often caused downtime, as there was no built-in mechanism for rolling updates or rollbacks.

  • Resource Inefficiency: Containers were often over- or under-provisioned, wasting resources.

  • Service Discovery and Load Balancing: Coordinating communication between containers across servers was complex.

  • Fault Tolerance: Handling node or container failures required custom scripts or manual intervention.

  • Environment Consistency: Ensuring consistent environments across development, testing, and production was difficult.

Kubernetes addresses these issues with a comprehensive set of features, making it a game-changer for containerized workloads.

Key Features of Kubernetes :-

Here are the key features of Kubernetes (K8s), based on its capabilities for managing containerized applications:

  1. Container Orchestration: Automatically schedules and deploys containers across a cluster, optimizing resource use and placement based on constraints like CPU and memory.

  2. Service Discovery and Load Balancing: Assigns a single DNS name to a group of containers (pods) and distributes traffic evenly, simplifying communication and ensuring high availability.

  3. Self-Healing: Detects and restarts failed containers, reschedules them to healthy nodes, and terminates unresponsive ones, minimising downtime.

  4. Horizontal Scaling: Scales applications up or down manually or automatically based on metrics like CPU usage, ensuring efficient resource allocation.

  5. Rolling Updates and Rollbacks: Updates applications without downtime by incrementally replacing old containers with new ones and allows easy rollbacks if issues occur.

  6. Storage Orchestration: Automatically mounts and manages storage (local, cloud, or network-based) for containers, supporting persistent data needs.

  7. Secret and Configuration Management: Securely handles sensitive data (e.g., passwords, API keys) and configuration settings separately from application code.

  8. Resource Monitoring: Tracks resource usage to optimize allocation, prevent over-provisioning, and ensure efficient cluster performance.

  9. Extensibility: Supports custom resources and controllers, allowing tailored solutions for specific use cases, like integrating with monitoring tools.

  10. High Availability: Ensures no downtime by distributing workloads across nodes and replicating critical components.

Kubernetes Platforms and Services :-

Kubernetes can be run on various platforms, from local setups to managed cloud services and physical infrastructure, offering flexibility for different needs:

Online Platforms (Local Development) :
  • Minikube: A single-node Kubernetes cluster for local development and testing, ideal for experimenting

  • Kind (Kubernetes in Docker): Runs Kubernetes clusters inside Docker containers, ideal for CI/CD pipelines, providing a lightweight option.

  • k3s: A lightweight Kubernetes distribution for resource-constrained environments like IoT or edge devices, ensuring efficiency.

Cloud-Based Managed Services :
  • Google Kubernetes Engine (GKE): Fully managed Kubernetes service on Google Cloud with auto-scaling and auto-upgrades, simplifying management .

  • Amazon Elastic Kubernetes Service (EKS): Managed Kubernetes on AWS, integrated with AWS services like IAM and VPC, offering seamless integration.

  • Azure Kubernetes Service (AKS): Managed Kubernetes on Microsoft Azure, with tight integration for Azure DevOps, enhancing DevOps workflows.

Kubernetes is deployed on Infrastructure as a Service (IaaS) by major providers like Amazon, Google, IBM, Oracle, Red Hat, Microsoft, SUSE, VMware, and Platform9, and supports Platform as a Service (PaaS) for handling infrastructure and operations tasks in cloud-native development

Kubernetes vs. Docker Swarm :-

  • Installation and Cluster Configuration :

    • Kubernetes: Complicated and time-consuming setup process.

    • Docker Swarm: Fast and easy setup.

  • Support for Container Types :

    • Kubernetes: Works with almost all container types (e.g., Rocket, Docker, containerd).

    • Docker Swarm: Works only with Docker containers.

  • GUI (Graphical User Interface) :

    • Kubernetes: GUI available (e.g., Kubernetes Dashboard).

    • Docker Swarm: GUI not available.

  • Data Volume Sharing :

    • Kubernetes: Data can only be shared with containers in the same pod.

    • Docker Swarm: Data can be shared with any other container in the cluster.

  • Updates and Rollbacks :

    • Kubernetes: Supports process scheduling to maintain services during updates, with health monitoring.

    • Docker Swarm: Supports progressive updates and service health monitoring during updates.

  • Autoscaling :

    • Kubernetes: Supports vertical and horizontal autoscaling.

    • Docker Swarm: Does not support autoscaling.

  • Monitoring Tools :

    • Kubernetes: Inbuilt monitoring tools available (e.g., integration with Prometheus).

    • Docker Swarm: Relies on third-party tools like Splunk for monitoring.

This list captures the key distinctions as presented on the whiteboard, reflecting Kubernetes' advanced capabilities versus Docker Swarm's simpler approach.

0
Subscribe to my newsletter

Read articles from Aditya Sharma directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Aditya Sharma
Aditya Sharma

DevOps Enthusiast | Python | Chef | Docker | GitHub | Linux | Shell Scripting | CI/CD & Cloud Learner | AWS