Skip to content

Kubernetes three brothers

Kubernetes three brothers refers to a conceptual grouping of three core resources in Kubernetes: Pod, Service, and Deployment.^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md] These components are central to implementing advanced operations such as load balancing, rolling updates, security, and monitoring within a cluster.^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md]

Overview

When practicing or implementing Kubernetes, the workflow invariably revolves around configuring these three specific resources to achieve complex system behaviors.^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md]

  • Pod: The smallest deployable unit in a node where containers are managed.
  • Service: An abstraction which defines a logical set of Pods and a policy by which to access them.
  • Deployment: A controller that provides declarative updates for Pods and ReplicaSets.

The "Brothers"

Pod

The Pod is the smallest unit of management within a Node (節點).^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md] While a Pod typically hosts a single container, it is designed to support one or more containers as needed.^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md]

This component serves as the core host for the containerized applications. The configuration of a Pod includes defining apiVersion, kind, metadata (such as labels and names), and spec (which details the container image, ports, and resources).^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md]

Labels play a critical role in the Pod ecosystem; they are key-value pairs attached to objects that allow users to group and map meaningful objects, enabling other components like Services to select specific Pods using Selectors.^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md]

Service

The Service component is responsible for enabling network access to the application running on Pods.^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md] Because Pods are ephemeral and their IP addresses can change, a Service provides a stable endpoint (often a virtual IP) that decouples the client from the specific Pod instances.

Services utilize the Selectors mentioned in the Pod section to define which set of Pods receives traffic, facilitating concepts like load balancing.^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md]

Deployment

The Deployment is a management tool used to update and maintain Pods.^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md] While a kubectl create command creates resources that do not exist, a Deployment allows for the use of kubectl apply, which checks for setting changes and updates resources that already exist.^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md]

This capability is essential for rolling updates and scaling, ensuring that applications can be updated or modified without downtime by gradually replacing old Pods with new ones.^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md]

Workflow and Operations

Managing these three resources is the daily routine of operating Kubernetes. Common workflows involve:

  1. Defining Pods: Writing YAML manifests to specify container images and ports.
  2. Networking: Using Services to expose applications, potentially utilizing kubectl port-forward to map local ports to the cluster for testing.^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md]
  3. Updating: Applying Deployment configurations to roll out changes or scale the application.

Sources

^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md]