From d6258eb6c234d60db068742308a8a3f9b002ea7d Mon Sep 17 00:00:00 2001 From: Andy Librian Date: Sun, 4 Oct 2020 21:11:45 +0700 Subject: Add support for resource memory limit to generate kube addresses #7855 Signed-off-by: Andy Librian --- libpod/kube.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'libpod/kube.go') diff --git a/libpod/kube.go b/libpod/kube.go index f83e99d82..b2a2673ec 100644 --- a/libpod/kube.go +++ b/libpod/kube.go @@ -303,12 +303,23 @@ func containerToV1Container(c *Container) (v1.Container, []v1.Volume, error) { // This should not be applicable //container.EnvFromSource = kubeContainer.Env = envVariables - // TODO enable resources when we can support naming conventions - //container.Resources kubeContainer.SecurityContext = kubeSec kubeContainer.StdinOnce = false kubeContainer.TTY = c.config.Spec.Process.Terminal + if c.config.Spec.Linux != nil && + c.config.Spec.Linux.Resources != nil && + c.config.Spec.Linux.Resources.Memory != nil && + c.config.Spec.Linux.Resources.Memory.Limit != nil { + if kubeContainer.Resources.Limits == nil { + kubeContainer.Resources.Limits = v1.ResourceList{} + } + + qty := kubeContainer.Resources.Limits.Memory() + qty.Set(*c.config.Spec.Linux.Resources.Memory.Limit) + kubeContainer.Resources.Limits[v1.ResourceMemory] = *qty + } + return kubeContainer, kubeVolumes, nil } -- cgit v1.2.3-54-g00ecf From 62607e7f27458a9ecacb6ffc4b4a7f777f94a0bc Mon Sep 17 00:00:00 2001 From: Andy Librian Date: Mon, 5 Oct 2020 12:50:39 +0700 Subject: Add TODO for adding CPU limit support Signed-off-by: Andy Librian --- libpod/kube.go | 1 + 1 file changed, 1 insertion(+) (limited to 'libpod/kube.go') diff --git a/libpod/kube.go b/libpod/kube.go index b2a2673ec..6df79e394 100644 --- a/libpod/kube.go +++ b/libpod/kube.go @@ -307,6 +307,7 @@ func containerToV1Container(c *Container) (v1.Container, []v1.Volume, error) { kubeContainer.StdinOnce = false kubeContainer.TTY = c.config.Spec.Process.Terminal + // TODO add CPU limit support. if c.config.Spec.Linux != nil && c.config.Spec.Linux.Resources != nil && c.config.Spec.Linux.Resources.Memory != nil && -- cgit v1.2.3-54-g00ecf