DEV Community

Cover image for Overview of Kubernetes Components
aseem wangoo
aseem wangoo

Posted on

Overview of Kubernetes Components

In case it helped :)
Pass Me A Coffee!!

What is Kubernetes?

As per the official website

Overview of Kubernetes Components
Overview of Kubernetes Components

Kubernetes is an open-source platform for managing containerized workloads and services. Some of its capabilities include:

  • Service discovery and load balancing: It can expose a container using the DNS name or using their own IP address and if the traffic to a container is high, Kubernetes is able to load balance and distribute the network traffic.
  • Storage orchestration: It allows you to automatically mount a storage system of your choice, such as local storage, public cloud providers, and more.
  • Automated rollouts and rollbacks: Automate Kubernetes to create new containers for your deployment, remove existing containers and adopt all their resources to the new container
  • Self-healing: Restarts containers that fail, replaces containers, kills containers that don’t respond to your user-defined health check
  • Secret and configuration management: Lets you store and manage sensitive information, such as passwords, OAuth tokens, and SSH keys

Article here: https://flatteredwithflutter.com/kubernetes-components/

Why is it popular?

Overview of Kubernetes Components
Overview of Kubernetes Components

Traditional Deployment: In the early days, organizations ran applications on physical servers. There was no way to define resource boundaries for applications in a physical server, and this caused resource allocation issues

Container Deployment: Containers are considered lightweight. Similar to a VM, a container has its own filesystem, the share of CPU, memory, process space, and more. As they are decoupled from the underlying infrastructure, they are portable across clouds and OS distributions.

Other factors:

  • In the previous time, as the trend for microservices grew, companies began deploying more and more of them.
  • There was no proper way to manage them. 

Rise of DevOps

DevOps
DevOps

Kubernetes introduced DevOps. Without Kubernetes, software development teams need to script down their own software deployment, scale it manually, and update workflows. In a large enterprise, DevOps handles this task.

Kubernetes Components

Overview of Kubernetes

Pod:

  • The smallest unit of Kubernetes (K8s)
  • It is an abstraction over the container
  • Any containers in the same pod will share the same resources and local network.
  • Containers can easily communicate with other containers in the same pod.
  • Each pod gets its own IP address, and when a pod dies, a new IP is assigned.
  • Pods are the unit of replication in K8s. If the application becomes popular and a single pod instance can’t carry the load, Kubernetes can be configured to deploy new replicas of your pod to the cluster.

Overview of Kubernetes Components | Pods

Service:

  • Kubernetes gives Pods their own IP addresses and a single DNS name for a set of Pods and can load-balance across them.
  • The client sends a request to the stable IP address, and the request is routed to one of the Pods in the Service.
  • The lifecycle of a pod and service are not connected. So, if a pod dies, its service is not affected.
  • This component itself is a load balancer.
  • A Service identifies its member Pods with a selector. For a Pod to be a member of the Service, the Pod must have all of the labels specified in the selector.

Overview of Kubernetes Components| Service
Overview of Kubernetes Components| Service

Volume:

On-disk files in a container are ephemeral (lasting for short time), which presents some problems for non-trivial applications when running in containers. 

Problems:

  1. Loss of files when a container crashes. The kubelet restarts the container but with a clean slate. 
  2. Sharing files between containers running together in a Pod

Enter Volume

  • Used for persisting data. Kubernetes guarantees data is preserved across container restarts.
  • It is a directory with some data, accessible to the containers in a pod.
  • There are different types of volumes available
  • Apod can use any number of volume types simultaneously. Ephemeral volume types have a lifetime of a pod, but persistent volumes exist beyond the lifetime of a pod.

ConfigMap:

Overview of Kubernetes Components | ConfigMap
Overview of Kubernetes Components | ConfigMap

  • ConfigMaps enable you to separate your configurations from your Pods and components. 
  • This makes pod configurations easier to change and manage and prevents hardcoding configuration data to Pod specifications.
  • Let’s you set the configuration data separately from the application code.
  • Store non-confidential data in key-value pairs.
  • The pods read the data from this config map.

Note: To use sensitive information in your clusters, you must use Secrets.

Secrets:

Overview of Kubernetes Components | Secrets
Overview of Kubernetes Components | Secrets

  • Secrets are secure objects which store sensitive data, such as passwords, OAuth tokens, and SSH keys, in your clusters.
  • Using Secrets reduces the risk of exposing the data to unauthorized users.
  • Values stored are base64 encoded.

Note: Built-in security mechanism is not enabled by default in K8s

Deployment:

  • Although pods are the basic unit of computation in k8s, they are managed by a layer of abstraction: deployment.
  • A component that specifies the blueprint for a pod. 
  • Used to create stateless applications.
  • Mostly you will not be working with pods, instead of with deployment. 
  • Deployment’s primary purpose is to declare how many replicas of a pod should be running at a time.
  • If a pod dies, the deployment will automatically re-create it.

Ingress:

You can create a cluster of nodes, and launch deployments of pods onto the cluster. However, we need to allow external traffic to your application.

Enter Ingress

Overview of Kubernetes Components| Ingress
Overview of Kubernetes Components| Ingress

  • Exposes HTTP and HTTPS routes from outside the cluster to services within the cluster.
  • Request from the outside world first goes to the ingress.
  • Ingress has the traffic routing rules defined and forwards the request to the appropriate service.

There are multiple ways to add ingress to your cluster. The most common ways are by adding either an Ingress controller or a LoadBalancer.

Note: Client can be a web browser, mobile devices, etc.

Stateful Set:

If you deploy any stateful application on Kubernetes, you’ll need to ensure that pods can reach each other through a unique identity that does not change (hostnames, IPs…etc.). 

Enter Stateful Set

  • This is responsible for creating stateful applications, for instance, MySQL clusters, Redis, Kafka, MongoDB, and others.
  • Maintains a sticky identity for each of its pods. Each pod has a persistent identifier.

Overview of Kubernetes Components | Stateful Set
Overview of Kubernetes Components | Stateful Set

  • Headless Service like Nginx controls the network domain.

PersistentVolume:

Programs running on your cluster aren’t guaranteed to run on a specific node. If a program tries to save data to a file for later but is then relocated onto a new node, the file will no longer be where the program expects it to be. 

Enter PersistentVolume

Overview of Kubernetes Components | PersistentVolume

  • To store data permanently, Kubernetes uses Persistent Volumes.
  • PersistentVolume (PV) is a piece of storage in the cluster.
  • PV is independent of the pod lifecycle.
  • They provide a file system that can be mounted to the cluster, without being associated with any particular node.

PersistentVolumeClaim:

  • A PVC is the request to provision persistent storage with a specific type and configuration.
  • Applications claim the PV using PVC

StorageClass:

  • To specify the persistent storage flavor that you want, you use Kubernetes storage classes.
  • When we create a PVC, the request is sent to the storage provider. 
  • Depending on the configuration that is defined in the storage class, the physical storage device is ordered and provisioned in your application.
  • If the requested configuration does not exist, the storage is not created.

In case it helped :)
Pass Me A Coffee!!

Top comments (0)