CraftedTemplate
Blog How to Host and Scale Containers with Kubernetes (Beginner’s DevOps Tutorial)

How to Host and Scale Containers with Kubernetes (Beginner’s DevOps Tutorial)

11/1/2025 • Festus Ayomike
How to Host and Scale Containers with Kubernetes (Beginner’s DevOps Tutorial)

If Docker helps you run one or two containers, Kubernetes helps you manage hundreds — across multiple servers, automatically. It’s the backbone of modern cloud platforms like Google Cloud, AWS, and Azure.

In this post, you’ll learn the fundamentals of Kubernetes (K8s) — how to host, scale, and maintain containerized apps using YAML manifests and a simple cluster setup.

See Also: How to Set Up a Complete CI/CD Pipeline with Jenkins (Automated Website Deployment Tutorial)

What Is Kubernetes?

Kubernetes (often called K8s) is an open-source orchestration system for managing containers at scale.

It handles:

  • Automatic deployment and scaling
  • Load balancing
  • Self-healing containers (restart if one fails)
  • Rolling updates and version control

In short, Kubernetes automates everything Docker can’t do alone.

Step 1: Install Kubernetes Locally (Minikube)

The easiest way to get started is with Minikube, a local Kubernetes cluster.

Install dependencies:

Code · batchfile
sudo apt install docker.io curl -y
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube

Start your local cluster:

Code · batchfile
minikube start

Step 2: Create a Deployment

A Deployment defines how your containers run and update.

Create a file named deployment.yaml:

Code · yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
spec:
  replicas: 3
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
      - name: my-app-container
        image: your-dockerhub-username/my-app:latest
        ports:
        - containerPort: 80

Apply it:

Code · batchfile
kubectl apply -f deployment.yaml

This creates 3 running instances (pods) of your container.

See Also: How to Set Up Automated Website Deployment with GitHub Actions (Complete CI/CD Tutorial)

Step 3: Expose the Deployment (Service)

Kubernetes services let your app be accessible to users.

Create a service.yaml:

Code · yaml
apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  type: NodePort
  selector:
    app: my-app
  ports:
    - port: 80
      targetPort: 80
      nodePort: 30007

Apply it:

Code · batchfile
kubectl apply -f service.yaml

Now, open your app:

Code · batchfile
minikube service my-service

Step 4: Scaling the App

Need to handle more traffic? Scale replicas easily:

Code · batchfile
kubectl scale deployment my-app --replicas=5

Kubernetes automatically creates two more containers.

Step 5: Rolling Updates

When you push a new image to Docker Hub, update Kubernetes:

Code · batchfile
kubectl set image deployment/my-app my-app-container=your-dockerhub-username/my-app:v2

It’ll gradually replace old containers with new ones — with zero downtime.

See Also: How to Deploy Containerized Apps with Docker Compose (Step-by-Step Guide)

Step 6: Deploying on the Cloud

You can deploy the same YAML files on:

  • Google Kubernetes Engine (GKE)
  • AWS EKS
  • Azure AKS

Each provider offers a managed control plane, so you only worry about your workloads — not server maintenance.

Step 7: Add Ingress and HTTPS

Use an Ingress Controller (like NGINX Ingress) to route traffic and add HTTPS with Let’s Encrypt. Example manifest:

Code · yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: my-app-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - host: mywebsite.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: my-service
            port:
              number: 80

Step 8: Monitor and Manage

Monitor running pods and deployments:

Code · batchfile
kubectl get pods
kubectl get deployments
kubectl get services

View logs:

Code · batchfile
kubectl logs <pod-name>

Delete everything when done:

Code · batchfile
kubectl delete all --all

Conclusion

Kubernetes is the next step in mastering hosting and DevOps.
It takes the power of Docker and adds automation, scalability, and reliability — perfect for modern production apps.

In the next Hosting Academy post, we’ll explore Continuous Deployment with GitLab CI/CD and how it compares to GitHub Actions and Jenkins.