Kubernetes Overview and Architecture

Learn about the high-level architecture of the Kubernetes.

What is Kubernetes?

Kubernetes is a set of primitives that allow us to run robust, distributed applications. It handles scaling and automated failover for our application. It also includes deployment patterns and APIs that will enable us to automate resource management and provide new workloads.

Introduction

Concentrating on the complexity of the code rather than its infrastructure is one of the main challenges for developers. One of the leading architectural concepts for addressing this challenge is Serverless. Various platforms, such as AWS Lambda, AWS Fargate, and Azure Functions, allow us to run serverless applications deployed as single functions or inside containers. These managed platforms come with certain drawbacks:

  • Vendor lock-in

  • Size limitation of the application binary/artifacts

  • Cold start performance

Imagine that we’re only allowed to run applications within a private data center, or we may be using Kubernetes. Nevertheless, we’d like to harness serverless architecture features. Different open-source platforms and tools, such as Knative and OpenFaaS, use Kubernetes to abstract the infrastructure from the developer, allowing us to deploy and manage our applications using serverless architecture and patterns.

Architecture and components

Kubernetes follows a client-server architecture. There’s a single master server that functions as a command and control node and a point of communication. It comprises many components, such as a Kube-apiserver, etcd storage, a Kube-controller-manager, a cloud-controller-manager, a Kube-scheduler, and a DNS server for Kubernetes services.

Kubernetes has two major components:

  • Master node

  • Worker nodes

Master node components

The main components of the master node are discussed below:

  • etcd cluster: This is the key-value storage used to store the Kubernetes cluster’s data, service discovery details, and API objects.

  • kube-apiserver: The Kubernetes API server is the primary management entity for the cluster, receiving all REST requests for changes (to pods, services, replication sets/controllers, and others) and acts as a frontend for the cluster. This is also the only component connected with the etcd cluster, ensuring that the data is stored and the service details of the deployed pods are in agreement.

  • kube-controller-manager: This runs several distinct processes in the background to maintain the state of the cluster and do routine tasks.

  • Kube-scheduler: This helps schedule pods to nodes depending on the resource usage. It reads the service’s operational requirements and schedules it on the preferred node.

Worker node components

  • kubelet: This is the main service on a node. It receives new or modified pod specifications regularly and ensures the health of the pods and their containers.

  • kube-proxy: This proxy service runs on each worker node and handles individual host subnetting. It also exposes services to the outside world and directs requests across a cluster’s segregated networks to the relevant pods/containers.

Kubectl

Kubectl is a command-line tool for interacting with the Kubernetes cluster. Kubectl may be used in either an imperative or declarative manner.

  • Declarative: We use it declaratively by providing a manifest that outlines what we want and kubectl submits it to our cluster, which will then figure out how to make it happen.
  • Imperative: We use it imperatively when we provide it with cluster-specific commands, instructing it on accomplishing what we want.

The declarative method is the preferred approach to utilize Kubernetes, which we’ll do throughout this course. We’ll notice that things are a lot easier when we can tell it what we want and not worry about how it’ll be done.