Kubernetes 101: A Beginner’s Guide to Orchestrating Containers at Scale

This blog provides a comprehensive introduction to Kubernetes, covering its architecture, key components, and how it orchestrates containerized applications at scale, essential for developers and operations professionals.


This content originally appeared on HackerNoon and was authored by Sourav Dhiman

Welcome to the DevOps Digest! If you are interested in containerization and orchestrating containerized applications at scale, then you have come to the right place. In this blog, we will provide you with a comprehensive introduction to Kubernetes, including what it is, why it's important, and how it works. Whether you are a developer, an operations professional, or just someone curious about the latest trends in technology, this blog will help you understand the fundamental concepts of Kubernetes and why it has become so popular.

What is Kubernetes?

Kubernetes is a container orchestration technology used to orchestrate the deployment and management of hundreds and thousands of containers in a clustered environment.

\

  • The whole process of deploying and managing containers is known as Container Orchestration. e.g. Scaling up your application when no. of users increases and scaling down when the load decreases.

Kubernetes Architecture

  • Node: It is a machine (physical or virtual on which Kubernetes is installed. It is a worker machine where a container will be launched by Kubernetes.

  • Cluster: It is a set of nodes grouped together. So, even if one node fails, we have our application still accessible from the other nodes. It also helps in sharing loads as well.

  • Master: It is another node with Kubernetes installed in it and is configured as a Master. It watches over the nodes in the cluster and is responsible for the actual orchestration of containers on the worker nodes.

    \

  1. Manage the cluster

  2. Stores the information about the members of the cluster

  3. Monitor the nodes

    \

  • Components:

    \

  1. API Server

  2. etcd Service

  3. kubelet Service

  4. Container runtime

  5. Controllers

  6. Schedulers

Components of Kubernetes

  1. API Server: It acts as the frontend for kubernetes. The user, management devices, and command line interfaces all talk to the API server to interact with kubernetes clusters.

    \

  2. etcd: It is a distributed reliable key-value store used by kubernetes to store all data used to manage the clusters.

  • Responsible for implementing locks within the cluster to ensure that there are no conflicts between the masters.

  • When you have multiple nodes and multiple masters in your clusters, etcd, stores all that information on all the nodes in the cluster in a distribution manner.

    \

  1. Scheduler: It is responsible for distributing work or containers across multiple nodes. It looks for newly created containers and assigns them to nodes

    \

4. Controllers: (Brain behind Orchestration)

  • They are responsible for noticing and responding when nodes, containers or endpoints go down

  • They make the decision to bring up new containers

    \

5. Container Runtime: It is the underlying software that is used to run containers. e.g. Docker

\ 6. Kubelet: It is an agent that runs on each node in the cluster.

  • It is responsible for making sure that the containers are running on the node as expected
  • It is also responsible for interacting with a master to provide health information of the worker node and carry out the action requested by the Master on the worker nodes

Kubernetes doesn't deploy containers directly on the worker nodes.

Kubectl

  • It is a command-line utility
  • It is used to deploy and manage applicants on a Kubernetes cluster
  • To get cluster information, the status of other nodes in the cluster, etc.

Kubernetes Pods

Pods are the smallest deployable units of computing that you can create and manage in Kubernetes

  • Pods usually have a one-to-one relationship with containers running your application

  • To scale up, you create new Pods and to scale down, you delete existing Pods

    \

Q: Can a Pod only have a single container?

No, a single Pod can have multiple containers except for the fact that they're usually not multiple containers of the same kind.

Those containers can also communicate with each other directly by referring to each other as localhost since they share the same network space. They can also easily share the same storage space as well.

Commands

  1. Kubectl run: It is used to deploy an application on the cluster
  2. kubectl cluster-info: It is used to view information about the cluster
  3. kubectl get nodes: It is used to list all the nodes part of the cluster
  4. kubectl get pods: Used to see the list of Pods available
  5. kubectl run (pod name) --image = (image name): Used to create a pod by specifying the docker image to be used available at the dockerhub
  6. kubectl describe pod (pod name): Used to get more information related to pods
  7. kubectl get pods -o wide: It provides additional information such as the node when the pod is running and the IP address of the Pod
  8. kubectl create deployment (pod name) --image = (image name): As of version 1.18, to create a deployment using the imperative command, we have to use "kubectl create"

YAML in Kubernetes

(pod-defination.yml)

A kubernetes definition file always contains 4 top level fields.

  • apiVersion

  • kind

  • metadata

  • spec

  1. apiVersion: It is the version of the kubernetes API you're using to create the objects.

\

| Kind | Version | |----|----| | POD | v1 | | Service | v1 | | ReplicaSet | apps/v1 | | Deployment | apps/v1 |

\

  1. kind: It refers to the type of object we are trying to create. e.g. POD, Service, ReplicaSet, Deployment.

  2. Metadata: It is the data about the object like its name labels, etc. As you can see, metadata is in the form of a dictionary.

    \

metadata:
    name: myapp-pod
    labels: 
       app: myapp
       type: front-end

\

  1. spec: Depending on the object we are going to create, this is where we provide additional information to kubernetes about that object.
spec:
  containers:
      - name: nginx-container
        image: nginx

Resources

  1. TechwithPrerit
  2. TechWorldwithNana
  3. Kodekloud

Conclusion

In conclusion, Kubernetes has become the go-to solution for container orchestration, enabling organizations to deploy, manage, and scale containerized applications with ease. With its robust feature set and flexibility, Kubernetes has gained widespread adoption across industries and has revolutionized the way modern software is developed, deployed, and managed. Whether you are a developer, an operations professional, or just someone curious about the latest trends in technology, understanding Kubernetes is essential in today's tech landscape. We hope this introduction has given you a solid foundation to start exploring the world of Kubernetes and its possibilities.

\


This content originally appeared on HackerNoon and was authored by Sourav Dhiman


Print Share Comment Cite Upload Translate Updates
APA

Sourav Dhiman | Sciencx (2024-06-30T20:12:04+00:00) Kubernetes 101: A Beginner’s Guide to Orchestrating Containers at Scale. Retrieved from https://www.scien.cx/2024/06/30/kubernetes-101-a-beginners-guide-to-orchestrating-containers-at-scale/

MLA
" » Kubernetes 101: A Beginner’s Guide to Orchestrating Containers at Scale." Sourav Dhiman | Sciencx - Sunday June 30, 2024, https://www.scien.cx/2024/06/30/kubernetes-101-a-beginners-guide-to-orchestrating-containers-at-scale/
HARVARD
Sourav Dhiman | Sciencx Sunday June 30, 2024 » Kubernetes 101: A Beginner’s Guide to Orchestrating Containers at Scale., viewed ,<https://www.scien.cx/2024/06/30/kubernetes-101-a-beginners-guide-to-orchestrating-containers-at-scale/>
VANCOUVER
Sourav Dhiman | Sciencx - » Kubernetes 101: A Beginner’s Guide to Orchestrating Containers at Scale. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/06/30/kubernetes-101-a-beginners-guide-to-orchestrating-containers-at-scale/
CHICAGO
" » Kubernetes 101: A Beginner’s Guide to Orchestrating Containers at Scale." Sourav Dhiman | Sciencx - Accessed . https://www.scien.cx/2024/06/30/kubernetes-101-a-beginners-guide-to-orchestrating-containers-at-scale/
IEEE
" » Kubernetes 101: A Beginner’s Guide to Orchestrating Containers at Scale." Sourav Dhiman | Sciencx [Online]. Available: https://www.scien.cx/2024/06/30/kubernetes-101-a-beginners-guide-to-orchestrating-containers-at-scale/. [Accessed: ]
rf:citation
» Kubernetes 101: A Beginner’s Guide to Orchestrating Containers at Scale | Sourav Dhiman | Sciencx | https://www.scien.cx/2024/06/30/kubernetes-101-a-beginners-guide-to-orchestrating-containers-at-scale/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.