You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Kubernetes provides several workload controllers for running containers in a GKE cluster. Each controller is designed for a specific type of application. Understanding when to use each one is fundamental to building reliable applications on GKE.
A Deployment is the most common workload controller. It manages a set of identical, stateless pods and handles rolling updates, rollbacks, and scaling. Deployments are the right choice for stateless applications such as web servers, APIs, and microservices.
| Feature | Description |
|---|---|
| Rolling updates | New pods are gradually created while old pods are terminated |
| Rollback | Revert to any previous revision |
| Scaling | Scale up or down by changing the replica count |
| Self-healing | Failed pods are automatically replaced |
| ReplicaSet | A Deployment manages a ReplicaSet, which manages pods |
apiVersion: apps/v1
kind: Deployment
metadata:
name: web-api
labels:
app: web-api
spec:
replicas: 3
selector:
matchLabels:
app: web-api
template:
metadata:
labels:
app: web-api
spec:
containers:
- name: web-api
image: europe-west2-docker.pkg.dev/my-project/repo/web-api:v1.2.0
ports:
- containerPort: 8080
resources:
requests:
cpu: 250m
memory: 256Mi
limits:
cpu: 500m
memory: 512Mi
livenessProbe:
httpGet:
path: /healthz
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
readinessProbe:
httpGet:
path: /ready
port: 8080
initialDelaySeconds: 5
periodSeconds: 5
spec:
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1 # 1 extra pod during update
maxUnavailable: 0 # No pods unavailable during update (zero-downtime)
StatefulSets manage stateful applications that require stable network identities, persistent storage, and ordered deployment. They are used for databases, message queues, and distributed systems like ZooKeeper, Kafka, and Elasticsearch.
| Feature | Description |
|---|---|
| Stable pod names | Pods are named sequentially (my-app-0, my-app-1, my-app-2) |
| Stable network identity | Each pod gets a DNS name via a Headless Service |
| Persistent storage | Each pod gets its own PersistentVolumeClaim that persists across restarts |
| Ordered operations | Pods are created, updated, and deleted in order |
| Ordered scaling | Scale-up creates pods sequentially; scale-down removes them in reverse order |
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.