diff --git a/pipeline/backend/kubernetes/service.go b/pipeline/backend/kubernetes/service.go index 2f5b073eb1..b1233f0567 100644 --- a/pipeline/backend/kubernetes/service.go +++ b/pipeline/backend/kubernetes/service.go @@ -15,6 +15,8 @@ package kubernetes import ( + "fmt" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" @@ -24,6 +26,7 @@ func Service(namespace, name string, ports []uint16) (*v1.Service, error) { var svcPorts []v1.ServicePort for _, port := range ports { svcPorts = append(svcPorts, v1.ServicePort{ + Name: fmt.Sprintf("port-%d", port), Port: int32(port), TargetPort: intstr.IntOrString{IntVal: int32(port)}, }) diff --git a/pipeline/backend/kubernetes/service_test.go b/pipeline/backend/kubernetes/service_test.go index 9604bee8d0..59a631b150 100644 --- a/pipeline/backend/kubernetes/service_test.go +++ b/pipeline/backend/kubernetes/service_test.go @@ -32,14 +32,17 @@ func TestService(t *testing.T) { "spec": { "ports": [ { + "name": "port-1", "port": 1, "targetPort": 1 }, { + "name": "port-2", "port": 2, "targetPort": 2 }, { + "name": "port-3", "port": 3, "targetPort": 3 }