Kubernetes (K8s) Basic

April ¥in
3 min readJan 17, 2024

--

To know what the K8s are, you must know Docker Basic.

What is K8s?

  • K8s is a platform managing containerized local, cloud, and hybrid applications.
  • It is a container orchestration platform.

Some challenges and considerations commonly arise when deploying applications using Docker containers.

  • Containers might crash.
  • Someone might need to sit down and check the container’s status 24 /7
  • If traffic increases/decreases, how do you adjust to manage this traffic?
  • All incoming traffic must be equally distributed.

Why do we need Kubernetes to deploy containers?

  • When it comes to production deployment, there might be a condition such as this website being deployed into many servers so that
  • 1) if one server is down, another is ready to jump in. So, the system will be available 24/7.
  • 2) if there are a lot of requests, these requests must be equally distributed into all servers for high performance,
  • So, it solved the above problems and simplified the deployment.

You might wonder how the container exists in K8s! See below skatch

This is not a complete architecture. To show where the container exists.

There are a lot of new terms. Cluster, Master Node, Worker Node, Pod, and more to come ….

Cluster:

- A set of virtual machines or nodes are grouped together.

-A cluster has at least one Master Node and one or more than one Worker Node.

Master Node:

The Master Node has four key components (API Server, Scheduler, Kube Controller Manager, and Cloud Controller Manager), which all manage and control the cluster’s resources and workloads.

  • The master node controls all worker nodes.
  1. API Server
  • it is the initial entry point for authentication.
  • every request passes this API Server for authentication.
  • it communicates between the Master node and the Worker node

2. Scheduler

  • manage the pod, such as schedule to create/delete/restart/… pod
  • it also selects the Worker Node for the pod
    For example, which worker node has more resources/is available, and assign the pod to that worker node.

3. Controller Manager

  • check the status of the pod
  • for example, if a pod dies, this controller detects it first
  • then, the controller will tell the scheduler what to do

4. Etcd

  • store cluster information

Worker Node:

  • The Worker Node is responsible for running applications
  • .It is like a virtual machine.
  • Inside the worker node, there can be more than one Pod.

Pod:

  • The pod is the place where containers are deployed.
  • It is also known as the smallest unit of K8s.
  • Pod has its own internal IP address.
  • Since it is internal, it can be accessed within its cluster.

So, how can we access the pod from outside?

or

how do the pods from different clusters talk to each other?

Service can solve all of your questions. Service exposes pods over a network. So the developer can access the pod or the containers inside the pod. Let’s talk about Service.

Service type:

  1. Cluster IP: This service is only reachable from within the cluster. it communicates multiple pods within the same cluster. It is the default type.
  2. NodePort: This service is reachable from outside of the cluster. It exposes cluster IP services outside of the cluster. If no port is defined, K8s will select the port randomly.
  3. LoadBalancer: This service is reachable from outside the cluster as it builds on top of NodePort. It creates a connection for a pod with the internet/public or private. If the pod dies, it will close the connection.

We have discussed about the basic infrastructure of Kubernetes. You might have one question in mind.

How to use Kubernetes?

In order to use Kubernetes, you need Minikube and Kubectl and also need to understand what they are for.

Minikube

  • is a tool used to run clusters on the local machine.
  • You can think of Minikube as a virtual machine.
  • It is for development, testing, and learning purposes, not for production.

Kubectl

  • is a common line interface (CLI) tool used to manage cluster resources and interact with the Kubernetes cluster, regardless of where they are deployed.

--

--

April ¥in

A software engineer from non-traditional background