diff --git a/server/sandbox_run.go b/server/sandbox_run.go index d4221e95..a3f0584f 100644 --- a/server/sandbox_run.go +++ b/server/sandbox_run.go @@ -22,6 +22,14 @@ import ( pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime" ) +const ( + // PodInfraOOMAdj is the value that we set for oom score adj for + // the pod infra container. + // TODO: Remove this const once this value is provided over CRI + // See https://github.com/kubernetes/kubernetes/issues/47938 + PodInfraOOMAdj int = -998 +) + // privilegedSandbox returns true if the sandbox configuration // requires additional host privileges for the sandbox. func (s *Server) privilegedSandbox(req *pb.RunPodSandboxRequest) bool { @@ -387,6 +395,10 @@ func (s *Server) RunPodSandbox(ctx context.Context, req *pb.RunPodSandboxRequest } } + // Set OOM score adjust of the infra container to be very low + // so it doesn't get killed. + g.SetLinuxResourcesOOMScoreAdj(PodInfraOOMAdj) + hostNetwork := req.GetConfig().GetLinux().GetSecurityContext().GetNamespaceOptions().HostNetwork // set up namespaces