Kubernetes (part-1)

praduman_cnd

Praduman

Posted on September 21, 2024

Kubernetes (part-1)

Understanding Kubernetes: The Container Orchestration Powerhouse

Kubernetes, also known as k8s, is an open-source system that helps automate the deployment, scaling, and management of applications in containers. It is a container orchestration platform.

When you install Kubernetes, you create a cluster, which is a group of nodes. Nodes are physical or virtual machines that helps to run your containers.

Virtual machines can also be orchestrated through Kubernetes by installing KubeVirt.

Kubernetes are:

  • CNCF Graduated Project

  • Inspired by Borg and Omega

  • Launched in 2014

  • Designed for Scale

  • Run Anywhere

Why Choose Kubernetes? Unleashing the Power of Container Management

Kubernetes is popular because it offers powerful features:

  1. Autoscaling: Automatically adjusts the number of running containers based on current demand, ensuring efficient resource usage and optimal performance.

  2. Autohealing: Detects and replaces failed containers to maintain the health and availability of applications.

  3. Scheduling: Efficiently allocates containers to nodes based on resource requirements and constraints, optimizing resource usage.

  4. Load Balancing: Distributes network traffic across multiple containers to ensure no single container is overwhelmed.

  5. Storage Orchestration: Automatically mounts the necessary storage systems, whether local, cloud-based, or network storage.

  6. Deployment Automation: Automates the deployment, scaling, and rollback of applications, ensuring smooth updates and maintaining high availability.

  7. Monitoring and Logging Integration: Provides integration with various tools for monitoring and logging, offering insights into application performance and health.

Docker's Drawbacks: Why Kubernetes is the Superior Choice

Docker is a platform for running containers, which are lightweight temporary by nature.

Here are some key issues with Docker:

  • Ephemeral Nature: Containers have short lifespans. If a container stops or crashes, the application inside becomes inaccessible until someone restarts it.

  • Single Host Limitation: Docker manages containers on a single machine, making it difficult to handle large-scale deployments.

  • Manual Monitoring: Monitoring and managing a large number of containers manually is impractical. Running commands like docker ps to check container states isn't feasible at scale.

  • Handling Traffic: When a container experiences a surge in traffic, Docker lacks built-in mechanisms to automatically distribute the load or scale up the number of containers, leading to potential performance issues.

How Kubernetes Helps

Kubernetes addresses these problems with features like:

  • Autohealing: Automatically detects and restarts failed containers, ensuring applications remain accessible without manual intervention.

  • Autoscaling: Automatically adjusts the number of running containers based on traffic demand, ensuring that applications can handle increased traffic without performance degradation.

  • Multi-Host Orchestration: Manages containers across multiple machines, enabling large-scale deployments and better resource utilization.


Step-by-Step Guide: Creating a Container Using Docker

firstly make sure you have installed Docker on your server

  • Pull nginx image from dockerHub on your local.

    docker run -d --name my-nginx-container --memory 512m --cpus 1 nginx
    


  • check image are running

    docker ps
    

  • print process id (PID) of container nginx

    docker inspect --format '{{.State.Pid}}' my-nginx-container
    
    (or)
    
    ps aux | grep '[n]ginx' | sort -n -k 2 | head -n 1 | awk '{print $2}'
    

  • list namespaces of a process of linux

    lsns -p <PID>
    


Conclusion

Kubernetes, or k8s, revolutionizes the way applications are deployed, scaled, and managed by automating these processes within containerized environments. Its robust features, such as autoscaling, autohealing, efficient scheduling, load balancing, and storage orchestration, make it an indispensable tool for modern DevOps practices. Unlike Docker, which is limited to single-host container management and requires manual intervention for scaling and monitoring, Kubernetes excels in multi-host orchestration and automatic management of container health and scaling. By leveraging Kubernetes, organizations can achieve greater efficiency, reliability, and scalability in their application deployments.

💖 💪 🙅 🚩
praduman_cnd
Praduman

Posted on September 21, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related