Combining Scheduling Techniques
For complex workloads with specific requirements, you can combine multiple scheduling techniques to implement sophisticated placement strategies. This approach enables precise control over workload placement to optimize resource utilization, availability, and performance.
Layered Scheduling Constraints
By strategically combining scheduling methods, you can implement layered constraints:
Layer | Technique | Purpose |
---|---|---|
Base Selection | Node selectors | Target specific node pools (fundamental constraint) |
Refined Selection | Node affinity | Express complex node requirements and preferences |
Pod Distribution | Pod anti-affinity | Ensure high availability across failure domains |
Specialized Access | Tolerations | Allow access to tainted/specialized nodes |
Example: Multi-Technique Deployment
The following example shows a sophisticated deployment that utilizes multiple scheduling techniques. This deployment does the following:
- Selects nodes with a “worker” role using a node selector
- Requires nodes with SSD storage using node affinity
- Allows scheduling on GPU nodes with a specific toleration
apiVersion: apps/v1
kind: Deployment
metadata:
name: multi-technique-app
spec:
replicas: 3
selector:
matchLabels:
app: multi-technique-app
template:
metadata:
labels:
app: multi-technique-app
spec:
nodeSelector:
kubernetes.io/role: worker
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: disktype
operator: In
values:
- ssd
tolerations:
- key: "dedicated"
operator: "Equal"
value: "gpu"
effect: "NoSchedule"
containers:
- name: app-container
image: my-app-image
Common Combined Scheduling Patterns
Here are some practical combined scheduling patterns for common scenarios in AKS:
Scenario | Techniques | Implementation |
---|---|---|
High-Performance Computing | Node selectors + Tolerations | Target GPU node pools with specialized VM SKUs and use tolerations to access tainted GPU nodes |
Multi-Region Resilience | Pod anti-affinity + Node affinity | Spread pods across regions/zones and prefer nodes with specific characteristics |
Cost Optimization | Node selectors + Tolerations | Target Spot VM node pools for non-critical workloads, with tolerations for Spot eviction |
Stateful Workloads | Node affinity + Pod affinity | Keep pods close to their data and maintain proximity for related services |
Mixed Windows/Linux | Node selectors + Tolerations | Direct Windows containers to Windows nodes with appropriate tolerations |
Scheduling Strategy Best Practices
When implementing complex scheduling strategies:
- Start simple: Begin with node selectors before adding more complex constraints
- Test thoroughly: Verify that pods schedule as expected in various scenarios
- Monitor unschedulable pods: Watch for pods that can’t be scheduled due to conflicting constraints
- Consider fallbacks: Use preferred (soft) constraints when appropriate to avoid pods remaining unscheduled
- Document decisions: Clearly document the purpose of each scheduling constraint for future maintainers
By thoughtfully combining scheduling techniques, you can create robust, efficient, and resilient deployment patterns that fully leverage AKS’s capabilities.