Kubernetes
Container
• A container is a lightweight, portable unit of
software that packages up code and all its
dependencies, ensuring that an application runs
consistently across different environments
• Container orchestration is the process of
automating the deployment, management,
scaling, and networking of containers throughout
their lifecycle. It ensures that applications run
efficiently across different environments,
especially when dealing with large-scale
containerized workloads.
Kubernetes
• Kubernetes (also called K8s) is an open-source
platform that helps you automates the deployment,
scaling, and management of containerized
applications
• Ex. A food delivery app runs in a container using
Docker. When app becomes popular and thousands
of users start placing orders, you need to run more
copies of it to handle the load.
• Instead of doing this manually, you use Kubernetes
to say:
– “Hey Kubernetes, always keep 5 copies of my app
running. If one stops, replace it. And if more users come,
increase the number of copies automatically.”
Kubernetes – container orchestration tool for deployment,
scaling and managing containerized Applications
Architecture of Kubernetes
Key Terminologies
• PoD
– the smallest deployable unit that represents a single
instance of an application
– It can contain one or multiple containers that share
storage, network, and specifications for how they
should run together.
– Created by control plane
Node
– A Node is a machine (physical or virtual) in a Kubernetes
cluster that runs your applications.
– Each Node contains the tools needed to run Pods, including
the container runtime (like Docker), the Kubelet (agent), and
the Kube proxy (networking).
Kubelet – is a deamon running on each
worker node. It is responsible for
communicating with control plane
Container runtime – responsible for pulling
images from registry / starting and stoping
containers / managing containers
Kube-proxy – responsible for routing trafic to
the correct path (pod)
Worker node Worker node
3. Cluster
– A Kubernetes cluster is a group of computers (called
nodes) that work together to run your containerized
applications. These nodes can be real machines or virtual
ones.
– There are two types of nodes in a Kubernetes cluster:
– Master node (Control Plane):
• Think of it as the brain of the cluster.
• It makes decisions, like where to run applications, handles
scheduling, and keeps track of everything.
– Worker nodes:
• These are the machines that actually run your apps inside
containers.
• Each worker node has a Kubelet (agent), a container runtime
(like Docker or containerd), and tools for networking and
monitoring.
Cluster
Pod is a smallest deployable unit in the k8s
Control Plane - Components
etcd
• etcd is the persistence key value storage where
the state of the containers are stored
• It is used by control plane to store information
about clusters
• Control manger is responsible for running
controllers that manages the state of cluster
• API Server acts as the gateway for all
interactions within the cluster, handling REST
API requests
• Scheduler
• is responsible for scheduling pods in the worker node in a cluster
• Resources required by pods are served based on resources available
in the worker node
• Deployment Controller
– A Deployment is a Kubernetes object used to manage a set of Pods running your
containerized applications
– Controls Rolling updates and rollback of deployments
• ReplicaSet - Controller
– A ReplicaSet ensures that the right number of identical Pods are
running.
• Service
– A Service in Kubernetes is a way to connect applications running
inside your cluster.
• Ingress
– Ingress is a way to manage external access to your services in a
Kubernetes cluster.
• Persistent Volume (PV)
– A Persistent Volume (PV) in Kubernetes is a piece of
storage in the cluster that you can use to store data —
and it doesn’t get deleted when a Pod is removed or
restarted.
• Kubelet
– A Kubelet runs on each Worker Node and ensures Pods
are running as expected.
• Kube-proxy
– Kube-proxy manages networking inside the cluster,
ensuring different Pods can communicate.
• Namespace
– A Namespace is like a separate environment within your
Kubernetes cluster. It helps you organize and isolate
your resources like Pods, Services, and Deployments.
Benefits of using Kubernetes
• Automated Deployment and Management
• Scalability (horizondle – increase nodes, verticle – increase capasity
of a node)
• High Availability
• Cost-Effectiveness
• Improved Developer Productivity
Portable – b/w cloud and private cloud
Kubernetes Service Providers
Downside of K8s
1. Complexity – more complex to setup and operate
2. Required experts to configure and manage
3. Upfront cost is high for small organizations
Could be accessed as a cloud service
Deploying and Managing Containerized
Applications with Kubernete
• Step 1: Install Kubernetes and setup Kubernetes cluster
there should be minimum at least one master node and
two worker nodes you can set up the Kubernetes cluster
in any of the cloud which are providing the Kubernetes
as an service.
• Step 2: Now, create a deployment manifest file. In this
file, you specify the desired number of Pods, the
container image, and the resources required. After
creating the manifest, apply it using
the kubectl command.
• Step 3: After creating the pods know you need to expose
the service to the outside for that you need to write one
more manifest file which contains service type (e.g.,
Load Balancer or Cluster IP), ports, and selectors.
Kubernetes v/s Docker
Feature Docker Kubernetes
A container orchestration tool that
A containerization platform to build,
Purpose manages, deploys, and scales
ship, and run containers.
containerized applications.
Originally by Google, now managed by
Developed By Docker Inc.
CNCF.
Container Manages multiple containers across a
Manages individual containers.
Management cluster.
Manual scaling of containers Auto-scaling with Horizontal Pod
Scaling
using docker run or docker-compose. Autoscaler (HPA).
Uses a cluster-wide network to
Uses a single-host bridge network by
Networking connect services across multiple
default.
nodes.
Basic load balancing via Docker Advanced load balancing with Services
Load Balancing
Swarm. and Ingress.
Containers need to be restarted Automatically replaces failed
Self-Healing
manually if they fail. containers (Pods).
Not natively supported; requires Supports zero-downtime rolling
Rolling Updates
recreating containers manually. updates for applications.
Kubernetes Commands
• Start your cluster - From a terminal with administrator access (but not
logged in as root), run:
– minikube start
• to access your shiny new cluster:
– kubectl get po -A
• Create a sample deployment and expose it on port 8080:
– kubectl create deployment hello-minikube --image=kicbase/echo-
server:1.0
– kubectl expose deployment hello-minikube --type=NodePort --port=8080
• Way to access this service is to let minikube launch a web browser for
you:
– minikube service hello-minikube
• To manage clusters
– minikube pause
– Minikube stop / start
– minikube delete --all
Reference website for kubernetes
installation and commands
• Minikubernet commands
• https://minikube.sigs.k8s.io/docs/start/?arch=%
2Fwindows%2Fx86-
64%2Fstable%2F.exe+download
•
• to install minikubernet
• https://www.geeksforgeeks.org/kubernetes-
minikube/
•