GKE - Google Kubernetes Engine
Plan Deploy And Manage Workloads On GKE
Plan workload deployment to GKE
In this lesson, you’ll learn how to plan workload deployment and manage resources on a Google Kubernetes Engine (GKE) cluster. We’ll cover the four primary workload types—stateless, stateful, batch, and daemons—and compare imperative versus declarative management approaches.
Workload Type | Use Case | Kubernetes Object |
---|---|---|
Stateless | Web front-ends, application servers | Deployment |
Stateful | Databases, distributed coordination | StatefulSet |
Batch Jobs | Data processing, notification emails | Job |
Daemons | Logging, monitoring, background agents | DaemonSet |
To deploy and manage containerized applications on GKE, you define controller objects in YAML files and apply them with kubectl
or via the Kubernetes API.
GKE supports several workload types, including stateless applications, stateful applications, batch jobs, and daemons.
Stateless Applications
Stateless applications do not persist data internally; all session state is managed by clients or external services. They’re ideal for horizontal scaling and rolling updates.
- Examples:
- NGINX
- Apache Tomcat
- Other web servers
- Primary object: Deployment
Pods under a Deployment are interchangeable and ephemeral, allowing you to scale out or update without data loss.
Stateful Applications
Stateful applications require persistent storage to retain data across restarts and replicas. Use PersistentVolumes and PersistentVolumeClaims for durable storage.
- Examples:
- MongoDB
- Apache ZooKeeper
- Primary object: StatefulSet
StatefulSet pods maintain unique network identities and stable storage. Updates and scaling follow a strict, ordered process.
Note
StatefulSet guarantees that each pod is assigned the same name and storage on every restart, ensuring data consistency.
Batch Jobs
Batch jobs run to completion and are well suited for parallel, finite tasks.
- Examples:
- Sending notification emails
- Video rendering
- Complex numerical computations
- Primary object: Job
A Job runs Pods until they succeed, with controls for total completions and maximum parallelism.
Daemons
Daemon workloads run continuously on selected nodes to provide cluster-wide services.
- Examples:
- Fluentd (log collection)
- Monitoring agents
- Primary object: DaemonSet
A DaemonSet ensures one Pod per node (or per label selector), making it perfect for node-level background tasks.
Imperative vs. Declarative Management
GKE offers both imperative and declarative methods for managing workload objects:
Imperative Commands
Use one-offkubectl run
,kubectl create
, orkubectl delete
commands for quick changes and immediate feedback.Declarative Object Configuration
Store complete resource definitions in YAML and apply them withkubectl apply
. Keep these files in version control for an audit trail.Directory-Based Declarative Configuration
Organize YAML files in directories and runkubectl apply --recursive
to apply updates across many resources. This scales well for large projects.
References
Watch Video
Watch video content