Cloud Native 10 min read

Mastering Kubernetes: Understanding Pods, Probes, and Core Concepts

This article demystifies Kubernetes by explaining its scheduling fundamentals, the role of Pods, essential YAML configurations, health probes, high‑availability objects, service types, and core internal components, providing a comprehensive guide for developers and operators.

Efficient Ops
Efficient Ops
Efficient Ops
Mastering Kubernetes: Understanding Pods, Probes, and Core Concepts

1. Pod

Pod is the smallest scheduling unit in Kubernetes, containing one or more containers (typically Docker). Each Pod gets a unique IP address that is shared among its containers, enabling inter‑container communication via a shared namespace and allowing shared volumes.

Pods use shared namespaces so containers can communicate via localhost, and can mount shared storage volumes.

Pod definitions are written in YAML to avoid excessive API design.

apiVersion: v1
kind: Service
metadata:
  namespace: bcmall
  name: bcmall-srv
spec:
  type: NodePort
  selector:
    app: container-bcmall-pod
  ports:
    - port: 8080
      targetPort: 80
      nodePort: 14000
      protocol: TCP

Apply the YAML with kubectl create -f ./bcmall.yaml.

2. Probes and Hooks

After a Pod is scheduled, health checks (probes) verify its status: livenessProbe – similar to a heartbeat; if the container is not alive, it is terminated. readinessProbe – indicates the container is ready to receive traffic. startupProbe – ensures the container has started before other probes run.

Hooks allow custom actions: PostStart – runs after container start. PreStop – runs before container termination.

apiVersion: v1
kind: Pod
metadata:
  labels:
    test: liveness
  name: liveness-exec
spec:
  containers:
  - name: liveness
    image: k8s.gcr.io/busybox
    args:
    - /bin/sh
    - -c
    - touch /tmp/healthy; sleep 30; rm -rf /tmp/healthy; sleep 600
    livenessProbe:
      exec:
        command:
        - cat
        - /tmp/healthy
      initialDelaySeconds: 5
      periodSeconds: 5

3. High‑Availability Objects

To achieve high availability, multiple Pods are managed by higher‑level objects: ReplicaSet (RS) – ensures a desired number of Pod replicas. Deployment – builds on ReplicaSet and supports rolling updates; requires proper labels in spec.template.metadata.labels.

Labels are key‑value pairs used for selection, e.g.: kubectl get pod -n demo -l app=nginx,version=v1 Services expose Pods and provide stable networking:

ClusterIP – creates an internal virtual IP.

NodePort – exposes a static port on each node (uses NAT).

LoadBalancer – provisions an external load balancer.

ExternalName – maps a Service to an external DNS name.

4. Internal Components

Kubernetes consists of control‑plane components and node‑level daemons:

kube-apiserver – central REST API server handling authentication, authorization, and service discovery.

kube-scheduler – assigns unscheduled Pods to suitable nodes.

kube-controller-manager – maintains overall cluster state.

kubelet – runs on each node, communicates with the API server, and manages Pod lifecycles.

kube-proxy – handles Service networking, routing traffic to Pods.

etcd – distributed key‑value store for persistent cluster configuration.

Kubernetes architecture diagram
Kubernetes architecture diagram
deploymentKubernetesYAMLServicePodprobe
Efficient Ops
Written by

Efficient Ops

This public account is maintained by Xiaotianguo and friends, regularly publishing widely-read original technical articles. We focus on operations transformation and accompany you throughout your operations career, growing together happily.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.