Getting Started with Kubernetes
A practical introduction to container orchestration with Kubernetes — from pods and services to deploying your first production-ready cluster.
Kubernetes has become the de facto standard for container orchestration. Whether you're managing a handful of microservices or scaling to thousands, understanding the core building blocks is essential.
Why Kubernetes?
Containers solved the "it works on my machine" problem, but running containers in production introduces new challenges:
- Scaling — How do you spin up more instances when traffic spikes?
- Self-healing — What happens when a container crashes at 3 AM?
- Service discovery — How do containers find and talk to each other?
- Rolling updates — How do you deploy without downtime?
Kubernetes answers all of these with a declarative model. You describe what you want, and Kubernetes makes it happen.
Core Concepts
Pods
A Pod is the smallest deployable unit in Kubernetes. It wraps one or more containers that share networking and storage:
apiVersion: v1
kind: Pod
metadata:
name: my-app
labels:
app: my-app
spec:
containers:
- name: app
image: my-app:1.0.0
ports:
- containerPort: 8080
resources:
requests:
memory: "128Mi"
cpu: "250m"
limits:
memory: "256Mi"
cpu: "500m"
Deployments
You rarely create Pods directly. A Deployment manages a set of identical Pods and handles rolling updates:
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: app
image: my-app:1.0.0
ports:
- containerPort: 8080
Services
A Service gives your Pods a stable network identity and load-balances traffic across them:
apiVersion: v1
kind: Service
metadata:
name: my-app-service
spec:
selector:
app: my-app
ports:
- port: 80
targetPort: 8080
type: ClusterIP
Setting Up a Local Cluster
The fastest way to start experimenting is with minikube or kind:
# Install kind
go install sigs.k8s.io/kind@latest
# Create a cluster
kind create cluster --name dev
# Verify it's running
kubectl cluster-info
kubectl get nodes
Your First Deployment
Once your cluster is running, deploy an application:
# Create the deployment
kubectl apply -f deployment.yaml
# Watch pods come up
kubectl get pods -w
# Expose it locally
kubectl port-forward svc/my-app-service 8080:80
Open http://localhost:8080 and you should see your app running.
What's Next
This barely scratches the surface. In upcoming posts, I'll cover:
- Namespaces and RBAC for multi-tenant clusters
- Helm charts for packaging applications
- Ingress controllers for routing external traffic
- Monitoring with Prometheus and Grafana
The key takeaway: Kubernetes is complex, but the core concepts are straightforward. Master Pods, Deployments, and Services, and you have a solid foundation to build on.