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:

LayerTechniquePurpose
Base SelectionNode selectorsTarget specific node pools (fundamental constraint)
Refined SelectionNode affinityExpress complex node requirements and preferences
Pod DistributionPod anti-affinityEnsure high availability across failure domains
Specialized AccessTolerationsAllow 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:

ScenarioTechniquesImplementation
High-Performance ComputingNode selectors + TolerationsTarget GPU node pools with specialized VM SKUs and use tolerations to access tainted GPU nodes
Multi-Region ResiliencePod anti-affinity + Node affinitySpread pods across regions/zones and prefer nodes with specific characteristics
Cost OptimizationNode selectors + TolerationsTarget Spot VM node pools for non-critical workloads, with tolerations for Spot eviction
Stateful WorkloadsNode affinity + Pod affinityKeep pods close to their data and maintain proximity for related services
Mixed Windows/LinuxNode selectors + TolerationsDirect Windows containers to Windows nodes with appropriate tolerations

Scheduling Strategy Best Practices

When implementing complex scheduling strategies:

  1. Start simple: Begin with node selectors before adding more complex constraints
  2. Test thoroughly: Verify that pods schedule as expected in various scenarios
  3. Monitor unschedulable pods: Watch for pods that can’t be scheduled due to conflicting constraints
  4. Consider fallbacks: Use preferred (soft) constraints when appropriate to avoid pods remaining unscheduled
  5. 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.