Skip to content

Commit

Permalink
Merge "zookeeper - update liveness and readyness probes to only check…
Browse files Browse the repository at this point in the history
… SSL access"
  • Loading branch information
Microzuul CI authored and Gerrit Code Review committed Mar 15, 2024
2 parents b7330e6 + cb6364e commit eaaefce
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 37 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ All notable changes to this project will be documented in this file.
- "Debug" toggle for fluent bit sidecars

### Changed

- zookeeper - update liveness and readyness probes to only check SSL access and remove superfluous Service resource called
zookeeper-headless.

### Deprecated
### Removed
### Fixed
Expand Down
5 changes: 5 additions & 0 deletions controllers/softwarefactory_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ func (r *SFController) cleanup() {
Name: r.cr.Spec.FQDN + "-zuul-red",
},
})
// Remove unneeded extra Service resource for Zookeeper
currentZKHeadlessSVC := corev1.Service{}
if r.GetM("zookeeper-headless", &currentZKHeadlessSVC) {
r.DeleteR(&currentZKHeadlessSVC)
}
}

func (r *SFController) validate() error {
Expand Down
6 changes: 0 additions & 6 deletions controllers/static/zookeeper/ok.sh

This file was deleted.

4 changes: 4 additions & 0 deletions controllers/static/zookeeper/probe.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

echo "ruok" | openssl s_client -CAfile /tls/client/ca.crt -cert /tls/client/tls.crt -key /tls/client/tls.key \
-connect 127.0.0.1:2281 -quiet 2>/dev/null | grep "imok"
6 changes: 0 additions & 6 deletions controllers/static/zookeeper/ready.sh

This file was deleted.

31 changes: 6 additions & 25 deletions controllers/zookeeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@ import (
apiv1 "k8s.io/api/core/v1"
)

//go:embed static/zookeeper/ok.sh
var zookeeperOk string

//go:embed static/zookeeper/ready.sh
var zookeeperReady string
//go:embed static/zookeeper/probe.sh
var zookeeperProbe string

//go:embed static/zookeeper/run.sh
var zookeeperRun string
Expand All @@ -32,18 +29,9 @@ var zkFluentBitForwarderConfig string
//go:embed static/zookeeper/logback.xml
var zkLogbackConfig string

const zkPortName = "zk"
const zkPort = 2181

const zkSSLPortName = "zkssl"
const zkSSLPort = 2281

const zkElectionPortName = "zkelection"
const zkElectionPort = 3888

const zkServerPortName = "zkserver"
const zkServerPort = 2888

const ZookeeperIdent = "zookeeper"
const zkPIMountPath = "/config-scripts"

Expand Down Expand Up @@ -103,13 +91,12 @@ func (r *SFController) DeployZookeeper() bool {
}

cmData := make(map[string]string)
cmData["ok.sh"] = zookeeperOk
cmData["ready.sh"] = zookeeperReady
cmData["probe.sh"] = zookeeperProbe
cmData["run.sh"] = zookeeperRun
cmData["logback.xml"] = zkLogbackConfig
r.EnsureConfigMap(ZookeeperIdent+"-pi", cmData)

configChecksumable := zookeeperOk + "\n" + zookeeperReady + "\n" + zookeeperRun + "\n" + zkLogbackConfig
configChecksumable := zookeeperProbe + "\n" + zookeeperRun + "\n" + zkLogbackConfig

annotations := map[string]string{
"configuration": utils.Checksum([]byte(configChecksumable)),
Expand Down Expand Up @@ -153,9 +140,6 @@ func (r *SFController) DeployZookeeper() bool {
srv := base.MkServicePod(ZookeeperIdent, r.ns, ZookeeperIdent+"-0", []int32{zkSSLPort}, ZookeeperIdent)
r.EnsureService(&srv)

srvZK := base.MkHeadlessServicePod(ZookeeperIdent, r.ns, ZookeeperIdent+"-0", []int32{zkSSLPort, zkElectionPort, zkServerPort}, ZookeeperIdent)
r.EnsureService(&srvZK)

storageConfig := r.getStorageConfOrDefault(r.cr.Spec.Zookeeper.Storage)
logStorageConfig := base.StorageConfig{
Size: utils.Qty1Gi(),
Expand All @@ -179,13 +163,10 @@ func (r *SFController) DeployZookeeper() bool {
base.MkVolumeSecret("zookeeper-server-tls"),
base.MkEmptyDirVolume(ZookeeperIdent + "-conf"),
}
zk.Spec.Template.Spec.Containers[0].ReadinessProbe = base.MkReadinessCMDProbe([]string{"/bin/bash", "/config-scripts/ready.sh"})
zk.Spec.Template.Spec.Containers[0].LivenessProbe = base.MkReadinessCMDProbe([]string{"/bin/bash", "/config-scripts/ok.sh"})
zk.Spec.Template.Spec.Containers[0].ReadinessProbe = base.MkReadinessCMDProbe([]string{"/bin/bash", "/config-scripts/probe.sh"})
zk.Spec.Template.Spec.Containers[0].LivenessProbe = base.MkLivenessCMDProbe([]string{"/bin/bash", "/config-scripts/probe.sh"})
zk.Spec.Template.Spec.Containers[0].Ports = []apiv1.ContainerPort{
base.MkContainerPort(zkPort, zkPortName),
base.MkContainerPort(zkSSLPort, zkSSLPortName),
base.MkContainerPort(zkElectionPort, zkElectionPortName),
base.MkContainerPort(zkServerPort, zkServerPortName),
}

if r.cr.Spec.FluentBitLogForwarding != nil {
Expand Down

0 comments on commit eaaefce

Please sign in to comment.