Showing posts with label docker. Show all posts
Showing posts with label docker. Show all posts

Saturday, April 1, 2023

Understanding Kubernetes Pods: A Practical Guide with Commands

Introduction:

Kubernetes, an open-source container orchestration platform, leverages the concept of Pods as its fundamental unit. Pods play a crucial role in enhancing the High Availability of hosted applications, primarily achieved through the configuration of replicas. In this blog, we'll delve into the basics of Pods, exploring their structure and functionality, along with practical examples and essential Kubernetes commands.

What Are Pods?

Pods serve as the building blocks of Kubernetes, allowing for efficient deployment and scaling of containerized applications. They can house one or more containers, tightly coupled together with shared storage and network resources. The key features of Pods include:

  • Shared Storage: Applications within a pod have access to shared volumes, defined as part of the pod's configuration, providing a mechanism for data sharing between containers.

  • Shared IP Address and Port Space: Containers within a pod share the same IP address and port space, facilitating communication via local host.

Example: Multi-Container Pod with Shared Storage

Consider a scenario where a pod contains a file puller and a web server, both utilizing a persistent volume for shared storage. This example illustrates the flexibility and power of Pods in supporting complex application architectures.

Use Cases for Pods

While pods can host vertically integrated application stacks, their primary purpose is to facilitate the co-location and co-management of helper programs. Examples include file and content management systems, data loaders, cache managers, etc.

Kubernetes Commands for Pods

  1. List all Pods in the Default Namespace:

    bash
    $ kubectl get pods
  2. List Pods in a Specific Namespace:

    bash
    $ kubectl get pods -n <namespace name>
  3. List Pods in All Available Namespaces:

    bash
    $ kubectl get pods --all-namespaces
  4. View a Pod in Watch Mode:

    bash
    $ kubectl get pod <pod> --watch
  5. View All Pods in Watch Mode:

    bash
    $ kubectl get pods -A --watch
  6. Format Output:

    • JSON Output:
      bash
      $ kubectl get pods -o json
    • YAML Output:
      bash
      $ kubectl get pods -o yaml
    • Wide Output:
      bash
      $ kubectl get pods -o wide

Conclusion:

Understanding Kubernetes Pods is essential for effectively managing containerized applications. By exploring their features and practical usage through commands, you gain insights into how Pods contribute to the scalability, flexibility, and reliability of your Kubernetes deployments. For more detailed information, refer to the official Kubernetes documentation.

Wednesday, July 20, 2022

Kuberenetes Introduction - Part 1

 

