Developer 101: Containerization — Kubernetes Basics

Job Alex Muturi
3 min readJun 14, 2023
Photo by Alliance Football Club on Unsplash

Kubernetes, also known as K8s, is an open-source container orchestration platform that simplifies the deployment, scaling, and management of containerized applications. K8s is very popular amongst many container orchestration platforms in the market. Previously we’ve talked about architectures as well as technologies that are or can be used together with containers orchestration platforms; docker, kafka, grpc, microservices.

In this tutorial, we will cover the basics of Kubernetes, including its architecture, core components, and key concepts.

What is Kubernetes?

Kubernetes is an open-source container orchestration platform developed by Google. It allows you to automate the deployment, scaling, and management of containerized applications across a cluster of machines. Kubernetes provides a consistent and reliable environment for running applications, making it easier to manage complex distributed systems.

Kubernetes Architecture

At a high level, the architecture of Kubernetes consists of a master node and multiple worker nodes. The master node acts as the control plane and manages the cluster, while the worker nodes run the actual containerized applications. The master node includes components such as the API server, controller manager, scheduler, and etcd (distributed key-value store). The worker nodes host the containers and run the kubelet, container runtime, and other necessary components.

Core Components

Pods: A Pod is the smallest unit in Kubernetes and represents a single instance of a running process. It can contain one or more containers that share the same network namespace, IPC namespace, and storage volumes. Pods are the basic building blocks of Kubernetes and are scheduled onto worker nodes.

ReplicaSets: A ReplicaSet ensures that a specified number of replicas of a Pod are running at all times. It helps in scaling and fault tolerance by maintaining the desired number of Pod instances. ReplicaSets use labels to identify and select the Pods it manages.

Deployments: Deployments provide declarative updates for Pods and ReplicaSets. They allow you to define the desired state of your application and handle rolling updates and rollbacks. Deployments simplify the management of application updates and provide features like scaling, zero-downtime deployments, and versioning.

Services: Services provide network connectivity and load balancing to Pods. They abstract the underlying network details and provide a stable endpoint for accessing the application. Services can be used to expose applications within the cluster or externally using load balancers or NodePort.

ConfigMaps and Secrets: ConfigMaps store configuration data that can be injected into Pods as environment variables or mounted as files. Secrets are similar to ConfigMaps but are specifically designed for sensitive data like passwords or API keys. They help keep sensitive information separate from the application code.

Namespaces: Namespaces provide a way to divide cluster resources into virtual clusters. They help in organizing and isolating resources, allowing multiple teams or projects to run independently within the same cluster. Follow a similar idea used when coding.

Key Concepts

Labels and Selectors: Labels are key-value pairs attached to Kubernetes objects like Pods, ReplicaSets, or Services. They are used for grouping, selecting, and filtering resources. Selectors allow you to select resources based on labels and perform operations on them.

Resource Requests and Limits: Kubernetes allows you to specify resource requests and limits for containers running within Pods. Resource requests define the minimum required resources, while limits restrict the maximum resources a container can consume. This helps in effective resource management and ensures the stability of the cluster.

Rolling Updates and Rollbacks: Kubernetes supports rolling updates, allowing you to update your application without downtime. It gradually replaces the old Pods with new ones, ensuring a smooth transition. In case of issues, rollbacks can be performed to revert to the previous stable version.

Scaling: Kubernetes provides horizontal scaling by adjusting the number of Pod replicas based on resource utilization. You can scale your application up or down based on demand to ensure optimal performance.

Health Checks: Kubernetes performs health checks on Pods to determine their readiness and liveness. Readiness probes ensure that Pods are ready to accept traffic, while liveness probes check if Pods are running correctly. Health checks help in maintaining application availability and reliability.

Kubernetes simplifies the management of containerized applications, enabling efficient deployment, scaling, and automation. As developers, understanding these fundamentals will provide a strong foundation for working with Kubernetes and building scalable and resilient applications.

Another key aspect when developing apps is authentication and authorization. Next we will look at identity providers. I have written about one popular identity provider, Keycloak.

Happy container orchestration!

--

--

Job Alex Muturi

Angular Developer | Angular Kenya Peer Mentor | Blogger | Tech Speaker