Manage policies for Pod rightsizing - CLI

Prev Next

This topic describes how to use the CLI to change or remove the Pod rightsizing policy that manages a workload, and how to create and edit custom policies.

Change or remove a policy that manages a workload

You can change or remove Pod rightsizing on workloads from the cluster.

  • To change the policy that manages a workload, edit the policy selectors on the current and the desired policy.

    Tip

    To avoid an unmanaged gap, add the workload to the new policy before removing it from the old policy.

  • To remove a policy from a workload, remove the workload from policy selection, using the relevant solution:

    • Remove it from the policy’s  appList selector.

    • Update the policy label selector so it no longer matches the workload.

    • Remove the policy annotation from the workload.

    After removing, the workload may still be managed if it matches a different policy.

Manage custom policies

You can create, edit, and delete custom policies.

After you create a custom policy, you can apply it to workloads from the UI or CLI.

Create a custom policy

When creating a custom policy, all parameters need to be explicitly defined. Duplicating a policy creates a new custom policy resource. The duplicate is editable because it is a custom policy, even if the original policy was built-in.

To create a custom policy:

  1. From the cluster, duplicate an existing built-in policy.
    You can see the rightsizing parameters of the built-in policies at Built-in policy fixed parameter values.

  2. (Optional) Change parameters.
    You can see the full list of parameters and descriptions at Policy parameters reference.

  3. Save the policy with a new name.

Edit or delete a custom policy

When you edit policy parameters, those changes will affect future orchestrations. Running workloads will not be affected until the next orchestration.

You can delete a custom policy only if it is not assigned to any active workloads.

If you attempt to delete a custom policy that is assigned to workloads, the delete operation is blocked with a validation error. The error indicates how many workloads are still assigned to the policy and provides a way to view which workloads they are.

To edit or delete a policy, use Kubernetes CLI.

Common CLI commands

Replace the values inside [ ] with your values.

To do this

Use this command

List policies

kubectl get [policy-crd]

View a policy manifest

kubectl get [policy-crd] [policy-name] -o yaml

Create or update a policy

kubectl apply -f [policy-file].yaml

Add or update the workload policy annotation

kubectl annotate [workload-kind]/[workload-name] -n [namespace] [policy-annotation-key]=[policy-name] --overwrite

Remove the workload policy annotation

kubectl annotate [workload-kind]/[workload-name] -n [namespace] [policy-annotation-key]-

Delete a custom policy

kubectl delete [policy-crd] [policy-name]

© 2026 Zesty. All Rights Reserved

info@zesty.co