summaryrefslogtreecommitdiff
path: root/libpod/kube.go
diff options
context:
space:
mode:
authorAndy Librian <andylibrian@gmail.com>2020-10-04 21:11:45 +0700
committerAndy Librian <andylibrian@gmail.com>2020-10-04 21:17:00 +0700
commitd6258eb6c234d60db068742308a8a3f9b002ea7d (patch)
treea6f97dccc74aedf5b5eb99f14338ba4d6a85f1c3 /libpod/kube.go
parent5954d370718f67ebb220f3dbed24a63adf5c3dae (diff)
downloadpodman-d6258eb6c234d60db068742308a8a3f9b002ea7d.tar.gz
podman-d6258eb6c234d60db068742308a8a3f9b002ea7d.tar.bz2
podman-d6258eb6c234d60db068742308a8a3f9b002ea7d.zip
Add support for resource memory limit to generate kube
addresses #7855 Signed-off-by: Andy Librian <andylibrian@gmail.com>
Diffstat (limited to 'libpod/kube.go')
-rw-r--r--libpod/kube.go15
1 files changed, 13 insertions, 2 deletions
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
}