Kubernetes Core Concepts

Architecture Overview

┌─────────────────────────────────────────────────────────────────────┐
│                          CONTROL PLANE                               │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐ │
│  │ API Server  │  │  Scheduler  │  │ Controller  │  │    etcd     │ │
│  │             │  │             │  │   Manager   │  │  (storage)  │ │
│  └─────────────┘  └─────────────┘  └─────────────┘  └─────────────┘ │
└─────────────────────────────────────────────────────────────────────┘
                              │
                              │ manages
                              ▼
┌─────────────────────────────────────────────────────────────────────┐
│                       CLUSTER ADD-ONS                                │
│         (run as pods, but provide cluster-wide services)             │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐                  │
│  │   CoreDNS   │  │ kube-proxy  │  │   Metrics   │                  │
│  │   (DNS)     │  │ (networking)│  │   Server    │                  │
│  └─────────────┘  └─────────────┘  └─────────────┘                  │
└─────────────────────────────────────────────────────────────────────┘
                              │
                              │ runs on
                              ▼
┌─────────────────────────────────────────────────────────────────────┐
│                            NODES                                     │
│  ┌─────────────────────────────────────────────────────────────────┐│
│  │ Node                                                            ││
│  │  ┌──────────────────────────────────────────────────────────┐   ││
│  │  │                      kubelet                              │   ││
│  │  │  (talks to API server, manages pods on this node)         │   ││
│  │  └──────────────────────────────────────────────────────────┘   ││
│  │                            │                                    ││
│  │                            │ uses                               ││
│  │                            ▼                                    ││
│  │  ┌──────────────────────────────────────────────────────────┐   ││
│  │  │              Container Runtime (containerd)               │   ││
│  │  │  (actually pulls images, starts/stops containers)         │   ││
│  │  └──────────────────────────────────────────────────────────┘   ││
│  │                            │                                    ││
│  │                            │ runs                               ││
│  │                            ▼                                    ││
│  │  ┌──────────────────────────────────────────────────────────┐   ││
│  │  │                        Pods                               │   ││
│  │  │  ┌───────────┐ ┌───────────┐ ┌───────────┐               │   ││
│  │  │  │   pod-1   │ │   pod-2   │ │   pod-3   │               │   ││
│  │  │  │┌─────────┐│ │┌─────────┐│ │┌─────────┐│               │   ││
│  │  │  ││container││ ││container││ ││container││               │   ││
│  │  │  │└─────────┘│ │└─────────┘│ │└─────────┘│               │   ││
│  │  │  └───────────┘ └───────────┘ └───────────┘               │   ││
│  │  └──────────────────────────────────────────────────────────┘   ││
│  └─────────────────────────────────────────────────────────────────┘│
└─────────────────────────────────────────────────────────────────────┘

Component Responsibilities

LayerComponentWhat it does
Control PlaneAPI ServerSingle entry point, all components talk through it
SchedulerDecides which node runs each pod
Controller ManagerRuns controllers (Deployment, StatefulSet, DaemonSet, etc.)
etcdKey-value store, holds all cluster state
Add-onsCoreDNSTranslates service names → IPs (master.seaweedfs10.43.x.x)
kube-proxyNetwork rules, routes service IPs to pod IPs
Metrics ServerOptional, provides CPU/memory metrics for kubectl top
NodekubeletAgent on each node, manages pod lifecycle
containerdContainer runtime, does the actual container work
PodsYour workloads

YAML Fields → K8s Components

apiVersion: apps/v1              # → API Server: which API group handles this
kind: StatefulSet                # → Controller Manager: which controller manages this
metadata:
  name: master                   # → etcd: stored as unique key
  namespace: seaweedfs           # → etcd: partition/folder for storage
  labels:                        # → etcd: stored metadata for filtering
    app: seaweedfs
spec:
  serviceName: master            # → CoreDNS: creates DNS records
  replicas: 1                    # → Controller Manager: desired state to maintain
  selector:
    matchLabels:                 # → Controller Manager: how to find owned pods
      component: master
  template:                      # → kubelet: blueprint for creating pods
    metadata:
      labels:                    # → etcd + Controller: pod identification
        component: master
    spec:
      nodeSelector:              # → Scheduler: constraint for node selection
        kubernetes.io/hostname: pavanjci
      containers:                # → kubelet + containerd
      - name: master             # → containerd: container identifier
        image: seaweedfs:latest  # → containerd: what to pull/run
        args: [...]              # → containerd: process arguments
        ports:                   # → kube-proxy: network exposure info
        - containerPort: 9333
        volumeMounts:            # → kubelet: mount setup inside container
        - name: data
          mountPath: /data
      volumes:                   # → kubelet: volume provisioning
      - name: data
        hostPath:
          path: /data/seaweed/master

