diff --git a/k8sutils/services.go b/k8sutils/services.go index 627117277..24b7f74e6 100644 --- a/k8sutils/services.go +++ b/k8sutils/services.go @@ -55,6 +55,7 @@ func generateServiceDef(serviceMeta metav1.ObjectMeta, epp exporterPortProvider, } if headless { service.Spec.ClusterIP = "None" + service.Spec.PublishNotReadyAddresses = true } if exporterPort, ok := epp(); ok { redisExporterService := enableMetricsPort(exporterPort) diff --git a/k8sutils/services_test.go b/k8sutils/services_test.go index 5906d61db..e7503f691 100644 --- a/k8sutils/services_test.go +++ b/k8sutils/services_test.go @@ -102,9 +102,10 @@ func TestGenerateServiceDef(t *testing.T) { Protocol: corev1.ProtocolTCP, }, }, - Selector: map[string]string{"role": "sentinel"}, - ClusterIP: "None", - Type: corev1.ServiceTypeClusterIP, + Selector: map[string]string{"role": "sentinel"}, + ClusterIP: "None", + Type: corev1.ServiceTypeClusterIP, + PublishNotReadyAddresses: true, }, }, }, @@ -184,9 +185,10 @@ func TestGenerateServiceDef(t *testing.T) { Protocol: corev1.ProtocolTCP, }, }, - Selector: map[string]string{"role": "redis"}, - ClusterIP: "None", - Type: corev1.ServiceTypeClusterIP, + Selector: map[string]string{"role": "redis"}, + ClusterIP: "None", + Type: corev1.ServiceTypeClusterIP, + PublishNotReadyAddresses: true, }, }, },