kubernetes

Kubernetes for Beginners: Complete Container Orchestration Guide (2025)

Learn Kubernetes from zero. This beginner-friendly guide covers pods, deployments, services, and more with hands-on examples you can follow along.

CE

CloudElevate Team

DevOps Engineers

📝kubernetes

Kubernetes (K8s) has become the industry standard for container orchestration. If you've heard about Kubernetes but find it overwhelming, this guide is for you. We'll break down complex concepts into simple terms and get you running your first application on Kubernetes.

What is Kubernetes?

Kubernetes is an open-source platform that automates the deployment, scaling, and management of containerized applications. Think of it as a smart manager for your Docker containers.

Instead of manually starting containers on servers, Kubernetes:

  • Automatically schedules containers on available nodes
  • Restarts containers if they crash
  • Scales applications up or down based on demand
  • Manages networking between containers
  • Handles rolling updates with zero downtime

Core Kubernetes Concepts

Cluster

A Kubernetes cluster consists of nodes (machines) that run your applications. It has:

  • Control Plane: The brain that manages the cluster
  • Worker Nodes: Machines that run your containers

Pod

A Pod is the smallest deployable unit in Kubernetes. It contains one or more containers that share storage and network. Think of it as a wrapper around your container(s).

pod.yaml
apiVersion: v1
kind: Pod
metadata:
  name: my-first-pod
spec:
  containers:
    - name: nginx
      image: nginx:latest
      ports:
        - containerPort: 80

Deployment

A Deployment manages a set of identical Pods. It ensures the desired number of Pods are always running and handles updates gracefully.

deployment.yaml
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:1.25
          ports:
            - containerPort: 80

Service

A Service exposes your Pods to network traffic. Since Pod IPs change, Services provide a stable endpoint.

service.yaml
apiVersion: v1
kind: Service
metadata:
  name: nginx-service
spec:
  selector:
    app: nginx
  ports:
    - port: 80
      targetPort: 80
  type: LoadBalancer

Setting Up Your First Kubernetes Environment

Option 1: Minikube (Local Development)

Minikube runs a single-node Kubernetes cluster on your laptop:

minikube.sh
# Install minikube (macOS)
brew install minikube

# Start cluster
minikube start

# Check status
minikube status

# Access dashboard
minikube dashboard

Option 2: Kind (Kubernetes in Docker)

Kind runs Kubernetes clusters using Docker containers as nodes:

kind.sh
# Install kind
brew install kind

# Create cluster
kind create cluster --name my-cluster

# List clusters
kind get clusters

Hands-On: Deploy Your First Application

Let's deploy a simple web application step by step.

Step 1: Create a Deployment

step1.sh
# Create deployment
kubectl create deployment hello-world --image=nginx:latest

# View deployment
kubectl get deployments

# View pods
kubectl get pods

Step 2: Expose with a Service

step2.sh
# Expose the deployment
kubectl expose deployment hello-world --port=80 --type=NodePort

# Get service info
kubectl get services

# Access the app (minikube)
minikube service hello-world

Step 3: Scale the Application

step3.sh
# Scale to 5 replicas
kubectl scale deployment hello-world --replicas=5

# Watch pods scale up
kubectl get pods -w

# Scale back down
kubectl scale deployment hello-world --replicas=2

Step 4: Update the Application

step4.sh
# Update image (rolling update)
kubectl set image deployment/hello-world nginx=nginx:1.25

# Watch the rollout
kubectl rollout status deployment/hello-world

# Rollback if needed
kubectl rollout undo deployment/hello-world

Essential kubectl Commands

Here are the kubectl commands you'll use daily:

kubectl.sh
# View resources
kubectl get pods                    # List all pods
kubectl get deployments             # List deployments
kubectl get services                # List services
kubectl get all                     # List everything

# Describe resources (detailed info)
kubectl describe pod <pod-name>
kubectl describe deployment <name>

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

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

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

# Apply YAML files
kubectl apply -f deployment.yaml
kubectl delete -f deployment.yaml

Configuration with ConfigMaps and Secrets

ConfigMaps for Non-Sensitive Data

configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: app-config
data:
  DATABASE_HOST: "postgres.default.svc"
  LOG_LEVEL: "info"

Secrets for Sensitive Data

secret.yaml
apiVersion: v1
kind: Secret
metadata:
  name: app-secrets
type: Opaque
data:
  DB_PASSWORD: cGFzc3dvcmQxMjM=  # base64 encoded

What's Next?

Once you're comfortable with the basics, explore:

  • Ingress Controllers - Route external traffic
  • Persistent Volumes - Store data
  • Helm Charts - Package applications
  • Namespaces - Organize resources
  • RBAC - Security and access control
  • Horizontal Pod Autoscaler - Auto-scaling

FAQ

Do I need to know Docker first?

Yes, basic Docker knowledge is essential. Kubernetes orchestrates containers, so understanding container concepts is crucial.

Which managed Kubernetes should I use?

EKS (AWS), GKE (Google), or AKS (Azure) are all excellent. GKE is often considered the most developer-friendly for beginners.

Is Kubernetes overkill for small apps?

For very small apps, yes. Consider simpler options like Docker Compose, ECS, or App Runner. Kubernetes shines when you have multiple services and need advanced orchestration.

Ready to Run Kubernetes in Production?

CloudElevate helps teams adopt Kubernetes the right way. From initial setup to production optimization, we've deployed Kubernetes for startups and enterprises alike.

Contact us at info@cloudelevate.ai for Kubernetes consulting and training.

Tagged with

KubernetesK8sContainersDockerContainer OrchestrationDevOpsCloud NativePods

Ready to elevate your cloud infrastructure?

Get a free consultation with our DevOps experts.

View Services