DaemonSet recommendation groups

🚧

Limited Availability Feature

This feature is currently available through feature flags. Contact us to enable access for your organization.

DaemonSet recommendation groups partition usage samples by a node-label value and compute a separate recommendation for each group. With the InstanceType preset, each group contains pods on nodes of the same instance type. Workload Autoscaler also keeps the unscoped recommendation as a fallback.

Use recommendation groups when observed resource usage differs between groups of nodes. To size each pod as a percentage of its node's allocatable resources instead, use scale workloads by node size.

When you configure both features, a matching group supplies concrete requests and limits. If no group or container matches, the pod uses the unscoped recommendation, including its resourceStrategy.

When usage is the same on every node, recommendation groups add no benefit. Each group has fewer usage samples than the whole workload, so confidence filtering is more likely to drop a group.

How it works

  1. Workload Autoscaler reads the scope configuration from the workload.
  2. It resolves the configured scope label for every running pod.
  3. It groups usage samples by the label value and computes a separate recommendation for each group.
  4. It computes the unscoped recommendation for the whole workload at the same time.
  5. It writes the unscoped recommendation and the group recommendations to the Recommendation custom resource.

Each group takes the scope label's value as its name. With the InstanceType preset, the scope label is node.kubernetes.io/instance-type. For example, pods on m5.large nodes form the group m5.large.

If Kubernetes reschedules a pod to a node with a different scope value, the pod belongs to the group that matches the new value.

Pods on nodes without the configured scope label never form a group. The unscoped recommendation covers them. A group never fails the whole recommendation. When Workload Autoscaler drops every group, only the unscoped recommendation remains.

When you set CPU or memory optimization to read-only, the group carries no value for that resource. The unscoped recommendation behaves the same way.

At pod admission, Workload Autoscaler resolves the pod's group and stamps that group's requests and limits into the pod. Running pods keep their current requests until you recreate them. Recommendations with groups never resize pods in place.

Prerequisites

Recommendation groups require this minimum component version:

ComponentMinimum version
castai-workload-autoscalerv1.11.0

Recommendation groups also require:

  • Feature access: Your organization must have access to the feature. Contact us to enable it.
  • Workload kind: DaemonSets only. Other workload kinds ignore the scope and keep a single recommendation.
  • Node labels: Nodes must carry the configured scope label. With the InstanceType preset, this label is node.kubernetes.io/instance-type. Pods on nodes without the configured label use the unscoped recommendation.

Configuration

You can set the scope on a workload annotation or on a scaling policy. Both accept the InstanceType preset. As with every Workload Autoscaler setting, a workload annotation takes precedence over the policy.

Workload annotation

Add the scope field to the vertical section of the configuration annotation, with the InstanceType preset:

metadata:
  annotations:
    workloads.cast.ai/configuration: |
      vertical:
        scope:
          preset: InstanceType

The preset scopes the recommendation by the node.kubernetes.io/instance-type node label. Instead of the preset, the annotation also accepts any custom node label key:

vertical:
  scope:
    nodeLabel:
      key: custom-label

Configure custom scope labels before nodes join the cluster. Node autoscaling cannot use labels added later by webhooks or node agents when it simulates capacity.

Set exactly one of preset or nodeLabel. See Annotations reference for the full field reference.

Scaling policy

For API policy updates, set vertical.scope.preset to SCOPE_PRESET_INSTANCE_TYPE:

vertical:
  scope:
    preset: SCOPE_PRESET_INSTANCE_TYPE

Every DaemonSet that matches the policy then uses instance-type recommendation groups. A workload annotation takes precedence over this policy setting. Use the same preset value when you configure a scaling policy through Terraform.

Example

The Recommendation custom resource keeps the unscoped recommendation in the usual recommendation fields, and adds a spec.scope block with the groups:

spec:
  scope:
    type: NODE_LABEL
    key: node.kubernetes.io/instance-type
    groups:
      - value: m5.large
        recommendation:
          - containerName: app
            requests:
              cpu: 250m
              memory: 256Mi
      - value: c6i.4xlarge
        recommendation:
          - containerName: app
            requests:
              cpu: 1200m
              memory: 2Gi
FieldDescription
spec.scope.typeThe scope mechanism. NODE_LABEL is the only value.
spec.scope.keyThe node label the scope partitions by. node.kubernetes.io/instance-type with the InstanceType preset.
spec.scope.groups[]One entry per scope value that has data.
spec.scope.groups[].valueThe scope value, for example the instance type m5.large.
spec.scope.groups[].recommendation[]Per-container requests and limits for that group.

Workload Autoscaler applies a group to a pod only when both conditions hold:

  • The pod's node has the group's value for the configured scope label.
  • The group contains that container.

In every other case, the pod uses the unscoped recommendation. This covers pods on nodes without the configured scope label and containers that have no usage data in the matching group.

Limitations

  • One mechanism. Recommendation groups always partition by node label value.
  • Nodes must carry the configured scope label. A pod on a node without that label uses the unscoped recommendation. With the InstanceType preset, the required label is node.kubernetes.io/instance-type.
  • Confidence filtering can drop a group. When the workload configuration requires confidence, Workload Autoscaler drops groups whose confidence is lower than the threshold. It also drops groups with no confidence data. Each group's confidence comes from its own metrics. An OOM kill sets the unscoped recommendation's confidence to the maximum. It does not increase a group's confidence, so Workload Autoscaler can still drop that group after an OOM kill.
  • At most 100 groups. Over that limit, Workload Autoscaler drops the groups and keeps the unscoped recommendation.
  • No per-group settings. Percentiles, limits, constraints, and look-back periods stay workload-level, and every group inherits them.
  • JVM optimization and HPA simulation exclude recommendation groups. Workloads with JVM optimization enabled, and workloads eligible for HPA simulation, keep a single recommendation.
  • Groups change only on regeneration. A new scope value, or a node that starts reporting the configured scope label, joins the next recommendation cycle.
  • Labels that appear only at runtime are not visible to node autoscaling. Node autoscaling cannot use a label added after a node joins when simulating new nodes for capacity planning. It plans pods that use such a scope label against current requests instead of group requests. The InstanceType preset is not affected because cloud-registered instances already carry node.kubernetes.io/instance-type.

Troubleshooting

Open the recommendation-generated event in the Event log's JSON view and inspect its scope debug data. Recommendation events include scope debug data by default when they apply changes. Other recommendation outcomes can omit this data.

  • The recommendation has no groups. Confirm the prerequisites first, then check:
    • The workload has no JVM optimization and does not qualify for HPA simulation.
    • The fleet has 100 or fewer groups.
    • The scope debug data's fallbackReason explains why the recommendation as a whole fell back to the unscoped recommendation. Per-group causes are listed separately in droppedGroups when groups are dropped.
  • The scope annotation is rejected. scope must be an object with exactly one of nodeLabel.key or preset. A plain string such as scope: topology.kubernetes.io/zone is invalid, and so is setting both fields.
  • The scope setting has no effect, or a policy update fails. The cluster's castai-workload-autoscaler is older than v1.11.0. Upgrade the component.
  • One group is missing. Workload Autoscaler drops a group in two cases: no metrics in the look-back window, or confidence lower than the threshold. Check that pods of that group report metrics. Also check that the group has enough history. The scope debug data's droppedGroups lists the affected group and its drop reason.
  • A pod gets the unscoped request while its neighbours get a group value. The pod's node lacks the configured scope label, or the group has no data for that container. Check the configured scope label first. With the InstanceType preset, this is node.kubernetes.io/instance-type.

Next steps


Did this page help you?