diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-10-15 16:56:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-15 16:56:43 +0200 |
commit | 673cc5054c3e1c31abceb02906d20d1952bbf5b1 (patch) | |
tree | 05c4e33e789beafa18db5de5c68163d46d494bbf /libpod/kube.go | |
parent | 3f6fd8a7bd4f4fc3cfbfb1329814a5db016b1a6c (diff) | |
parent | 8db62d04fd0d740a9cd04bd2f674d2533ab3bd51 (diff) | |
download | podman-673cc5054c3e1c31abceb02906d20d1952bbf5b1.tar.gz podman-673cc5054c3e1c31abceb02906d20d1952bbf5b1.tar.bz2 podman-673cc5054c3e1c31abceb02906d20d1952bbf5b1.zip |
Merge pull request #11982 from umohnani8/targetPort
Set targetPort to the port value in the kube yaml
Diffstat (limited to 'libpod/kube.go')
-rw-r--r-- | libpod/kube.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/libpod/kube.go b/libpod/kube.go index 5a33bc968..d47f47f1c 100644 --- a/libpod/kube.go +++ b/libpod/kube.go @@ -25,6 +25,7 @@ import ( v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" v12 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/intstr" ) // GenerateForKube takes a slice of libpod containers and generates @@ -196,10 +197,11 @@ func containerPortsToServicePorts(containerPorts []v1.ContainerPort) []v1.Servic for _, cp := range containerPorts { nodePort := 30000 + rand.Intn(32767-30000+1) servicePort := v1.ServicePort{ - Protocol: cp.Protocol, - Port: cp.ContainerPort, - NodePort: int32(nodePort), - Name: strconv.Itoa(int(cp.ContainerPort)), + Protocol: cp.Protocol, + Port: cp.ContainerPort, + NodePort: int32(nodePort), + Name: strconv.Itoa(int(cp.ContainerPort)), + TargetPort: intstr.Parse(strconv.Itoa(int(cp.ContainerPort))), } sps = append(sps, servicePort) } |