Wednesday, 8 August 2018

Understanding kubernetes Architecture

How Kubernetes Works | Internal of Kubernetes

#Kubernetes Overview: 

  • Kubernetes is a container management Platform
  • Created by Google
  • Written in Go/GoLang
  • Also known as K8s

#Master Node

Master is the control-plane or the brain of k8s cluster. A Master comprises of few components:
  • api-server - Exposes REST API to talk to k8s cluster, consumes json, only api-server talks to Cluster Store.
  • Cluster Store (KV) - Cluster state and config management.
  • Scheduler - Watches api-server for new pods  and assign node to work
  • Controller -  A daemon that watches the state of the cluster to maintain desired state. Example are replication-controller, namespace-controller etc. Other than this it performs garbage collection of pods, nodes, events etc.

#Node

  • Kubelet - k8s agent which register nodes with cluster, watches api-server, instantiate pods, report back to the api-server. If pod fails, it reports to master and master decides what to do. Exposes port 10255 on node
  • Container Engine -  It does container management like pulling images, starting/stopping containers. Usually Docker is used for container runtime.
  • kube-proxy - Responsible for networking, Provide unique IP to Pods, All container in a pod share same IP, Load balances across all pods in a service 

#Pods

  • An environment to run containers
  • It have network stack, kernel namespaces and one or more container running
  • Container always runs inside a pod
  • Pod can have multiple containers
  • It is unit of scaling in k8s

#Services

Pods comes and go with different IPs. To distribute load and act as a single source of interaction to all pods of an application, service play the role.
  • Has single IP and DNS
  • Created with a manifest JSON file
  • All new pods gets added/registered to the service
  • Which pod should be assigned to which services is decided by labels
  • service and pods have labels on the basis of which service identifies its pods
  • only sends traffic to healthy pods
  • service can point things outside the cluster
  • uses tcp by default (udp is also supported)

#Deployments

It is a k8s object whose task is to manage identical pods running and upgrading them in controlled way.
  • Deployed using YAML/JSON manifest
  • Deployed via api-server
  • Provide update of pods
  • Provide rollbacks 

#Detailed Architecture

#Overall Flow

  • kubectl writes to the API Server
  • API Server validates the request and persists it to Cluster store(etcd)
  • Cluster store (etcd) notifies back the API Server
  • API Server invokes the Scheduler
  • Scheduler decides where to run the pod on and return that to the API Server
  • API Server persists it to etcd
  • etcd notifies back the API Server. 
  • API Server invokes the Kubelet in the corresponding node
  • Kubelet talks to the Docker daemon using the API over the Docker socket to create the container
  • Kubelet updates the pod status to the API Server
  • API Server persists the new state in etcd

#Kubernetes Course

8 comments:

 

Copyright @ 2013 Appychip.

Designed by Appychip & YouTube Channel