diff --git a/cmd/webhook.go b/cmd/webhook.go index dca5a79..f8f0a9d 100644 --- a/cmd/webhook.go +++ b/cmd/webhook.go @@ -14,6 +14,7 @@ import ( admissionv1 "k8s.io/api/admission/v1" corev1 "k8s.io/api/core/v1" k8serrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/serializer" @@ -225,6 +226,22 @@ func createPatch(pod *corev1.Pod, sidecarConfigTemplate *Config, annotations map tempSidecarConfig, _ := deepcopy.Anything(sidecarConfigTemplate) sidecarConfig := tempSidecarConfig.(*Config) + // Defines the resources for the kerberos sidecar container. + // Had to be defined here, the unmarshalling was not working correctly + // when it was defined in the configmap definition + sidecarResources := corev1.ResourceRequirements{ + Requests: corev1.ResourceList{ + corev1.ResourceCPU: resource.MustParse("1m"), + corev1.ResourceMemory: resource.MustParse("2.2M"), + }, + Limits: corev1.ResourceList{ + corev1.ResourceCPU: resource.MustParse("5m"), + corev1.ResourceMemory: resource.MustParse("20M"), + }, + } + + sidecarConfig.Containers[0].Resources = sidecarResources + // Add container and volume to the patch patch = append(patch, addContainer(pod.Spec.Containers, sidecarConfig.Containers, "/spec/containers")...) patch = append(patch, addVolume(pod.Spec.Volumes, sidecarConfig.Volumes, "/spec/volumes")...)