From 628f2982daf036a97ca759efd2a633bd287298ff Mon Sep 17 00:00:00 2001 From: Zenghui Shi Date: Mon, 4 Jan 2021 11:21:28 +0800 Subject: [PATCH] Allow disabling resource injection with specific pod label Fixes #56 Signed-off-by: Zenghui Shi --- pkg/webhook/webhook.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/webhook/webhook.go b/pkg/webhook/webhook.go index 560b144b..30053905 100644 --- a/pkg/webhook/webhook.go +++ b/pkg/webhook/webhook.go @@ -574,6 +574,17 @@ func createResourcePatch(patch []jsonPatchOperation, Containers []corev1.Contain patch = patchEmptyResources(patch, 0, "limits") } + for resourceName := range resourceRequests { + for _, container := range Containers { + if _, exists := container.Resources.Limits[corev1.ResourceName(resourceName)]; exists { + delete(resourceRequests, resourceName) + } + if _, exists := container.Resources.Requests[corev1.ResourceName(resourceName)]; exists { + delete(resourceRequests, resourceName) + } + } + } + resourceList := *getResourceList(resourceRequests) for resource, quantity := range resourceList {