Introduction to Kubernetes: Pod, Deployment and Service Concepts

Introduction to Kubernetes: Pod, Deployment and Service Concepts

Kubernetes (k8s) is an open-source orchestration platform that automates the deployment, scaling, and management of containers. According to the CNCF 2025 survey, 84% of organizations now run Kubernetes in production. This guide covers the fundamental building blocks of Kubernetes - Pod, Deployment,

Kubernetes (k8s) is an open-source orchestration platform that automates the deployment, scaling, and management of containers. According to the CNCF 2025 survey, 84% of organizations now run Kubernetes in production. This guide covers the fundamental building blocks of Kubernetes - Pod, Deployment, Service, ReplicaSet, and Namespace - with practical YAML examples.

What Is Kubernetes and Why Use It?

Kubernetes was inspired by Google's Borg system and released as open source in 2014. Its core purpose is managing the lifecycle of containers: you define which node runs what, how many replicas exist, health checks, network access, and update strategies through declarative YAML files, and Kubernetes handles the rest.

Docker runs containers on a single machine; Kubernetes manages tens or hundreds of machines as a single cluster. If your application crashes, it automatically restarts. When traffic spikes, it scales horizontally. During updates, it ensures zero downtime.

💡 Prerequisites: To follow this guide, basic Docker knowledge and the kubectl CLI tool are sufficient. For local experimentation, use Minikube or kind.

Kubernetes Architecture: Control Plane and Worker Nodes

A Kubernetes cluster consists of two main layers: the Control Plane (management layer) and Worker Nodes (workload layer).

Component Layer Role
kube-apiserver Control Plane Handles all API requests, the cluster's entry point
etcd Control Plane Key-value store that holds cluster state
kube-scheduler Control Plane Assigns Pods to appropriate nodes
kubelet Worker Node Runs and monitors Pods on the node
kube-proxy Worker Node Manages network rules, routes Service traffic

Pod: The Smallest Deployable Unit

A Pod is the smallest deployable unit in Kubernetes. One or more containers within a Pod share the same network namespace and storage volumes. In practice, most Pods contain a single container; multiple containers are used in patterns like sidecar.

pod.yaml
apiVersion: v1
kind: Pod
metadata:
  name: nginx-pod
  labels:
    app: nginx
spec:
  containers:
  - name: nginx
    image: nginx:1.25-alpine
    ports:
    - containerPort: 80
    resources:
      requests:
        memory: "64Mi"
        cpu: "100m"
      limits:
        memory: "128Mi"
        cpu: "250m"

⚠️ Important: Never create bare Pods in production. When a Pod is deleted, it won't be recreated. Use Deployments or StatefulSets instead - these resources automatically manage Pod lifecycle.

Deployment: Application Rollout and Updates

A Deployment ensures the desired number of Pods are always running. If a Pod crashes, it automatically recreates it. During updates, it uses a rolling update strategy for zero-downtime deployments. Under the hood, it manages ReplicaSet objects.

deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-app
spec:
  replicas: 3
  selector:
    matchLabels:
      app: web-app
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
  template:
    metadata:
      labels:
        app: web-app
    spec:
      containers:
      - name: web-app
        image: myapp:v1.2.0
        ports:
        - containerPort: 3000
        readinessProbe:
          httpGet:
            path: /health
            port: 3000
          initialDelaySeconds: 5
          periodSeconds: 10

During a Deployment update, maxSurge: 1 allows at most 1 extra Pod to be created, while maxUnavailable: 0 ensures no Pod becomes unavailable. This guarantees zero traffic interruption during rollouts.

terminal
# Create a Deployment
kubectl apply -f deployment.yaml

# Check rollout status
kubectl rollout status deployment/web-app

# Update image (triggers rolling update)
kubectl set image deployment/web-app web-app=myapp:v1.3.0

# Rollback an update
kubectl rollout undo deployment/web-app

# Scale replicas
kubectl scale deployment/web-app --replicas=5

Service: Stable Network Access to Pods

Pods receive ephemeral IP addresses that change when they're recreated. A Service places a stable network address in front of Pods, solving this problem. It automatically distributes traffic to Pods matching its label selector.

Service Type Access Use Case
ClusterIP Internal cluster only Inter-microservice communication
NodePort External via Node IP:Port Development and testing
LoadBalancer Cloud provider load balancer Production external traffic
ExternalName DNS CNAME redirect Accessing external services
service.yaml
apiVersion: v1
kind: Service
metadata:
  name: web-app-service