What is Kubernetes?

  • Kubernetes is an open-source system for automating the deployment, scaling, and management of containerized applications.
  • Kubernetes helps to package and distribute apps using image format and container technologies.
  • It groups containers that make up an application into logical units for easy management and discovery.
  • Kubernetes builds upon 15 years of experience of running production workloads at Google, combined with best-of-breed ideas and practices from the community.
  • Kubernetes Features

    Automatic bin packing

    • Automatically places containers based on their resource requirements and other  constraints, while not sacrificing availability.

    • Mix critical and best-effort workloads in order to drive up utilization and save even more resources.

    Automated rollouts 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 roll back the change for you.

    • Take advantage of a growing ecosystem of deployment solutions.

    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 containers their own IP addresses and a single DNS name for a set of containers and can load-balance across them.

    Storage orchestration

    • Automatically mount the storage system of your choice, whether from local storage, a  public cloud provider such as GCP or AWS, or a network storage system such as NFS,  iSCSI, Gluster, Ceph, Cinder, or Flocker.

    Self-healing

    • Restarts containers that fail, replace and reschedule 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.

    Secret and configuration management

    • Deploy and update secrets and application configuration without rebuilding your image and without exposing secrets in your stack configuration.

    Kubernetes Architecture

    Node Controller/ Master

    • The node controller is a Kubernetes master component that manages various aspects of nodes.

    • The node controller has multiple roles in a node’s life. (1). The first is assigning a CIDR block to the node when it is registered (if the CIDR  assignment is turned on).  (2). The second is keeping the node controller’s internal list of nodes up to date with the cloud provider’s list of available machines. (3).  The third is monitoring the nodes’ health.

    • The services on a Node Controller/Master Node include kube-api, kube-scheduler, kube-controller-manager and etcd.

    Node/Minions

    • A node is a worker machine in Kubernetes, previously known as a minion.

    • A node may be a VM or physical machine, depending on the cluster.

    • Each node has the services necessary to run pods and is managed by the node components.

    • The services on a Node include Docker, kubelet and kube-proxy, CNI.





    Node Controller/Master Components

    Kube-ApiServer

    • The Kubernetes API-server generally validates the configuration data store in ‘Etcd’ and the details of the deployed container that are in agreement.

    • It also provides a RESTful interface to make communication easy.

    Kube-Controller-Manager

    • It is generally responsible for handling the cluster level function such as replication controller.

    • Whenever the desired state of the cluster changes it is written to Etcd and then the controller manager tries to bring up the cluster in the desired state.

    Kube-Schedule Server

    • It is responsible for assigning tasks to nodes/minions in the cluster.

    Etcd

    • It is an open-source key-value store developed by the CoreOs team. Kubernetes uses  ‘Etcd’ to store the configuration data accessed by all nodes (minions and master) in the cluster.

    Node Components

    Kubelet

    • Host-level pod management.

    • It deals with pod specifications that are defined in YAML or JSON format.

    • It is responsible for managing pods and their containers.

    • It is an agent process that runs on each node.

    • Kubelet takes the pod specifications and checks whether the pods are running healthy or not.

    Kube-Proxy

    • Every node in the cluster runs a simple network proxy. Using a proxy node in cluster routes requests to the correct container in a node.

    • Manages the container network (IP addresses and ports) based on the network service manifests received  from the Kubernetes master.

    Docker

    • An API and framework built around Linux Containers (LXC) that allows for the easy management of containers and their images.

    CNI

    • A network overlay that will allow containers to communicate across multiple hosts.



    Saturday, April 18, 2020

    Docker Introduction

    Docker Introduction

    • Docker is an Open Source Platform designed to build, distribute and run applications inside the container.
    • Docker is Virtual box that packages applications.
    • Docker implements a high level API to proceed the light weight containers that run processors.
    • Also Docker is a tool for "Rapid Application Development"
    • Docker will use in Dev, Testing, Stage but before will not use in production because of security reason.
    • But now Docker itself has clearances, They integrated with SE-Linux(know that is for Security purpose).


    Virtual Machines Vs Containers

                                VM's                                                          Docker Containers
       

                     -> More time to Create                               -> Less time to create

                     -> Dedicated OS                                        -> Common OS

                     -> Specific bin/lib                                       -> Common bin/lib

                     -> Dedicated Resources                              -> Common resources

                     -> Memory wastage                                    -> No Memory Wastage

                     -> Low Performance                                   -> high performance

                     -> Complex Configure                                -> Simple Configuration

                     -> Heavy Weight (Gb's)                              -> Light Memory (Mb's)

                     -> Memory can not share                             -> Can Share Memory

    Docker Core Terminology

    Docker mainly have Core parts. Those are

                       ** Images
                       ** Containers
                       ** Dockerfile
                       ** Docker Volumes
                       ** Docker Compose
                       ** Docker Network

    Docker Images: 

    • Docker image is a collection of files and source meta data.
    • Images are made of layers, Conceptually stacked on top of each other.
    • Images can share layers to optimize the disk usage, transfer times and memory usage.
    • Docker image is Read Only file system.

    Docker Containers:

    • A container is an executable form of docker image.
    • A Container is an encapsulated set of processes running in read-write copy of the file system.

    Dockerfile:

    • Creates images automatically by using a build script: <Dockerfile>
    • Can be versionized in a version control system like Git or SVN along with all dependencies.
    • Docker hub can automatically build images based on dockerfiles on GitHub.

    Docker Volumes:

    • In Docker, we have a separate volume that can shared across containers. These are known as Data Volumes.
    • They are initialized when the container is created.
    • They can be shared and also reused among many containers.
    • Any changes to the volume itself can be made directly.
    • They exist even after the container is deleted.
              Ex: # docker run -it -v /root/files:/files ubuntu

    Docker Compose:

    • Docker Compose is a tool for defining and running multi-container Docker applications.
    • With Compose, we use a compose file to configure application's services.
    • Then, by using a single command we can create and start all the services from the given configuration requirement.
    Docker Network: 
    • To communicate Docker Containers with each other and the outside world via the host machine, there has to be a layer of networking involved.
    • Docker supports different types of networks, each fit for certain use cases.
    • Different Network Types    
           Docker comes with network drivers geared towards different use cases. The most common network types being:
    • Bridge
    • Overlay
    • Macvlan

    Run Platforms:

    • Various Linux Distributions (Ubuntu, CentOS, Fedora, RHEL, OpenSUSE, ...)
    • Cloud (AWS, GCP, Rackspace)
    • 2014-10: Microsoft announces plans to integrate Docker with next release of Windows Server.
    • 2013-03: Releases as Open Source Tool.



    Featured Post

    Ansible Tool Introduction

                                                                                                                                        Next ...