Kubernetes Learning Note (i)

Image for post
Image for post

Starting from this blog, we will look at Kubernetes following up to our Docker series. But first you may ask what is the difference among Docker, docker-compose and Kubernetes?

  • Docker is the container technology that allows you to containerize your applications.
  • Docker Compose is a tool that takes a YAML file which describes your multi-container application and helps you create, start/stop, remove all those containers without having to type multiple docker ... commands for each container. It has only one host and is not a production ready tool. It works great for PoC or development environments, but lacks a lot of the capabilities that are more or less table stakes for serious production use.
  • Kubernetes is a container orchestration tool that controls/manages containers — running many different containers over multiple different machines.
Image for post
Image for post

Basically, Kubernetes (k8s) allow you to not worry about what specific machine in your datacenter each application runs on. In a production environment, you need to manage the containers that run the applications and ensure that there is no downtime.

That’s how Kubernetes comes to the rescue! Kubernetes provides you with a framework to run distributed systems resiliently. It takes care of scaling and failover for your application, provides deployment patterns, and more.

Kubernetes provides you with:

  • Service discovery and load balancing
    Kubernetes can expose a container using the DNS name or using their own IP address. If traffic to a container is high, Kubernetes is able to load balance and distribute the network traffic so that the deployment is stable.
  • Storage orchestration
    Kubernetes allows you to automatically mount a storage system of your choice, such as local storages, public cloud providers, and more.
  • Automated rollouts and rollbacks
    You can describe the desired state for your deployed containers using Kubernetes, and it can change the actual state to the desired state at a controlled rate. For example, you can automate Kubernetes to create new containers for your deployment, remove existing containers and adopt all their resources to the new container.
  • Automatic bin packing
    You provide Kubernetes with a cluster of nodes that it can use to run containerized tasks. You tell Kubernetes how much CPU and memory (RAM) each container needs. Kubernetes can fit containers onto your nodes to make the best use of your resources.
  • Self-healing
    Kubernetes restarts containers that fail, replaces containers, kills containers that don’t respond to your user-defined health check, and doesn’t advertise them to clients until they are ready to serve.
  • Secret and configuration management
    Kubernetes lets you store and manage sensitive information, such as passwords, OAuth tokens, and SSH keys. You can deploy and update secrets and application configuration without rebuilding your container images, and without exposing secrets in your stack configuration.

Kubernete Component

Image for post
Image for post

Control Plane Components/Master

The Control Plane’s components make global decisions about the cluster (for example, scheduling), as well as detecting and responding to cluster events (for example, starting up a new pod when a deployment’s replicas field is unsatisfied).

kube-apiserver The API server is a component of the Kubernetes control plane that exposes the Kubernetes API. The API server 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.

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

kube-controller-manager Control Plane component that runs controller processes. These controllers include:

  • Node Controller: Responsible for noticing and responding when nodes go down.
  • Replication Controller: Responsible for maintaining the correct number of pods for every replication controller object in the system.
  • Endpoints Controller: Populates the Endpoints object (that is, joins Services & Pods).
  • Service Account & Token Controllers: Create default accounts and API access tokens for new namespaces.

cloud-controller-manager runs controllers that interact with the underlying cloud provider.

Node Components

Node components run on every node, maintaining running pods and providing the Kubernetes runtime environment.

kubelet An agent that runs on each node in the cluster. It makes sure that containers are running in a Pod. The kubelet takes a set of PodSpecs that are provided through various mechanisms and ensures that the containers described in those PodSpecs are running and healthy.

kube-proxy is a network proxy that runs on each node in your cluster, maintains network rules on nodes. These network rules allow network communication to your Pods from network sessions inside or outside of your cluster.

Container Runtime is the software that is responsible for running containers. It supports several container runtimes: Docker, containerd, CRI-O, and any implementation of the Kubernetes CRI (Container Runtime Interface).

Addons

Addons use Kubernetes resources (DaemonSet, Deployment, etc) to implement cluster features. Because these are providing cluster-level features, names-paced resources for addons belong within the kube-system namespace.

DNS is a DNS server, in addition to the other DNS server(s) in your environment, which serves DNS records for Kubernetes services.

Web UI (Dashboard)

Container Resource Monitoring

Cluster-level Logging

Image for post
Image for post

Set-up

To get k8s up and running in your local and cloud, you need the following tools:

  • Kubectl

is the Kubernetes cli. Kubectl provides a swiss army knife of functionality for working with Kubernetes clusters. Kubectl may be used to deploy and manage applications on Kubernetes.

  • Minikube

Minikube is a tool that makes it easy to run Kubernetes locally. Minikube runs a single-node Kubernetes cluster inside a Virtual Machine (VM) on your laptop for users looking to try out Kubernetes or develop with it day-to-day.

When we run Minikube, it will start a virtual Machine that will run as a node, which will create a pod — a group of containers for similar purpose. (Pod is smallest thing to run containers)

 -----node----
| |
| --pod-- |
| | cont- | |
| | aners | |
| ------- |
| |
---------------
  • EKS/GKE

Amazon Elastic Container Service and Google Cloud Kubernetes Engine are both for deploying k8s clusters to the cloud.

🛥 🚤 ⛴ 🛳 ⛵ ⚓️ 🌊🛥 🚤 ⛴ 🛳 ⛵ ⚓️ 🌊🛥 🚤 ⛴ 🛳 ⛵ ⚓️ 🌊🛥 🚤 ⛴ 🛳 ⛵ ⚓️ 🌊🛥 🚤 ⛴ 🛳 ⛵ ⚓️ 🌊🛥 🚤 ⛴ 🛳 ⛵ ⚓️ 🌊🛥 🚤 ⛴ 🛳 ⛵ ⚓️ 🌊

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store