Last active
May 7, 2022 16:20
-
-
Save Becram/29f49c34de0524bd2e759e20e0b87ee1 to your computer and use it in GitHub Desktop.
webhook-medium-2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Mutate returns a new mutated pod according to lifespan tolerations rules | |
func (mpl containerResources) Mutate(pod *corev1.Pod) (*corev1.Pod, error) { | |
mpl.Logger = mpl.Logger.WithField("mutation", mpl.Name()) | |
mpod := pod.DeepCopy() | |
resources, err := parseResources() | |
if err != nil { | |
return &corev1.Pod{}, err | |
} | |
tn := corev1.ResourceRequirements{ | |
Limits: resources.Limits, | |
Requests: resources.Requests, | |
} | |
for index, n := range mpod.Spec.Containers { | |
mpl.Logger.WithField("container", n.Name). | |
Printf("applying default limits and request resource") | |
mpod.Spec.Containers[index].Resources = tn | |
} | |
return mpod, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment