From 1e0384ba76994b68cb75a0967cb1e0460bc19b75 Mon Sep 17 00:00:00 2001 From: Krithika3 Date: Wed, 15 Jun 2022 14:22:12 -0700 Subject: [PATCH] Added name to service spec (#58) * Added name to service spec Signed-off-by: Krithika Vijayakumar * Added vertexHTTPSPortName Signed-off-by: Krithika Vijayakumar --- pkg/apis/numaflow/v1alpha1/const.go | 10 ++++++---- pkg/apis/numaflow/v1alpha1/vertex_type_test.go | 2 +- pkg/apis/numaflow/v1alpha1/vertex_types.go | 8 ++++---- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/pkg/apis/numaflow/v1alpha1/const.go b/pkg/apis/numaflow/v1alpha1/const.go index e69b02b5a..6ddd51344 100644 --- a/pkg/apis/numaflow/v1alpha1/const.go +++ b/pkg/apis/numaflow/v1alpha1/const.go @@ -88,10 +88,12 @@ const ( // Watermark EnvWatermarkOn = "NUMAFLOW_WATERMARK_ON" - PathVarRun = "/var/run/numaflow" - VertexMetricsPort = 2469 - VertexHTTPSPort = 8443 - DaemonServicePort = 4327 + PathVarRun = "/var/run/numaflow" + VertexMetricsPort = 2469 + VertexMetricsPortName = "metrics" + VertexHTTPSPort = 8443 + VertexHTTPSPortName = "https" + DaemonServicePort = 4327 DefaultRequeueAfter = 10 * time.Second diff --git a/pkg/apis/numaflow/v1alpha1/vertex_type_test.go b/pkg/apis/numaflow/v1alpha1/vertex_type_test.go index 34b36e03c..1678c6773 100644 --- a/pkg/apis/numaflow/v1alpha1/vertex_type_test.go +++ b/pkg/apis/numaflow/v1alpha1/vertex_type_test.go @@ -110,7 +110,7 @@ func TestGetVertexReplicas(t *testing.T) { } func TestGetHeadlessSvcSpec(t *testing.T) { - s := testVertex.getServiceObj(testVertex.GetHeadlessServiceName(), true, VertexMetricsPort) + s := testVertex.getServiceObj(testVertex.GetHeadlessServiceName(), true, VertexMetricsPort, VertexMetricsPortName) assert.Equal(t, s.Name, testVertex.GetHeadlessServiceName()) assert.Equal(t, s.Namespace, testVertex.Namespace) assert.Equal(t, 1, len(s.Spec.Ports)) diff --git a/pkg/apis/numaflow/v1alpha1/vertex_types.go b/pkg/apis/numaflow/v1alpha1/vertex_types.go index 053643d58..b08a45323 100644 --- a/pkg/apis/numaflow/v1alpha1/vertex_types.go +++ b/pkg/apis/numaflow/v1alpha1/vertex_types.go @@ -73,14 +73,14 @@ func (v Vertex) GetHeadlessServiceName() string { } func (v Vertex) GetServiceObjs() []*corev1.Service { - svcs := []*corev1.Service{v.getServiceObj(v.GetHeadlessServiceName(), true, VertexMetricsPort)} + svcs := []*corev1.Service{v.getServiceObj(v.GetHeadlessServiceName(), true, VertexMetricsPort, VertexMetricsPortName)} if x := v.Spec.Source; x != nil && x.HTTP != nil && x.HTTP.Service { - svcs = append(svcs, v.getServiceObj(v.Name, false, VertexHTTPSPort)) + svcs = append(svcs, v.getServiceObj(v.Name, false, VertexHTTPSPort, VertexHTTPSPortName)) } return svcs } -func (v Vertex) getServiceObj(name string, headless bool, port int) *corev1.Service { +func (v Vertex) getServiceObj(name string, headless bool, port int, servicePortName string) *corev1.Service { svc := &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ Namespace: v.Namespace, @@ -96,7 +96,7 @@ func (v Vertex) getServiceObj(name string, headless bool, port int) *corev1.Serv }, Spec: corev1.ServiceSpec{ Ports: []corev1.ServicePort{ - {Port: int32(port), TargetPort: intstr.FromInt(port)}, + {Port: int32(port), TargetPort: intstr.FromInt(port), Name: servicePortName}, }, Selector: map[string]string{ KeyPartOf: Project,