From 84352a81c95b0a322f6b0d691fbd49d82fbc76b6 Mon Sep 17 00:00:00 2001 From: Urvashi Mohnani Date: Tue, 30 Aug 2022 10:34:13 -0400 Subject: [PATCH] Set enableServiceLinks to false in generated yaml Since podman doesn't set/use the needed service env variable, always set enableServiceLinks to false in the generated kube yaml. Signed-off-by: Urvashi Mohnani --- libpod/kube.go | 13 ++++++++----- test/e2e/generate_kube_test.go | 4 ++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/libpod/kube.go b/libpod/kube.go index a0fb529732..a70782d69f 100644 --- a/libpod/kube.go +++ b/libpod/kube.go @@ -468,12 +468,15 @@ func newPodObject(podName string, annotations map[string]string, initCtrs, conta CreationTimestamp: v12.Now(), Annotations: annotations, } + // Set enableServiceLinks to false as podman doesn't use the service port environment variables + enableServiceLinks := false ps := v1.PodSpec{ - Containers: containers, - Hostname: hostname, - HostNetwork: hostNetwork, - InitContainers: initCtrs, - Volumes: volumes, + Containers: containers, + Hostname: hostname, + HostNetwork: hostNetwork, + InitContainers: initCtrs, + Volumes: volumes, + EnableServiceLinks: &enableServiceLinks, } if dnsOptions != nil && (len(dnsOptions.Nameservers)+len(dnsOptions.Searches)+len(dnsOptions.Options) > 0) { ps.DNSConfig = dnsOptions diff --git a/test/e2e/generate_kube_test.go b/test/e2e/generate_kube_test.go index 5133059b8a..6a73d8ab69 100644 --- a/test/e2e/generate_kube_test.go +++ b/test/e2e/generate_kube_test.go @@ -71,6 +71,8 @@ var _ = Describe("Podman generate kube", func() { Expect(pod.Spec.Containers[0]).To(HaveField("WorkingDir", "")) Expect(pod.Spec.Containers[0].Env).To(BeNil()) Expect(pod).To(HaveField("Name", "top-pod")) + enableServiceLinks := false + Expect(pod.Spec).To(HaveField("EnableServiceLinks", &enableServiceLinks)) numContainers := 0 for range pod.Spec.Containers { @@ -165,6 +167,8 @@ var _ = Describe("Podman generate kube", func() { err := yaml.Unmarshal(kube.Out.Contents(), pod) Expect(err).To(BeNil()) Expect(pod.Spec).To(HaveField("HostNetwork", false)) + enableServiceLinks := false + Expect(pod.Spec).To(HaveField("EnableServiceLinks", &enableServiceLinks)) numContainers := 0 for range pod.Spec.Containers {