Skip to content

Commit

Permalink
Merge "zookeeper - use service with pod-name selector"
Browse files Browse the repository at this point in the history
  • Loading branch information
Microzuul CI authored and Gerrit Code Review committed Nov 29, 2023
2 parents e2a31f9 + 7ebb290 commit 6a8371d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
8 changes: 8 additions & 0 deletions controllers/libs/base/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 4 additions & 6 deletions controllers/zookeeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 6a8371d

Please sign in to comment.