Rinu Goldgin Dhanaraj

Software Consultant

Notes from Kubernetes

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 ServerCluster StoreSchedulerControl Manager
            
        CentralPersist StateWatches API ServerController Loops
        Simplekey-valueSchedules PodsLifecycle Functions & desired state
        RESTetcdResourcesWatch & update API server
        Updates etcdwatchRespects ConstraintsReplicaSet
    •  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
      • kubeletkube-proxyContainer Runtime
           
        Monitor API Server changesNetwork Proxy – Manages n/w componentsContainer Interface
        Manages pod life cycleNetworking as serviceRuns containers
        Reports Node & Pod StateTraffic routing to podscontainer should be CRI complaint
        Pod liveness probs – app checkLoad balancing 
    • Scheduled Add/Ons
      • Provides services to the cluster
      • DNS Pods
      • Ingress
      • Dashboard

Notes:

  1. The scheduler taints the master, means, it can host only admin components and not user workload
  2. Master default taint setting can be reverted to share workloads across node 
    1. Not recommended for prod 
  3. Services provides n/w abstraction
    1. within this the state of cluster and its pods or obfuscated to the clients
      1. Client –> Service ( Load Balancer ) –> Cluster [Pod1, Pod2, Pod.n]
    2. in this scenario when a pod goes down the controller brings back a new pod without client impact
  4. Networking Fundamentals
    1. All pods can communicate with each other on all nodes
    2. All nodes communicate with all pods
    3. No NAT
      1. all pods & nodes should be reachable using real id’
    4. Scenario:
      1. Inside a Pod
      2. Pod to Pod within a node
      3. Within a cluster
        1. Pod 1, Pod2 Pod3 – they communicate using IP1, IP2, IP3
      4. External – Services are used, like load balancer, to communicate

 

Next : Lets get dirty – hands-on

 

 

Previous Article
Next Article