Skip to content

Commit

Permalink
Allow disabling resource injection with specific pod label
Browse files Browse the repository at this point in the history
Fixes #56
Signed-off-by: Zenghui Shi <[email protected]>
  • Loading branch information
zshi-redhat authored and martinkennelly committed May 5, 2021
1 parent e973dc9 commit 628f298
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 628f298

Please sign in to comment.