All Policies
Enable Kubecost Continuous Rightsizing
Kubecost is able to modify container resource requests and limits dynamically based upon observed utilization patterns and recommendations. This provides an easy way to automatically improve allocation of cluster resources by increasing efficiency. This policy will annotate all Deployments which have the label `env=test` with `request.autoscaling.kubecost.com/enabled="true"` if the annotation is not already present. Other annotations may be added according to need and users should see the documentation for a complete list.
Policy Definition
/kubecost/enable-kubecost-continuous-rightsizing/enable-kubecost-continuous-rightsizing.yaml
1apiVersion: kyverno.io/v1
2kind: ClusterPolicy
3metadata:
4 name: enable-kubecost-continuous-rightsizing
5 annotations:
6 policies.kyverno.io/title: Enable Kubecost Continuous Rightsizing
7 policies.kyverno.io/category: Kubecost
8 policies.kyverno.io/severity: medium
9 policies.kyverno.io/subject: Deployment, Annotation
10 kyverno.io/kyverno-version: 1.10.0
11 kyverno.io/kubernetes-version: "1.25"
12 policies.kyverno.io/description: >-
13 Kubecost is able to modify container resource requests and limits dynamically
14 based upon observed utilization patterns and recommendations. This provides an
15 easy way to automatically improve allocation of cluster resources by increasing
16 efficiency. This policy will annotate all Deployments which have the label
17 `env=test` with `request.autoscaling.kubecost.com/enabled="true"` if the annotation
18 is not already present. Other annotations may be added according to need and users
19 should see the documentation for a complete list.
20spec:
21 rules:
22 - name: enable-kubecost-autoscaling
23 match:
24 any:
25 - resources:
26 kinds:
27 - Deployment
28 selector:
29 matchLabels:
30 env: test
31 mutate:
32 patchStrategicMerge:
33 metadata:
34 annotations:
35 +(request.autoscaling.kubecost.com/enabled): "true"