Contents

Kubernetes

What is it?

Kubernetes, also known as K8s, is an open-source system for automating the deployment, scaling, and management of containerized applications. (Orchestration tool)

Features

  • High availability
  • Scalability (horizontal) and performance
  • Disaster recovery
  • Self healing
  • Automated rollbacks
  • Can run on-prem, cloud or hybrid environment

Drawbacks

  • High complexity
  • Upfront costs are high and can be costly
  • High level of expertise and resouces needed to deploy and manage
Info
Managed kuberenetes engines like Amazon EKS, Google kubernetes engine and Azure kubernetes service take care of underlying infrastructure, setting up, configure control plane, scaling the cluster and maintenance support.

Architecture

https://prod-files-secure.s3.us-west-2.amazonaws.com/f30e4495-2e1e-4eb6-b870-d053c4447a5c/2d8df856-c1d8-45c3-a7b2-4beadfcd4de1/Untitled.png

Node

A node may be a virtual or physical machine, depending on the cluster. Each node is managed by the control plane and contains the services necessary to run Pods.The components on a node include the kubelet, a container runtime, and the kube-proxy.

Kubelet

An agent that runs on each node in the cluster. It makes sure that containers are running in a Pod.

Kube-proxy

kube-proxy is a network proxy that runs on each node in your cluster, implementing part of the Kubernetes Service concept.

kube-proxy maintains network rules on nodes. These network rules allow network communication to your Pods from network sessions inside or outside of your cluster.

kube-proxy uses the operating system packet filtering layer if there is one and it’s available. Otherwise, kube-proxy forwards the traffic itself.

Container runtime

A fundamental component that empowers Kubernetes to run containers effectively. It is responsible for managing the execution and lifecycle of containers within the Kubernetes environment.

Pods

Smallest deployable units in kubernetes which has containers.

Control Plane

Responsible for managing a cluster. Also used to setup and monitor nodes and pods.

Kube-apiserver

The API server exposes the Kubernetes API and is the front end for the Kubernetes control plane.

etcd

Consistent and highly-available key value store used as Kubernetes’ backing store for all cluster data. Used by other components to store and access cluster state.

Kube-scheduler

Control plane component that watches for newly created Pods with no assigned node, and selects a node for them to run on.

Factors taken into account for scheduling decisions include: individual and collective resource requirements, hardware/software/policy constraints, affinity and anti-affinity specifications, data locality, inter-workload interference, and deadlines.

kube-controller-manager

It runs controller processes. Logically, each controller is a separate process, but to reduce complexity, they are all compiled into a single binary and run in a single process.

There are many different types of controllers. Some examples of them are:

  • Node controller: Responsible for noticing and responding when nodes go down.
  • Job controller: Watches for Job objects that represent one-off tasks, then creates Pods to run those tasks to completion.
  • EndpointSlice controller: Populates EndpointSlice objects (to provide a link between Services and Pods).
  • ServiceAccount controller: Create default ServiceAccounts for new namespaces.

The above is not an exhaustive list.

cloud-controller-manager

It embeds cloud-specific control logic to link your cluster into your cloud provider’s API, and separates out the components that interact with that cloud platform from components that only interact with your cluster.

The cloud-controller-manager only runs controllers that are specific to your cloud provider. If you are running Kubernetes on your own premises, or in a learning environment inside your own PC, the cluster does not have a cloud controller manager.

Tools

kubectl

Run commands against Kubernetes clusters, deploy applications, inspect and manage cluster resources, and view logs.

  • kubectl get pod -A
  • kubectl create deployment hello-minikube --image=kicbase/echo-server:1.0 kubectl expose deployment hello-minikube --type=NodePort --port=8080
  • kubectl get services hello-minikube
  • kubectl delete node <node name>

kind

Run Kubernetes on your local computer.

  • kind create cluster
  • kind get clusters
  • kubectl cluster-info --context CLUSTER_NAME
  • kind delete cluster

minikube

Like kind, minikube is a tool to run Kubernetes locally. minikube runs an all-in-one or a multi-node local Kubernetes cluster on your personal computer (including Windows, macOS and Linux PCs) so that you can try out Kubernetes, or for daily development work.

  • minikube start
  • minikube kubectl -- get po -A
  • minikube service hello-minikube
  • minikube dashboard
  • minikube pause
  • minikube unpause
  • minikube stop
  • minikube delete --all

kubeadm

To create and manage Kubernetes clusters. It performs the actions necessary to get a minimum viable, secure cluster up and running in a user friendly way.

  • kubeadm init <args>
  • kubeadm join <control-plane-host>:<control-plane-port> --token <token> --discovery-token-ca-cert-hash sha256:<hash>
  • kubectl drain <node name> --delete-emptydir-data --force --ignore-daemonsets
  • kubeadm reset

https://prod-files-secure.s3.us-west-2.amazonaws.com/f30e4495-2e1e-4eb6-b870-d053c4447a5c/da6ae482-4c7c-4ae6-bd7c-17f8ff65d6c0/Untitled.png

https://prod-files-secure.s3.us-west-2.amazonaws.com/f30e4495-2e1e-4eb6-b870-d053c4447a5c/e3e1772d-08e2-4165-8056-376ebb7d6aa9/Untitled.png

References