3. Kubernetes
• Open source container orchestration tool
• Developed by Google
• Helps manage containerized applications
Official definition of Kubernetes:
4. Why Kubernetes?
• What Problems does Kubernetes solve?
• What are the tasks of an orchestration tool?
5. Why Kubernetes?
• Trend from Monolithic arch to Micro-Services arch
Need for container orchestration tool
App App
App
App
App
Micro Service A
Micro Service B
Micro Service C
Micro Service E
Micro Service D
Mod 1 Mod 2
Mod 3 Mod 4
App
Monolithic
6. Kubernetes - Features
• High Availability or no downtime
• Scalability or high performance
• Disaster recovery – backup and restore
What features do orchestration tools offer?
10. Kubernetes - Processes
API Server: Entry-point to K8s cluster
Control
Plane
Controller Manager
Scheduler
Controller manager: keeps track of whats
happening in the cluster
Scheduler: ensure pods placement
API SERVER
30% used 70% used
12. Kubernetes - Processes
Virtual Network: creates one unified machine
Control
Plane
Controller Manager
Scheduler
API SERVER
etcd
Virtual Network
13. Kubernetes – Master Redundancy
Control Plane Nodes
Handful of master processes
Control
Plane
Controller Manager
Scheduler
API SERVER
etcd
Worker Nodes
Higher workload
Much bigger and more resources
14. Kubernetes – Master Redundancy
Control Plane Nodes
Handful of master processes
Much more important
Worker Nodes
Higher workload
Much bigger and more resources
Control
Plane
Controller Manager
Scheduler
API SERVER
etcd
Control
Plane
Controller Manager
Scheduler
API SERVER
etcd
16. Pod
• Smallest unit of Kubernetes
• Abstraction over container
• Usually 1 application per pod
• Each pod gets its own IP address
• New IP address on re-creation
Node
IP
IP
MY-APP
17. Service
• Permanent IP address
• Lifecycle of Pod and Service not connected
Node
IP
SERVICE
MY-APP
22. Component?
Database URL usually in the built application!!
Node
IP
SERVICE
MY-APP
DB SERVICE
INGRESS
Pull it in to the Pod
Push it to repo
Re-Build
Mongo-DB
23. ConfigMap
ConfigMap is for non-confidential data only!
Database URL usually in the built application!!
Node
IP
SERVICE
MY-APP
DB SERVICE
ConfigMap
Mongo-DB
Mongo-user
Mongo-pwd
DB_URL = Mongo-DB
Map map = new HashMap<>();
map.put(“DB_URL”, “http://mongoDB.jswsteel.vasind.bits.edu”);
map.put(“WS_EndPoint”, “http://weatherforecastingdata.gov.in”);
map.put(“NumberOfThreadsAllowed”, 10);
24. Secret
Used to store secret data
Reference Secret in Deployment
Node
IP
SERVICE
MY-APP
DB SERVICE
ConfigMap
Mongo-DB
Mongo-user
Mongo-pwd
DB_URL = Mongo-DB
Secret
DB_USER = mongo-user
DB_PWD = mongo pwd
25. Vol
Storage on local machine
Or remote, outside the K8s cluster
PS: Kubernetes does not manage data persistence
Storage
Node
IP
SERVICE
MY-APP
DB
SERVICE
INGRESS
Vol
remote
local
32. Deployment for Stateless apps
StatefulSet for StateFUL apps or databases
Node
IP
SERVICE
MY-APP
DB
SERVICE
Node
IP
SERVICE
MY-APP
DB
33. Kubernetes - Configuration
• JSON
• YAML
API Server: Entry-point to K8s cluster
Control
Plane
CLI
API
UI
API SERVER
34. Kubernetes - Configuration
• Declarative
• Is == Should
API Server: Entry-point to K8s cluster
Control
Plane
CLI
API
UI
API SERVER
Controller Manager
Controller Manager checks:
Desired state == actual state?
36. Kubernetes Configuration
• Each Configuration file has 3 parts:
• Metadata
• Specification
• Status
Deployment Service
Attributes of
“Spec” are specific
to the “kind”
37. Kubernetes Configuration
• Each Configuration file has 3 parts:
• Metadata
• Specification
• Status : K8s updates the state continously
Deployment Desired? Vs Actual?
38. Control
Plane
Controller Manager
Scheduler
API SERVER
etcd
Where does K8s get this status data?
API Server: Entry-point to K8s cluster
Controller manager: keeps track of whats
happening in the cluster
Scheduler: ensure pods placement
etcd: Kubernetes backing store
Provides the Status information
44. • Kubectl get node
• Kubectl apply –f mongo-configmap.yaml
• Like wise apply – mongo-secret.yaml, mongo.yaml, webapp.yaml
• Kubectl get deployments
• Kubectl get pods
• Kubectl get services
• Kubectl get all
• Kubectl describe service webapp-service
• Kubectl delete service <service-name>
• Kubectl delete deployment <deployment-name>
• Kubectl delete configmap <configmap name>
• Kubectl delete secret <secret-name>
Use private IP of any of the nodes to access the app!!