From deeacaf4b13663ef1dd3d4ae14053dfdb39e8553 Mon Sep 17 00:00:00 2001 From: Hamid Emamian Date: Mon, 13 Nov 2023 11:52:34 +0300 Subject: [PATCH] changed node affinity approach to node selector for spots --- admissioncontroller/main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/admissioncontroller/main.py b/admissioncontroller/main.py index 39c2b616a..d59193559 100644 --- a/admissioncontroller/main.py +++ b/admissioncontroller/main.py @@ -18,7 +18,10 @@ def deployment_webhook_mutate(): return admission_response_patch(True, "Adding allow label", json_patch = jsonpatch.JsonPatch([{"op": "add", "path": "/spec/tolerations", "value": [{"effect":"NoExecute", "key":"workload-type", "operator":"Equal", "value":"large-testnet"}]}, {"op":"add", "path":"/spec/nodeSelector", "value": {"nodetype":"large-network"}}])) else: - return admission_response_patch(True, "Adding allow label", json_patch = jsonpatch.JsonPatch([{"op": "add", "path": "/spec/tolerations", "value": [{"operator":"Exists"}]}, {"op":"add", "path":"/spec/affinity", "value": {"nodeAffinity":{"preferredDuringSchedulingIgnoredDuringExecution":[{"weight":100,"preference":{"matchExpressions":[{"key":"nodetype","operator":"In","values":["xlarge-network"]}]}},{"weight":50,"preference":{"matchExpressions":[{"key":"nodetype","operator":"In","values":["large-network"]}]}}]}} }])) + return admission_response_patch(True, "Adding allow label", json_patch = jsonpatch.JsonPatch([{"op": "add", "path": "/spec/tolerations", "value": [{"effect":"NoExecute", "key":"workload-type", + "operator":"Equal", "value":"xlarge-testnet"}]}, {"op":"add", "path":"/spec/nodeSelector", "value": {"nodetype":"xlarge-network"}}])) + +# return admission_response_patch(True, "Adding allow label", json_patch = jsonpatch.JsonPatch([{"op": "add", "path": "/spec/tolerations", "value": [{"operator":"Exists"}]}, {"op":"add", "path":"/spec/affinity", "value": {"nodeAffinity":{"preferredDuringSchedulingIgnoredDuringExecution":[{"weight":100,"preference":{"matchExpressions":[{"key":"nodetype","operator":"In","values":["xlarge-network"]}]}},{"weight":50,"preference":{"matchExpressions":[{"key":"nodetype","operator":"In","values":["large-network"]}]}}]}} }])) elif namespace.startswith("zombie-") and not hasNodeSelector: return admission_response_patch(True, "Adding allow label", json_patch = jsonpatch.JsonPatch([{"op": "add", "path": "/spec/tolerations", "value": [{"effect":"NoExecute", "key":"workload-type",