Workload Types
Rancher aggregates multiple Kubernetes workload types into a single Workload resource:Deployment
Stateless applications with rolling updates
StatefulSet
Stateful applications requiring stable identities
DaemonSet
One pod per node (monitoring, logging agents)
CronJob
Scheduled batch jobs
Workload Resource
Frompkg/api/norman/customization/workload/workload.go:48
Workload Spec
string
required
Name of the workload
string
required
Namespace where the workload is deployed
string
required
Type of workload:
deployment, statefulSet, daemonSet, cronJob, jobarray<Container>
required
integer
Number of replicas (for Deployment, StatefulSet, ReplicaSet)
array<Volume>
Volumes available to containers
map<string, string>
Labels for the workload
map<string, string>
Annotations for the workload
Scheduling
boolean
Whether the deployment is paused (Deployment only)
Workload Status
string
Current state:
active, updating, paused, stoppedinteger
Desired number of replicas
integer
Number of ready replicas
integer
Number of available replicas
Number of unavailable replicas
array<PublicEndpoint>
Exposed endpoints for the workload
Create Deployment
Deploy a stateless application:Create StatefulSet
Deploy a stateful application with persistent storage:Create DaemonSet
Deploy a pod on every node:Create CronJob
Schedule a recurring batch job:List Workloads
Retrieve all workloads in a project:Filter by Namespace
Get Workload
Retrieve a specific workload:Response Example
Update Workload
Update workload configuration:Scale Workload
Update the scale:Delete Workload
Delete a workload:Workload Actions
Frompkg/api/norman/customization/workload/workload.go:69
Pause Deployment
Pause a deployment to prevent updates:Resume Deployment
Resume a paused deployment:Redeploy
Force a redeployment of the workload:Rollback
Rollback to a previous revision:Get Revisions
List deployment revisions:Resource Requirements
Define CPU and memory for containers:Always set resource requests and limits to ensure proper scheduling and prevent resource exhaustion.
Environment Variables
Static Values
From ConfigMap
From Secret
Scheduling
Node Selection
Tolerations
Affinity Rules
Best Practices
Set Resource Limits
Set Resource Limits
Always define resource requests and limits:
- Requests ensure proper scheduling
- Limits prevent resource hogging
- Required for QoS guarantees
Use Health Checks
Use Health Checks
Configure liveness and readiness probes:
- Liveness: Restart unhealthy containers
- Readiness: Control traffic routing
- Startup: Handle slow-starting applications
Leverage Labels
Leverage Labels
Use meaningful labels for organization:
app: Application nameversion: Application versioncomponent: Application componentenvironment: Deployment environment
Store Secrets Securely
Store Secrets Securely
Never hardcode sensitive data:
- Use Kubernetes Secrets
- Reference secrets via environment variables
- Rotate secrets regularly
Configure Rolling Updates
Configure Rolling Updates
For Deployments, configure update strategy:
maxSurge: Extra pods during updatemaxUnavailable: Pods that can be down- Balance between speed and availability
Monitoring Workloads
Check Workload Status
View Pod Logs
Execute Commands
Next Steps
Services
Expose workloads with services
Ingress
Configure external access
Volumes
Attach persistent storage
Monitoring
Monitor application metrics