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.

Kubernetes Architecture

  1. Manage the cluster

  2. Stores the information about the members of the cluster

  3. Monitor the nodes

  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.

  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)

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.

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

Kubectl

Kubernetes Pods

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

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.

  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.