Kubernetes for Beginners: Deploy Your First Application in 10 Minutes

Kubernetes can seem overwhelming, but deploying your first application is simpler than you think. This beginner-friendly guide gets you from zero to deployed in 10 minutes.

Prerequisites

# Install kubectl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl && sudo mv kubectl /usr/local/bin/

# Install minikube for local development
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube

# Start cluster
minikube start

Core Concepts

  • Pod: Smallest deployable unit, runs one or more containers
  • Deployment: Manages pod replicas and rolling updates
  • Service: Exposes pods to network traffic
  • ConfigMap/Secret: External configuration

Step 1: Create a Deployment

# deployment.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
        image: nginx:alpine
        ports:
        - containerPort: 80
        resources:
          requests:
            cpu: 100m
            memory: 128Mi
          limits:
            cpu: 250m
            memory: 256Mi
        livenessProbe:
          httpGet:
            path: /
            port: 80
          initialDelaySeconds: 5
          periodSeconds: 10
kubectl apply -f deployment.yaml
kubectl get pods -w  # Watch pods come up

Step 2: Expose with a Service

# service.yaml
apiVersion: v1
kind: Service
metadata:
  name: my-app-service
spec:
  selector:
    app: my-app
  ports:
  - port: 80
    targetPort: 80
  type: LoadBalancer
kubectl apply -f service.yaml
minikube service my-app-service  # Opens in browser

Step 3: Configure with ConfigMaps

kubectl create configmap app-config \
  --from-literal=APP_ENV=production \
  --from-literal=LOG_LEVEL=info

Essential kubectl Commands

# View resources
kubectl get pods,svc,deploy
kubectl describe pod my-app-xxx
kubectl logs my-app-xxx -f

# Scaling
kubectl scale deployment my-app --replicas=5

# Rolling update
kubectl set image deployment/my-app my-app=nginx:latest
kubectl rollout status deployment/my-app

# Rollback
kubectl rollout undo deployment/my-app

# Debug
kubectl exec -it my-app-xxx -- /bin/sh
kubectl port-forward svc/my-app-service 8080:80

Common Pitfalls

  • Not setting resource limits (leads to noisy neighbors)
  • Using latest tag (not reproducible)
  • Skipping health checks (slow failure detection)
  • Hardcoding configuration (use ConfigMaps and Secrets)

Conclusion

Kubernetes is the industry standard for container orchestration. Start with these basics, then explore Helm charts, Ingress controllers, and GitOps workflows as you grow.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Privacy Policy · Contact · Sitemap

© 7Tech – Programming and Tech Tutorials