Skip to content

add resources to sidecar container #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions cmd/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")...)
Expand Down