Back to Policies

Add CAST AI Removal Disabled

CAST AI will not downscale a node that includes a pod with the autoscaling.cast.ai/removal-disabled="true" label on it, this protects sensitive workloads from being evicted and can be attributed to any pod to protect against unwanted downscaling. This policy will mutate jobs and cronjobs to add the removal-disabled label to protect against eviction.

View on GitHub

Policy Definition

apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: add-castai-removal-disabled
annotations:
policies.kyverno.io/title: Add CAST AI Removal Disabled
policies.kyverno.io/category: CAST AI
policies.kyverno.io/severity: medium
policies.kyverno.io/subject: Job, CronJob
kyverno.io/kyverno-version: "1.9"
kyverno.io/kubernetes-version: "1.25"
policies.kyverno.io/description: "CAST AI will not downscale a node that includes a pod with the autoscaling.cast.ai/removal-disabled=\"true\" label on it, this protects sensitive workloads from being evicted and can be attributed to any pod to protect against unwanted downscaling. This policy will mutate jobs and cronjobs to add the removal-disabled label to protect against eviction. "
spec:
rules:
- name: do-not-evict-jobs
match:
any:
- resources:
kinds:
- Job
mutate:
patchStrategicMerge:
spec:
template:
metadata:
labels:
autoscaling.cast.ai/removal-disabled: "true"
- name: do-not-evict-cronjobs
match:
any:
- resources:
kinds:
- CronJob
mutate:
patchStrategicMerge:
spec:
jobTemplate:
spec:
template:
metadata:
labels:
autoscaling.cast.ai/removal-disabled: "true"

Related Policies