spec:
  type: ClusterIP
  selector:
    app: web-app
  ports:
  - protocol: TCP
    port: 80
    targetPort: 3000

This Service definition routes traffic from port 80 to port 3000 on all Pods with the app: web-app label. Other Pods within the cluster can reach this service at web-app-service:80.

Resource Isolation with Namespaces

Namespaces divide a single cluster into logical partitions. You can create separate namespaces for different teams, environments (dev/staging/prod), or projects, then apply resource quotas and access controls.

terminal
# Create namespaces
kubectl create namespace production
kubectl create namespace staging

# Deploy to a specific namespace
kubectl apply -f deployment.yaml -n production

# List resources in a namespace
kubectl get pods -n production

# Define a resource quota
kubectl apply -f - <<EOF
apiVersion: v1
kind: ResourceQuota
metadata:
  name: staging-quota
  namespace: staging
spec:
  hard:
    requests.cpu: "4"
    requests.memory: 8Gi
    limits.cpu: "8"
    limits.memory: 16Gi
    pods: "20"
EOF

Essential kubectl Commands

kubectl is the CLI tool for interacting with your Kubernetes cluster. Here are the commands you'll use most frequently:

terminal
# Cluster info
kubectl cluster-info
kubectl get nodes

# List resources
kubectl get pods,svc,deploy -o wide

# Pod details and logs
kubectl describe pod nginx-pod
kubectl logs -f web-app-7d9f8b6c4-x2k9p

# Exec into a Pod
kubectl exec -it web-app-7d9f8b6c4-x2k9p -- /bin/sh

# Port forwarding (local testing)
kubectl port-forward svc/web-app-service 8080:80

# Export YAML
kubectl get deploy web-app -o yaml

Production Readiness Checklist

  • Define Resource Limits Set CPU and memory requests/limits for every container. Pods without limits can consume all node resources.
  • Add Liveness and Readiness Probes Liveness probes restart crashed containers, readiness probes prevent traffic from reaching unready Pods.
  • Run At Least 2 Replicas A single replica means service outage during node failures. Use minimum 2 in production, 3+ for critical services.
  • Avoid the latest Image Tag Use pinned version tags (v1.2.0). The latest tag makes it impossible to track which version is running.

For Kubernetes auto-scaling, check our HPA (Horizontal Pod Autoscaling) guide. To standardize application deployment, see our Helm Chart guide. For container security, read our Docker Image Security guide. The official Kubernetes documentation and CNCF annual survey are valuable additional resources.

Frequently Asked Questions

Do I need to know Docker before learning Kubernetes?

Yes. Kubernetes manages containers, and its basic unit (Pod) hosts one or more containers. Understanding Docker image creation, Dockerfile syntax, and container lifecycle is a prerequisite for Kubernetes.

Is Kubernetes necessary for small projects?

For a single application with low traffic, Docker Compose is sufficient. Kubernetes adds value when you need coordination of multiple services, auto-scaling, and high availability. Consider it when you have 3-5+ microservices.

What's the difference between Minikube and kind?

Minikube creates a single-node cluster in a VM or container and offers add-ons like a dashboard. kind (Kubernetes in Docker) creates multi-node clusters inside Docker containers and runs faster in CI/CD environments.

Is a Pod the same as a container?

No. A Pod is Kubernetes' smallest deployable unit and can host one or more containers. Containers within the same Pod share the same IP address and volumes. In most cases, a Pod contains a single container.

How many servers do I need for a Kubernetes cluster?

For production, a minimum of 3 nodes is recommended: 1 control plane + 2 worker nodes. For high availability, use 3 control plane + 3 worker nodes. For development, a single node with Minikube is sufficient.

Conclusion

You've learned the fundamental building blocks of Kubernetes: Pods host containers, Deployments manage Pod lifecycle, and Services provide stable network access. Namespaces isolate resources, and kubectl lets you manage your cluster. As a next step, install Minikube locally and apply these YAML files hands-on.

Powerful Servers for Your Kubernetes Infrastructure

Run your Kubernetes cluster with high performance and low latency on Hosted Cloud servers.

Explore Cloud Server Plans →
A

Ahmet Yılmaz

Senior Infrastructure Engineer

With over 10 years of experience in cloud infrastructure and DevOps, Ahmet specializes in Kubernetes, Terraform, and high-availability architectures.

Comments coming soon