top of page

Kubernetes How It works

Updated: Feb 24


We run Docker, then we go to Kubernetes and turn on cluster in Docker — what exactly are we doing? Is it related to architecture?





Try to Understand this


Your App

Docker Image

Container Runtime (Docker / containerd)

Kubernetes

Cluster (Control Plane + Worker Nodes)

Pods (running your containers)




Architecture of Kubernetes

When you enable Kubernetes in Docker Desktop:
Your laptop becomes BOTH master and worker.


When you enable Kubernetes:

You are moving from:

Single container management (Docker only)

To:

Cluster-based container orchestration (Kubernetes)

Docker Only

Docker + Kubernetes

Run 1 container

Run many containers

Manual restart

Auto restart

No auto scaling

Auto scaling

No self-healing

Self-healing

Local only

Cluster architecture

  1. Docker builds the image

  2. Kubernetes runs and manages containers from that image


When we run with Docker,

docker build -t flask-app .

docker run flask-app

That is simple container execution.


But in Kubernetes:

You create:

  • Deployment YAML

  • Service YAML


Then:

kubectl apply -f deployment.yaml

apiVersion: apps/v1

kind: Deployment

metadata:

name: flask-deployment

spec:

replicas: 3

selector:

matchLabels:

app: flask-app

template:

metadata:

labels:

app: flask-app

spec:

containers:

- name: flask-container

image: flask-app:latest

ports:

- containerPort: 5000


What happens internally?

  1. API Server receives YAML

  2. Scheduler selects node

  3. 3 Pods are created

  4. Each Pod runs container from image

  5. kubelet starts container



Why we Use Serverice. Yaml


Pod-1 → 10.244.0.5

Pod-2 → 10.244.0.6

Pod-3 → 10.244.0.7


What Happens If Pod Crashes?


Imagine you have:

Replica = 1
Pod IP = 10.244.0.5

Now:

  • Pod crashes ❌

  • Kubernetes deletes it

  • Kubernetes creates a NEW Pod

Now new Pod might get:

Pod IP = 10.244.0.9

Old IP (10.244.0.5) is gone.


That is what we mean by:


Pods have dynamic IPs.




like we did here ,


apiVersion: v1

kind: Service

metadata:

name: flask-service

spec:

type: NodePort

selector:

app: flask-app

ports:

- protocol: TCP

port: 80

targetPort: 5000

nodePort: 30007


Chronology of Ports




$50

Product Title

Product Details goes here with the simple product description and more information can be seen by clicking the see more button. Product Details goes here with the simple product description and more information can be seen by clicking the see more button

$50

Product Title

Product Details goes here with the simple product description and more information can be seen by clicking the see more button. Product Details goes here with the simple product description and more information can be seen by clicking the see more button.

$50

Product Title

Product Details goes here with the simple product description and more information can be seen by clicking the see more button. Product Details goes here with the simple product description and more information can be seen by clicking the see more button.

Recommended Products For This Post
 
 
 

Comments


© 2023 by newittrendzzz.com 

  • Facebook
  • Twitter
  • Instagram
bottom of page