All posts

Kubernetes Fundamentals: Complete Orchestration Guide

· Pavan Y N · kubernetes, k8s, orchestration, containers


# title: "Kubernetes Fundamentals: Complete Orchestration Guide" date: "2025-10-21" tags: ["kubernetes", "k8s", "orchestration", "containers"]

Kubernetes Fundamentals: Complete Orchestration Guide

Kubernetes (K8s) is the industry-standard container orchestration platform. This guide covers architecture, core concepts, and practical implementation.

# What is Kubernetes?

Kubernetes orchestrates containerized applications across clusters of machines, providing:

  • →Automated Deployment: Deploy containers automatically
  • →Scaling: Scale applications up or down
  • →Self-Healing: Restart failed containers
  • →Load Balancing: Distribute traffic efficiently
  • →Rolling Updates: Zero-downtime deployments

# Kubernetes Architecture

## Master Node Components

  • →API Server: Central management point
  • →Scheduler: Assigns pods to nodes
  • →Controller Manager: Maintains desired state
  • →etcd: Distributed key-value store

## Worker Node Components

  • →Kubelet: Node agent
  • →Kube-proxy: Network proxy
  • →Container Runtime: Docker, containerd, CRI-O
  • →Pods: Running containers

# Core Concepts

## Pods

Smallest deployable unit:

code
apiVersion: v1
kind: Pod
metadata:
  name: nginx-pod
spec:
  containers:
  - name: nginx
    image: nginx:latest
    ports:
    - containerPort: 80

## Deployments

Manage replica sets:

code
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:latest
        ports:
        - containerPort: 80

## Services

Network abstraction:

code
apiVersion: v1
kind: Service
metadata:
  name: nginx-service
spec:
  selector:
    app: nginx
  ports:
  - protocol: TCP
    port: 80
    targetPort: 80
  type: LoadBalancer

# Essential kubectl Commands

code
# Get resources
kubectl get pods
kubectl get deployments
kubectl get services

# Describe resources
kubectl describe pod <pod-name>
kubectl describe deployment <deployment-name>

# View logs
kubectl logs <pod-name>
kubectl logs -f <pod-name>  # Follow logs

# Execute commands in pod
kubectl exec -it <pod-name> -- /bin/bash

# Apply configuration
kubectl apply -f deployment.yaml

# Delete resources
kubectl delete pod <pod-name>
kubectl delete deployment <deployment-name>

# ConfigMaps and Secrets

## ConfigMap

Store configuration data:

code
apiVersion: v1
kind: ConfigMap
metadata:
  name: app-config
data:
  database_url: "postgres://db:5432"
  log_level: "info"

## Secret

Store sensitive data:

code
apiVersion: v1
kind: Secret
metadata:
  name: app-secret
type: Opaque
data:
  password: cGFzc3dvcmQxMjM=  # base64 encoded

# Troubleshooting Pods

## Common Issues

Pod Pending:

code
kubectl describe pod <pod-name>
# Check: Insufficient resources, node selector mismatch

CrashLoopBackOff:

code
kubectl logs <pod-name>
# Check: Application errors, missing dependencies

ImagePullBackOff:

code
kubectl describe pod <pod-name>
# Check: Image name, registry access, credentials

# Resource Management

## Resource Requests and Limits

code
resources:
  requests:
    memory: "64Mi"
    cpu: "250m"
  limits:
    memory: "128Mi"
    cpu: "500m"

# Health Checks

## Liveness Probe

code
livenessProbe:
  httpGet:
    path: /health
    port: 8080
  initialDelaySeconds: 30
  periodSeconds: 10

## Readiness Probe

code
readinessProbe:
  httpGet:
    path: /ready
    port: 8080
  initialDelaySeconds: 5
  periodSeconds: 5

# Best Practices

  1. •Use Namespaces: Organize resources
  2. •Set Resource Limits: Prevent resource exhaustion
  3. •Implement Health Checks: Enable self-healing
  4. •Use Labels: Organize and select resources
  5. •Version Images: Never use :latest in production
  6. •Use ConfigMaps/Secrets: Externalize configuration
  7. •Monitor Everything: Track metrics and logs

# Conclusion

Kubernetes provides powerful orchestration capabilities. Master these fundamentals, practice with real deployments, and gradually explore advanced features.

# Next Steps

  1. •Set up local Kubernetes cluster (minikube/kind)
  2. •Deploy sample applications
  3. •Practice kubectl commands
  4. •Learn about Helm charts
  5. •Explore advanced features (Ingress, StatefulSets)

Happy orchestrating! ☸️