Date

K8s: Pod, Deployment & Services

Summary

In this article we will learn about Pod, Replication Controller, Deployment and Services.

Perquisite

Linux Physical or virtual machine for Master and Linux/Windows physical or virtual machine as Nodes (Minions)

PODs

  • Atomic unit of deployment and scaling in Kubernetes. POD is ring fenced environment (Sandbox or Namespace) to run Containers. It contains Network Stack, Kernel namespace, Shared Memory, Storage, etc
  • All Containers always runs inside PODs, shares POD environment.
  • One Pod can have multiple Containers. A Pod can’t be spread across multiple Nodes, rather Pod run on single Node.
  • Pods are Mortal: If any Pod dies, new Pod is created on other Nodes with different IP (No Resurrection, No Lazarus Experience)
PODs are Mortal: No Lazarus Experience, No Resurrection
  • Pods are either deployed through Deployment Manifest (YMAL or JSON) to API Server or Replication Controller (Replicas)
IMAGE: PODs
SAMPLE: YAML Template for POD

Replication Controllers: 

IMAGE: Rolling Update and Rollback
  • Replication Controller maintains Desired state of an Application

Example

  • We want of deploy 4 replicas of an Application, we create a YMAL file, kind: Replication Controller, replicas: 4 and share it to API Server. API Server spins 4 Pods on the Cluster
  • If any Pod becomes unresponsive, Kubernetes will deploy new Pods (Create New Pods on available Nodes) to maintain Desired healthy state
YAML Template for Replication Controller

Deployments:

  • Deployments are declarative REST API objects in Kubernetes . Use YMAL (or JSON) file for declaration (creates Manifest Files) and send manifest file to API Server
YAML Template for Deployment
  • As Replication controllers adds feature and functionalities around Pods, Deployment do the same for Replica Set (Replication Controller are replaced by Replica Sets)
  • Deployments add Powerful Update Model (Versioning, Rolling Updates, Concurrent Releases) and Rollbacks
IMAGE: Deployment, Replica Set & Pods

Declarative Model and Desired State

  • Kubernetes works on Declarative Model: We fetch API Server with manifest files (YMAL or JSON) that describes Desired State of the Cluster

i.e ‘How Cluster should looks like and feels like’. Then it is a job of API Server to implement this desired state and maintain it (at any given point of time Desired State = Current State )

  • Changes the state of a ReplicaSet to desired state at a control rate, managing the transition between two ReplicaSet (Moving between two version of application, e.g Version Control (Update application from one version to another version in control way))
  • Deployment control the rate of the transition and even provides Rollback functionality

Service

  • Services is Kubernetes Object that provides stable IP and DNS Name for front-end PODs (Application/Service) to reach backend PODs
  • The way the Service belongs to pods is via Labels (Tags). We create Labels on the Service object: Service will load balance incoming request across all the Pods with same Labels
  • Service IP and DNS name load balances incoming request from front-end Application/Service across multiple backend Pods
  • Services only send traffic to healthy Pods, uses TCP (default) and can be configured with Session Affinity (YMAL file)
  • Service is higher-level stable abstraction point for multiple pods and provides Load Balancing.  Services add persistency to PODs based on the state of the System
Example: Service load balancing incoming request to backend PODs
YAML Template for Service

Example

  • K8s Service is a Network abstraction to the service (Eg: backend Database service) that Pods provides. So Kubernetes persistently allocates an DNS and IP for an Application services that are provided by the collection of Pods
  • As the Pods are created or deleted, Kubernetes dynamically update the service with new information for these Pods
  • So Users will still simply access front end IP and DNS, and Kubernetes will maintain the plumbing or infrastructure underneath as the pods come and go based on their lifecycle. Kubernetes will update the routing information to make sure that traffic comes in on that persistent IP and is routed directly to the pods that are up and healthy
IMAGE : Service claiming PODs with same TAGs
  • Scale up and down service by adding or removing Pods based on demands by updating TAGs (on PODs and Service)
  • Service will Load Balance to distribute application requests across those Pods with same Tag as those on Service
  • This is also helpful in PODs rolling update and Rollback
Example : How Service use TAGs to claim PODs

AZmachina

Knowledge Shared = Knowledge2

We have created AZmachina blog to share our knowledge on Docker & Container and Kubernetes on Windows Servers with curious and enthusiastic novice learner. We hope that this will help them to take a swim in this vast ocean of Window Containers and Kubernetes

Happy Learning !
Recent Posts
Categories
Archives
Sumeet Kumar

Sumeet Kumar

I am Windows Core Engineer with 7+ years of experience in Windows Hyper-v, Failover Cluster, Windows Storage, Volume Shadow Copy (VSS), Docker & Containers on Windows Servers, Backup & Recovery, VMware vSphere EXSi & vCenter Server

RELATED

Articles

Leave a Reply

Your email address will not be published. Required fields are marked *