Open Monokaix opened 1 month ago
Glad to contribute if it's acceptable.
/assign
sidecarContainer has been a beta feature and enabled by default in k8s v1.29, we should also support it to get a more accurate resources requirement.
Can you give an example to explain the gaps we currently have? As far as I know, resource interpreters already consider sidecar containers when determining resource requirements. https://github.com/karmada-io/karmada/blob/38ee277de7aaaf4f93fec42d49bfc71cc4b0be76/pkg/util/helper/binding.go#L385-L405
sidecarContainer has been a beta feature and enabled by default in k8s v1.29, we should also support it to get a more accurate resources requirement.
Can you give an example to explain the gaps we currently have? As far as I know, resource interpreters already consider sidecar containers when determining resource requirements.
Seems the func AddPodTemplateRequest
is just copyed from old k8s version, and didn't consider the sidecarcontainers resources, sidecar container is a special init container with restartPolicy = Always
, here is the logic of k8s when compute pod resource requests https://github.com/kubernetes/kubernetes/blob/b3cf9c6e5c7f7851529e17a4ebf51c2e98392cb4/staging/src/k8s.io/component-helpers/resource/helpers.go#L104
Oh, I see. Thanks for the reminder, that makes sense to me.
PS: Link some materials about the SideCarContainer feature:
A little question need to be cleared, what if the featuregate of sidecareContaiener is enabled in karmada control plan but is disabled in member cluster or vice versa, to put it simply, the replicas calculation is not consistent between control plane and members. How does karmdada solve the problem of inconsistent featuregate switches?
What would happen if we deploy a Deployment with sidecar container to a cluster where the SidecarContainers
feature is disabled?
Sidecarcontainer is a special init container but will run last forever with main container, the pod request computation result is different with Sidecarcontainer disabled and enabled, it will affect scheduling result, if the SidecarContainers is enaled in control plane, the pod request resources computation result in control plane will be larger than in member clusters with SidecarContainers disabled, and the first level of scheduling may think the pod is not schedulable but actually it can be scheduled in member cluster. And if Sidecarcontainer is disabled in control plane while enabled in member cluster, the pod maybe schedulable but actually it cann't be schedulable in member cluster.
What would you like to be added: Add sidecarContainers support when compute
resource requirements
in resourceInterpreter. Why is this needed: sidecarContainer has been a beta feature and enabled by default in k8s v1.29, we should also support it to get a more accurate resources requirement. xrefs: https://kubernetes.io/docs/concepts/workloads/pods/sidecar-containers/