diff --git a/controllers/etcdcluster_controller.go b/controllers/etcdcluster_controller.go index a0cd4812..8d8a46ef 100644 --- a/controllers/etcdcluster_controller.go +++ b/controllers/etcdcluster_controller.go @@ -42,6 +42,7 @@ import ( const ( clusterNameSpecField = "spec.clusterName" etcdClientPortName = "etcd-client" + etcdMetricsPortName = "etcd-metrics" ) const ( @@ -377,6 +378,11 @@ func headlessServiceForCluster(cluster *etcdv1alpha1.EtcdCluster) *v1.Service { Protocol: "TCP", Port: etcdPeerPort, }, + { + Name: "etcd-metrics", + Protocol: "TCP", + Port: etcdMetricsPort, + }, }, }, } @@ -596,7 +602,7 @@ func serviceMonitorForCluster(cluster *etcdv1alpha1.EtcdCluster) *monitorv1.Serv Spec: monitorv1.ServiceMonitorSpec{ Endpoints: []monitorv1.Endpoint{ { - Port: etcdClientPortName, + Port: etcdMetricsPortName, Interval: "10s", }}, NamespaceSelector: monitorv1.NamespaceSelector{ diff --git a/controllers/etcdcluster_controller_test.go b/controllers/etcdcluster_controller_test.go index da374996..39bbca8a 100644 --- a/controllers/etcdcluster_controller_test.go +++ b/controllers/etcdcluster_controller_test.go @@ -383,6 +383,12 @@ func (s *controllerSuite) testClusterController(t *testing.T) { Port: 2380, TargetPort: intstr.FromInt(2380), }, "Service did not declare peer port") + require.Contains(t, ports, v1.ServicePort{ + Name: "etcd-metrics", + Protocol: "TCP", + Port: 2381, + TargetPort: intstr.FromInt(2381), + }, "Service did not declare metrics port") }) t.Run("CreatePodDisruptionBudget", func(t *testing.T) {