File tree Expand file tree Collapse file tree 3 files changed +25
-2
lines changed
Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,20 @@ helm install krr-enforcer robusta/krr-enforcer -f enforcer-values.yaml
9797| `resources.requests.cpu` | CPU request for the enforcer pod | `100m` |
9898| `resources.requests.memory` | Memory request for the enforcer pod | `256Mi` |
9999
100+ # ## Additional settings
101+
102+ On some scenarios, you might want to exclude a specific container from `enforcement`, across all Deployments/Pods.
103+ For example, if you have some init container, that you'd like to be excluded.
104+
105+ You can do that by adding an environment variable named `EXCLUDED_CONTAINERS`, with a list of comma separated container names that should be excluded.
106+ For example :
107+
108+ ` ` ` yaml
109+ additionalEnvVars:
110+ ...
111+ - name: EXCLUDED_CONTAINERS
112+ value: my-spiky-container, java-init-container
113+ ` ` `
100114
101115# # Running Locally
102116
Original file line number Diff line number Diff line change 2121SCAN_AGE_HOURS_THRESHOLD = int (os .environ .get ("SCAN_AGE_HOURS_THRESHOLD" , 360 )) # 15 days
2222
2323ENFORCER_SSL_KEY_FILE = os .environ .get ("ENFORCER_SSL_KEY_FILE" , "" )
24- ENFORCER_SSL_CERT_FILE = os .environ .get ("ENFORCER_SSL_CERT_FILE" , "" )
24+ ENFORCER_SSL_CERT_FILE = os .environ .get ("ENFORCER_SSL_CERT_FILE" , "" )
25+
26+ EXCLUDED_CONTAINERS = [container_name .strip () for container_name
27+ in os .environ .get ("EXCLUDED_CONTAINERS" , "" ).split ("," ) if container_name .strip ()]
Original file line number Diff line number Diff line change 22import logging
33from typing import Dict , Any , List , Optional
44from enforcer .model import ContainerRecommendation
5- from enforcer .env_vars import UPDATE_THRESHOLD
5+ from enforcer .env_vars import UPDATE_THRESHOLD , EXCLUDED_CONTAINERS
6+
67logger = logging .getLogger ()
78
89REQ = "requests"
@@ -241,6 +242,11 @@ def patch_container_resources(
241242 if not recommendation :
242243 return patches
243244
245+ container_name = container .get ("name" )
246+ if container_name and container_name in EXCLUDED_CONTAINERS :
247+ logging .info (f"Skipping excluded container { container_name } " )
248+ return patches
249+
244250 had_resources = "resources" in container
245251 resources = copy .deepcopy (container .get ('resources' , {}))
246252 updated_resources = get_updated_resources (container .get ('resources' , {}), recommendation )
You can’t perform that action at this time.
0 commit comments