Namespace Actions
ScaleOps supports defining policies and automating a namespace using CRD or annotations.
Version 1.21.0 Update: ScaleOps introduced GitOps control for Replicas Optimization and Spot Optimization, as well as updates to Workload Rightsizing fields. For older versions, follow the backward compatibility notes to configure Workload Rightsizing via GitOps.
Annotations
You can use annotations to automate a namespace and set default policies for all its workloads.
Automating a namespace using an annotation
Control namespace’s automation with annotation.
Use scaleops.sh/default-auto: "true" to set default automation for Workload Rightsizing. To disable automation, delete the annotation or set its value to “false”.
For GPU Rightsizing, use scaleops.sh/default-gpu-auto: "true" to enable GPU automation for all workloads in the namespace.
UI action take precedence over annotations. Thus, UI action on a workload permanently disables the annotation’s effect for that workload.
Example:
apiVersion: v1
kind: Namespace
metadata:
annotations:
scaleops.sh/default-auto: "true"Setting namespace policy
Control namespace’s default Workload Rightsizing policy with annotation.
Use scaleops.sh/default-policy: {policy name} to set a specific policy for your namespace.
For GPU Rightsizing, use scaleops.sh/default-gpu-policy: {policy name} to set a default GPU policy for all workloads in the namespace.
UI action take precedence over annotations. Thus, UI action on a workload permanently disables the annotation’s effect for that workload.
Example:
apiVersion: v1
kind: Namespace
metadata:
annotations:
scaleops.sh/default-policy: production
scaleops.sh/default-gpu-policy: productionExcluding namespace
Exclude namespace from Workload Rightsizing automation by adding scaleops.sh/exclude-automation: "true" annotation.
ScaleOps will not allow automation on this excluded namespaces. If the namespace has automated workloads, adding the annotation will disable their automation.
Removing this annotation after excluding a namespace will allow the recommendations to be controlled again and will be automatically automated if the namespace or cluster is automated.
Exclude annotation takes precedence over other annotations and UI actions.
Example:
apiVersion: v1
kind: Namespace
metadata:
annotations:
scaleops.sh/exclude-automation: "true"Custom namespace labels Available in v1.26.10+
ScaleOps enhances namespace management by enabling you to include or exclude namespaces from automation based on namespace labels. This allows workloads to remain visible for troubleshooting while controlling their automation status.
Unlike ignoredNamespaces in the Helm chart (which completely hides namespaces from ScaleOps), namespace automation settings allow workloads to remain visible in the platform while excluding them from automation.
Configuration can be done via:
- Helm chart: Use the
namespaceAutomationsection in your values file. See Helm configuration reference. - Console UI: Navigate to
Settings → Generalto select labels. - ConfigMap: Create the
scaleops-custom-namespace-labelsConfigMap manually in thescaleops-systemnamespace.
Configuration Options
| Field | Description |
|---|---|
exclude-labels | Exclude namespaces from automation by label. Format: "key=value" or "key=regex". |
include-labels | Include namespaces in automation by label. Format: "key=value" or "key=regex". |
ConfigMap Example
apiVersion: v1
kind: ConfigMap
metadata:
name: scaleops-custom-namespace-labels
namespace: scaleops-system
data:
exclude-labels: '["env=staging", "team=test-.*"]'
include-labels: '["scaleops.sh/auto=true", "env=production"]'Helm Values Example
namespaceAutomation:
excludeLabels:
- "env=staging"
- "team=test-.*" # regex pattern for value
includeLabels:
- "scaleops.sh/auto=true"
- "env=production"Ignored Namespaces
Ignored namespaces are completely hidden from ScaleOps — workloads inside them are not displayed in the dashboard and not optimized in any way.
Configuration can be done via:
- Console UI: Navigate to
Settings → Generalunder Namespace operations → Ignored Namespaces. - Helm chart: Use the
ignoredNamespacesfield in your values file. It accepts a list of namespace names or regex patterns. See Helm configuration reference.
Default namespaces:
ignoredNamespaces:
- kube-system
- kube-public
- kube-node-lease
- "openshift.*"
- trident
- cluster-autoscalerExample — adding custom ignored namespaces:
ignoredNamespaces:
- kube-system
- kube-public
- kube-node-lease
- "openshift.*"
- trident
- cluster-autoscaler
- my-internal-namespace
- "temp-.*"Setting ignoredNamespaces in your Helm values replaces the default list entirely. Make sure to include the default namespaces if you want to keep them ignored.
Removing kube-system from ignored namespaces requires an additional Helm parameter alongside updating ignoredNamespaces. Without it, kube-system will remain ignored even if omitted from the list:
configParams:
overrideUserKubeSystemIgnoredNamespace: "true"Include both this parameter and your updated ignoredNamespaces list in the same Helm upgrade.
Ignored namespaces vs. automation exclusions: ignoredNamespaces completely hides namespaces from ScaleOps. If you want workloads to remain visible in the platform (for troubleshooting or monitoring) while excluding them from automation, use namespace automation settings or custom namespace labels instead.
Note: A few ScaleOps features still operate on ignored namespaces: custom workloads receive their ScaleOps label regardless, and Pod Placement and Spot Optimization continue to function on kube-system namespace.
CRD
The AutomatedNamespace CRD allows you to automate an entire namespace or set a policy for all workloads within that namespace across all optimization products.
To apply this, create an AutomatedNamespace CR in the specific namespace you wish to automate or set a policy for.
For granular control over each optimization product, use the following product-specific fields:
- Rightsizing:
rightsizeOptimize: true/false,defaultRightsizePolicy: "policy-name" - Replicas:
replicasOptimize: true/false,defaultReplicasPolicy: "policy-name" - Spot:
spotOptimize: true/false,defaultSpotPolicy: "policy-name" - GPU Rightsizing:
gpuOptimize: true/false,defaultGpuPolicy: "policy-name" - Java Optimization:
javaOptimize: true/false
By adding excludeAutomation field, you can exclude the entire namespace from automation.
Example - Configure namespace with ANS CRD:
apiVersion: analysis.scaleops.sh/v1alpha1
kind: AutomatedNamespace
metadata:
name: name-of-namespace # needs to match the name of the namespace
namespace: name-of-namespace # needs to match the name of the namespace
spec:
rightsizeOptimize: true # enable or disable rightsize automation for all workloads in the namespace
defaultRightsizePolicy: "production"
replicasOptimize: true # enable or disable replicas automation for all workloads in the namespace
defaultReplicasPolicy: "cost"
spotOptimize: true # enable or disable spot automation for all workloads in the namespace
defaultSpotPolicy: "spot-friendly"
gpuOptimize: true # enable or disable GPU rightsize automation for all workloads in the namespace
defaultGpuPolicy: "production"
javaOptimize: true # enable or disable Java optimization automation for all workloads in the namespace
excludeAutomation: false UI actions take precedence over CRD automation and policy assignment actions, if taken after the CRD is applied. In addition, the workload exclude annotation will take precedence over the CRD action.
Note: The optimize field is supported to enable or disable automation for Workload Rightsizing for backward compatibility. The defaultPolicy field is supported to apply a specific policy to all workloads for Workload Rightsizing for backward compatibility.