From Docker Hurdles to Kubernetes Solutions: Bridging the Gap

Namrata Gurufale
TechVerito
Published in
6 min readDec 19, 2023

Introduction to Containers and Docker

Containerization involves packaging an application with all its dependencies like frameworks and libraries to make it run efficiently and without bugs.

Applications can run efficiently in different environments with Docker containers. It provides advantages such as being lightweight, occupying less space, running in isolation, being portable, and having a short boot-up time.

If you’re not familiar with these concepts, I recommend checking out this link for an introduction:

Understanding Docker Limitations

Docker provides a simple and minimalistic platform for containerization, but it has its limitations:

  1. Ephemeral Nature: Containers are single-host in nature. If the host doesn’t have enough memory, no new containers can be created, or existing ones may fail.
  2. Auto Healing Challenges: If the container gets terminated or experiences failure within Docker, it necessitates manual intervention to restart or rectify the issue. Docker lacks automatic processes to seamlessly heal or recover containers, which can impact application availability and reliability.
  3. Manual Scaling for Increased Demand: When confronted with increased traffic or a surge in user count, Docker’s scaling mechanisms rely heavily on manual actions. This entails the manual creation of additional containers and load balancing setup to manage the augmented workload.

Introducing Kubernetes

The limitations faced in containerization find effective resolutions within Kubernetes, often abbreviated as K8s, which operates as a cluster comprising multiple nodes. Although a developmental setup might consist of only one node, Kubernetes is implemented as a cluster in production environments.

Key features defining Kubernetes’ prowess include:

  1. Replication Controller/Replica Set: This feature allows seamless scaling by managing the number of replicas of a particular application. When confronted with increased traffic, Kubernetes efficiently adjusts the count of application instances, ensuring optimal performance.
  2. Horizontal Pod Autoscaler: Kubernetes introduces automatic scaling capabilities. It intelligently monitors the workload and, upon detecting an elevated load surpassing a predefined threshold, autonomously creates additional containers to accommodate the increased demand, maintaining consistent performance levels.
  3. Auto Healing Mechanism: In the event of a container failure, Kubernetes demonstrates its resilience. The Kubernetes API server immediately identifies the failure and initiates the deployment of a new container instance, ensuring continuous application availability without manual intervention.

Deep Dive into Kubernetes Architecture

Kubernetes architecture consists of two main sections — the Control Plane and the Data Plane.

1. Control Plane (Master Node):

The Control Plane components manage and regulate the cluster’s state and operations

API Server:

  • It serves as the control hub and handles all communication for Kubernetes.
  • Receives REST requests, validates, processes, and stores API objects (manifests defining the cluster’s desired state).

Scheduler:

  • Pods are assigned to nodes based on resource requirements, policies, and constraints.
  • Ensures that workloads are evenly distributed and allocated across the cluster, resulting in optimal performance.

etcd (key-value store):

  • Stores all cluster data, including configuration details, status, and metadata.
  • Provides a reliable, distributed, and consistent storage solution for maintaining the cluster’s state.

Controller Manager:

  • Manages various controllers that oversee different aspects of the cluster.
  • Controllers such as node, replication, and endpoint controllers ensure that the cluster’s present condition aligns with the desired state.

Cloud Controller Manager:

  • Integrates the Kubernetes cluster with the cloud provider’s APIs.
  • It manages the cluster’s interaction with the cloud infrastructure, including load balancing, storage, and networking.

2. Data Plane:

The Data Plane components handle the execution and management of workloads (containers) in the cluster.

Kubelet:

  • Acts as an agent running on each node within the cluster.
  • Manages the node and ensures containers run according to specifications through communication with the API server.

Container Runtime:

  • Executes and manages containers within pods.
  • Various container runtimes like Docker and containerd are supported, which allows containers to be created and operated based on Kubernetes-defined configurations.

Kube Proxy:

  • Facilitates network communication within the cluster.
  • It manages network rules and maintains connectivity between different parts of the Kubernetes cluster, including load balancing.

Deploying a Kubernetes Cluster using Minikube

Before we proceed with deploying a Kubernetes cluster using Minikube, let’s familiarize ourselves with some fundamental concepts:

1. Pods in Kubernetes:

A Pod is a fundamental unit in Kubernetes that acts as a wrapper for containers. It can encompass one or multiple containers, sharing network and file resources. All containers within a Pod share the same host address.

2. kubectl — Kubernetes Command-Line Interface (CLI):

kubectl is the command-line tool used for interacting with a Kubernetes cluster, allowing users to manage various aspects of the cluster, such as deployments, services, and pods.

3. Minikube:

Minikube is a useful tool that allows its users to run a simple Kubernetes cluster on their local machines. It is primarily built for testing, development, and learning purposes, providing a simpler way to experiment with Kubernetes without requiring an extensive multi-node cluster setup.

Installation Steps:

  1. Install kubectl:
  • Follow the instructions provided here for kubectl installation.
  • Execute the following command to install kubectl:
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/arm64/kubectl"
  • Verify the installation by checking the kubectl version using:
kubectl version

2. Install Minikube:

  • Follow the Minikube installation guide here.
  • Once installed, start the Minikube cluster using the command:
minikube start
  • To check the available nodes in the Minikube cluster, use the command:
kubectl get nodes

3. Deployment of an Application Pod:

  • Create a YAML file for your application pod by referring to the example provided here. Customize the image name and port for your container within the YAML file.
  • To create the application pod, execute:
kubectl create -f pod.yml
  • Check the created pods using:
kubectl get pods
  • For detailed information about the pod, use the command:
kubectl get pods -o wide

4. Accessing the Pod:

  • To access the application within the pod via an IP address, first log in to the Minikube cluster:
minikube ssh
  • After logging in, use the following command to execute the application: [ip_address_pod] (associated with the targeted pod).
curl ip_address_pod

Upon following these steps, your first application pod should be successfully deployed and running within the Minikube Kubernetes cluster.

Conclusion

To summarize, Kubernetes is a powerful tool for managing container orchestration. It provides a complete system for handling containerized applications in large-scale environments. Its architecture consists of two main components, the Control Plane and Data Plane, which automate scale, and enhance resilience across node clusters.

Key takeaways from this exploration of Kubernetes basics include:

  1. Orchestration and Automation: Kubernetes goes beyond Docker by extending containerization capabilities, enabling automation in the deployment, scaling, and management of containerized applications.
  2. Cluster Management: Understanding the architecture of a Kubernetes cluster is essential for effective cluster management. The Control Plane components handle global decisions while the Data Plane executes workloads.
  3. Minikube for Local Development: Minikube is a tool that sets up local Kubernetes clusters for testing, learning, and development purposes, which helps developers gain practical experience.
  4. kubectl Command Line: The kubectl CLI is a powerful tool to manage Kubernetes clusters, allowing users to handle deployments, pods, services, and more. For a quick reference, check out the kubectl command cheat sheet.

As you start your Kubernetes journey, keep exploring its wide range of tools to make development smoother, handle intricate applications, and adopt modern cloud-based structures.

Happy Kubernetes Explorations!

Further Reading

  • Understanding Pipeline, Continuous Integration & Deployment: Exploring the complexities of software design within collaborative teams and effective change management.
  • Docker: Orchestrating Container Management: Exploring cloud-native applications and their orchestration to build functional applications.
  • Kubernetes Basics: Exploring what Kubernetes can do for you.

--

--