From 4527b5e5603f842c265fb4b4ce839a5c838e140a Mon Sep 17 00:00:00 2001 From: karta0807913 Date: Sat, 26 Nov 2022 14:16:35 +0800 Subject: [PATCH] set spac cgroup option Signed-off-by: karta0807913 --- pkg/specgen/generate/kube/kube.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/specgen/generate/kube/kube.go b/pkg/specgen/generate/kube/kube.go index 5186a2f722..1d30711cf5 100644 --- a/pkg/specgen/generate/kube/kube.go +++ b/pkg/specgen/generate/kube/kube.go @@ -16,6 +16,7 @@ import ( "github.com/containers/common/libimage" "github.com/containers/common/libnetwork/types" + "github.com/containers/common/pkg/config" "github.com/containers/common/pkg/parse" "github.com/containers/common/pkg/secrets" cutil "github.com/containers/common/pkg/util" @@ -145,6 +146,16 @@ type CtrSpecGenOptions struct { func ToSpecGen(ctx context.Context, opts *CtrSpecGenOptions) (*specgen.SpecGenerator, error) { s := specgen.NewSpecGenerator(opts.Container.Image, false) + rtc, err := config.Default() + if err != nil { + return nil, err + } + + if s.CgroupsMode == "" { + s.CgroupsMode = rtc.Cgroups() + } + + // pod name should be non-empty for Deployment objects to be able to create // multiple pods having containers with unique names if len(opts.PodName) < 1 {