GitHub EN PT

K8s by Example: Overview

Kubernetes orchestrates containers across a cluster of machines. This guide shows how the core components fit together: Cluster, Nodes, Pods, Deployments, and Services.

cluster-overview

A Cluster is a set of machines (nodes) running Kubernetes. The Control Plane manages the cluster, worker nodes run your applications.

Cluster Control Plane Worker Nodes API Server Scheduler etcd Node 1 Node 2
node

A Node is a machine (physical or virtual) in the cluster. Each node runs kubelet (agent), kube-proxy (networking), and a container runtime. Nodes host Pods.

Node kubelet - talks to API kube-proxy - networking container runtime - runs pods Pod A Pod B Pod C
pod

A Pod is the smallest deployable unit. It wraps one or more containers that share network (same IP) and storage. Containers in a Pod communicate via localhost.

Pod - IP: 10.244.1.5 localhost nginx :80 sidecar :9090 Shared Volume
deployment-replicaset-pod

Deployment manages ReplicaSets, which ensure N copies of a Pod run. You define desired state, Kubernetes maintains it. Deployments handle rolling updates.

Deployment - replicas: 3 ReplicaSet Pod nginx Pod nginx Pod nginx
service

A Service provides a stable IP and DNS name to access Pods. Pods are ephemeral (they come and go), but Services give a fixed endpoint. Load balances across matching Pods.

requests Service: nginx-service Pod 10.244.1.5 Pod 10.244.2.3 Pod 10.244.3.7
namespace

Namespaces divide a cluster into virtual clusters. Use them to separate teams, environments (dev/prod), or projects. Resources in different namespaces are isolated by default.

Cluster ns: dev ns: prod nginx-svc nginx-pod nginx-svc nginx-pod
labels-selectors

Labels are key-value tags on resources. Selectors find resources by labels. This is how Services find Pods, and how you organize resources.

matches matches no match Service selector: app=nginx Pod app=nginx Pod app=nginx Pod app=redis
configmap-secret

ConfigMap stores configuration (env vars, config files). Secret stores sensitive data (passwords, tokens). Both inject data into Pods without hardcoding.

DB_HOST, LOG_LEVEL DB_PASS, API_KEY ConfigMap Secret Pod
full-picture

Putting it all together: Deployments manage Pods, Services expose them, ConfigMaps/Secrets configure them, all organized in Namespaces.

namespace: production Deployment requests configures users Service ConfigMap + Secret Pod Pod Pod
terminal

See all main resources in the current namespace. This shows Pods, Services, Deployments, and ReplicaSets at a glance.

$ kubectl get all
NAME                         READY   STATUS    RESTARTS   AGE
pod/nginx-6799fc88d8-7xj2k   1/1     Running   0          5m
pod/nginx-6799fc88d8-9abc2   1/1     Running   0          5m
pod/nginx-6799fc88d8-def34   1/1     Running   0          5m

NAME                 TYPE        CLUSTER-IP     PORT(S)   AGE
service/nginx        ClusterIP   10.96.100.50   80/TCP    5m

NAME                    READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/nginx   3/3     3            3           5m

NAME                               DESIRED   CURRENT   READY   AGE
replicaset.apps/nginx-6799fc88d8   3         3         3       5m

Index | Use arrow keys to navigate