Journey of Kubernetes:
This covers the key principles, architecture & components of Kubernetes.
What is Kubernetes?
In simple terms it’s a container Orchestrator, which means the Kubernetes manages the container based applications and is responsible in maintaining the desired state of the application.
- Workload Placement
- With the code we can define the c ode its application behavior on where to deploy or which cluster to be shared etc
- Infra Abstraction
- Hardware resources such as memory, cpu etc are maintained efficiently without the need for manual interference
- State Persistence
- Defined & the desired app/service states are managed by the platform and ensured by the kubernetes
Benefits of Kubernetes
- Speed of Deployment
- Dev to Prod rollout is controlled & faster
- Adaptability
- Change(s) are handled efficiently
- Recover
- Kubernetes maintained the defined state
- Managed
- complex systems obfuscated through kubernetes
What are the key principle of Kubernetes?
- Declarative Configuration – where declarative state defined in the code
- Controllers
- Control loops keeps monitoring the resources of system and ensures the state.
- API Server
- Core hub of kubernetes cluster
- One Master
Kubernetes API Server
- Collection of API Objects
- These API Objects are primitive & represents the state of the systems
- Enables the state of the configuration either
- Declaratively – Defined or desired state as described
- Imperatively – Getting the desired state through CLI
- REST API Interfaces
- HTTP using JSON
- Communicates (only way) with your cluster
- The interaction of Kubernetes with the cluster
- The Operation states changes are serialized & persisted with the cluster datastore.
The core primitives of the Kubernetes API Objects – these are considered as the building blocks with the Kubernetes deployments
- Pods
- Container based application
- Single or collection of containers deployed as single unit.
- Pods are Ephemeral – “never redeployed”
- when a pod crashes – based on state always a new pod is bought back in.
- Pods are binary
- Kubernetes keeps the pod running based on the desired state
- where state – is Pod up/down
- App health – “probes” based on app response status
- Controllers
- Ensures the systems desired state of the Pods ( applications )
- ReplicaSet Controller
- No.of Replicas
- Deployment Controller
- Manages the rollout of ReplicaSet
- controls the rate of transition
- Services
- Persistent access point to the application that are deployed in the pods
- Services manages the states across controller & pods
- Network abstraction
- Dynamically allocates IP & DNS for the new pods
- Kubernetes provides plumbing for the new pods without impact to the end users
- All redeployed pods are updated automatically
- Scaling
- Add / Remove the Pods
- Load Balancing across the pods
- Storage
- Persistent storage – datastore
- Volumes are created and mapped to pods
- Persistent volumes are pod independent storage
- defined at the cluster level
Kubernetes Architecture
- Cluster Components
- Master
- Implements the major control functions of cluster.
- It coordinates cluster operations, monitors the pods
- Primary for cluster administration
- Master – Control Plane Components
- API Server
- Cluster Store
- Scheduler
- Controller Manager
- Life cycle management
- kubectl – this is outside the master components
- Interacts with the API Server
- Primary tool
API Server Cluster Store Scheduler Control Manager Central Persist State Watches API Server Controller Loops Simple key-value Schedules Pods Lifecycle Functions & desired state REST etcd Resources Watch & update API server Updates etcd watch Respects Constraints ReplicaSet
- Node
- Application pods
- N/W reachability
- Multiple nodes
- Node Components ( runs on all nodes including master nodes)
- kubelet
- communicates with API Server
- kube-proxy
- communicates with API Server
- Container Runtime
- kubelet
kubelet kube-proxy Container Runtime Monitor API Server changes Network Proxy – Manages n/w components Container Interface Manages pod life cycle Networking as service Runs containers Reports Node & Pod State Traffic routing to pods container should be CRI complaint Pod liveness probs – app check Load balancing
- Scheduled Add/Ons
- Provides services to the cluster
- DNS Pods
- Ingress
- Dashboard
- Master
Notes:
- The scheduler taints the master, means, it can host only admin components and not user workload
- Master default taint setting can be reverted to share workloads across node
- Not recommended for prod
- Services provides n/w abstraction
- within this the state of cluster and its pods or obfuscated to the clients
- Client –> Service ( Load Balancer ) –> Cluster [Pod1, Pod2, Pod.n]
- in this scenario when a pod goes down the controller brings back a new pod without client impact
- within this the state of cluster and its pods or obfuscated to the clients
- Networking Fundamentals
- All pods can communicate with each other on all nodes
- All nodes communicate with all pods
- No NAT
- all pods & nodes should be reachable using real id’
- Scenario:
- Inside a Pod
- Pod to Pod within a node
- Within a cluster
- Pod 1, Pod2 Pod3 – they communicate using IP1, IP2, IP3
- External – Services are used, like load balancer, to communicate
Next : Lets get dirty – hands-on