Service YAML

apiVersion: v1
kind: Service                    # → kube-proxy + CoreDNS
metadata:
  name: master                   # → CoreDNS: DNS name (master.seaweedfs.svc)
  namespace: seaweedfs
spec:
  clusterIP: None                # → kube-proxy: headless, no load balancer IP
  selector:                      # → kube-proxy: which pods to route to
    component: master
  ports:                         # → kube-proxy: port mapping rules
  - port: 9333

Field to Component Mapping

YAML FieldK8s ComponentPurpose
apiVersionAPI ServerRoutes to correct API handler
kindController ManagerPicks which controller manages it
metadata.nameetcdUnique identifier, stored as key
metadata.namespaceetcdLogical partition
metadata.labelsetcdStored for filtering/selection
spec.replicasController ManagerDesired state to reconcile
spec.selectorController ManagerLinks controller to pods
spec.serviceNameCoreDNSStable DNS for StatefulSet pods
spec.templatekubeletPod creation blueprint
nodeSelectorSchedulerNode placement constraint
containerskubelet + containerdActual workload definition
imagecontainerdContainer image to run
portskube-proxyNetwork exposure
volumeMountskubeletIn-container mount points
volumeskubeletVolume source definitions
Service selectorkube-proxyPod discovery for routing
Service clusterIPkube-proxyVirtual IP assignment

The Flow: What Happens When You Apply

1. kubectl apply -f deployment.yaml
                │
                ▼
2. API Server: validates, stores in etcd
                │
                ▼
3. Controller Manager: sees new resource
   "I need 1 replica, currently 0, create pod"
                │
                ▼
4. Scheduler: sees unscheduled pod
   "nodeSelector says node-1, assign there"
                │
                ▼
5. kubelet (on node-1): sees pod assigned to it
   "Create container, mount volumes, start process"
                │
                ▼
6. kube-proxy: sees Service + pod labels match
   "Route traffic for service:port to this pod"
                │
                ▼
7. CoreDNS: sees Service
   "service.namespace.svc.cluster.local → pod IP"

Labels and Names

What’s Required vs Optional

FieldRequired?Purpose
metadata.nameYesK8s resource identifier
metadata.namespaceNo (defaults to default)Isolation
spec.selector.matchLabelsYesLinks controller → pods
template.metadata.labelsYesMust match selector
spec.serviceNameStatefulSet onlyStable pod DNS
app, component, etc.NoHuman organization + filtering

Label Rules

  • selector.matchLabels must be a subset of template.metadata.labels
  • Label keys can be anything (app, component, banana, etc.)
  • Labels are just key-value pairs for filtering
# Valid - template has more labels than selector
selector:
  matchLabels:
    component: master
template:
  metadata:
    labels:
      component: master    # matches selector
      app: seaweedfs       # extra, ignored by selector

Namespace vs App Label

AspectNamespaceapp label
What it isK8s built-in isolationJust a text label
Enforced byKubernetes itselfNothing (convention)
ScopeResources isolatedNo effect on visibility
NetworkServices need full DNS to crossNo effect
Deletionkubectl delete ns X removes allJust a filter

K3s vs Full Kubernetes

Full K8sK3s
etcdSQLite (or etcd optional)
Separate binariesSingle k3s binary
containerd separatecontainerd bundled
kube-proxy separateBuilt into k3s

Useful Commands

# View control plane components
kubectl get pods -n kube-system
 
# View CoreDNS
kubectl get pods -n kube-system -l k8s-app=kube-dns
 
# Filter by labels
kubectl get pods -l app=seaweedfs
kubectl get pods -l component=master
kubectl logs -l component=mount
 
# Multiple labels (AND)
kubectl get pods -l app=seaweedfs,component=master
 
# All namespaces
kubectl get pods -A -l app=seaweedfs

Tags

kubernetes k8s infrastructure containers devops