diff --git a/controllers/libs/base/base.go b/controllers/libs/base/base.go index b81e23de..d6ddcf16 100644 --- a/controllers/libs/base/base.go +++ b/controllers/libs/base/base.go @@ -262,6 +262,14 @@ func MkHeadlessService(name string, ns string, selector string, ports []int32, p return service } +// MkHeadlessServicePod produces a headless service. +func MkHeadlessServicePod(name string, ns string, podName string, ports []int32, portName string) apiv1.Service { + service := MkServicePod(name, ns, podName, ports, portName) + service.ObjectMeta.Name = name + "-headless" + service.Spec.ClusterIP = "None" + return service +} + // MkHTTPSRoute produces a Route on top of a Service func MkHTTPSRoute( name string, ns string, host string, serviceName string, path string, diff --git a/controllers/zookeeper.go b/controllers/zookeeper.go index 3506ef18..bf0252a6 100644 --- a/controllers/zookeeper.go +++ b/controllers/zookeeper.go @@ -94,13 +94,11 @@ func (r *SFController) DeployZookeeper() bool { }, } - servicePorts := []int32{zkSSLPort} - srv := base.MkService(zkIdent, r.ns, zkIdent, servicePorts, zkIdent) - r.GetOrCreate(&srv) + srv := base.MkServicePod(zkIdent, r.ns, zkIdent+"-0", []int32{zkSSLPort}, zkIdent) + r.EnsureService(&srv) - headlessPorts := []int32{zkSSLPort, zkElectionPort, zkServerPort} - srvZK := base.MkHeadlessService(zkIdent, r.ns, zkIdent, headlessPorts, zkIdent) - r.GetOrCreate(&srvZK) + srvZK := base.MkHeadlessServicePod(zkIdent, r.ns, zkIdent+"-0", []int32{zkSSLPort, zkElectionPort, zkServerPort}, zkIdent) + r.EnsureService(&srvZK) storageConfig := r.getStorageConfOrDefault(r.cr.Spec.Zookeeper.Storage) zk := r.mkHeadlessSatefulSet(