what is the command to check zookeeper health check for liveness , readiness probes and to start , stop the zookeeper

8/21/2020

i have tried the following commands to check the zookeeper health and its corresponding error i am getting 1. sh -c zookeeper-ready 2181 (error: zookeeper-ready command not found) 2. i have tried all echo commands (error: it is not a file) 3. /apache-zookeeper-3.5.5-bin/bin/zkServer.sh start (error: cannot be able to start) 4. /apache-zookeeper-3.5.5-bin/bin/zkServer.sh stop (error: zookeeper stopping ...... there is no zookeeper to stop) 5. /apache-zookeeper-3.5.5-bin/bin/zkServer.sh status (error: when i am stopping the zookeeper the probe needs to fail for this command but it is not happening. it needs to be done)

and i have used these commands in go file as

	LivenessProbe: &corev1.Probe{
		Handler: corev1.Handler{
			Exec: &corev1.ExecAction{
				Command: []string{"sh",
					"/apache-zookeeper-3.5.5-bin/bin/zkServer.sh" ,
					"status",
				},
			},
		},
		InitialDelaySeconds: 30,
		TimeoutSeconds:      5,
	},
	ReadinessProbe: &corev1.Probe{
		Handler: corev1.Handler{
			Exec: &corev1.ExecAction{
				Command: []string{
					"sh",
					"/apache-zookeeper-3.5.5-bin/bin/zkServer.sh" ,
					"status",
				},
			},
		},
		InitialDelaySeconds: 30,
		TimeoutSeconds:      5,
	},
-- mokshagna sai teja
apache-zookeeper
kubernetes
kubernetes-health-check

2 Answers

12/28/2020

To check liveness and readiness for zookeeper you can use following command

echo "ruok" | timeout 2 nc -w 2 localhost 2181 | grep imok

but make sure to set the env variable ZOO_4LW_COMMANDS_WHITELIST=rouk other wise the the check will fail.

-- amrit sandhu
Source: StackOverflow

4/5/2021

You have to configure

livenessProbe:
      exec:
        command: ['/bin/bash', '-c', 'echo "ruok" | nc -w 2 localhost 2181 | grep imok']
      initialDelaySeconds: 30
      periodSeconds: 10
      timeoutSeconds: 5
      failureThreshold: 6
      successThreshold: 1
    readinessProbe:
      exec:
        command: ['/bin/bash', '-c', 'echo "ruok" | nc -w 2 localhost 2181 | grep imok']
      initialDelaySeconds: 5
      periodSeconds: 10
      timeoutSeconds: 5
      failureThreshold: 6
      successThreshold: 1

For ruok,

Plain kafka

You need to set env. variable

ZOO_4LW_COMMANDS_WHITELIST=rouk

Confluent kafka

KAFKA_OPTS=-Dzookeeper.4lw.commands.whitelist=ruok

Also, You have to change the podManagementPolicy=parallel to start parallel

-- NIrav Modi
Source: StackOverflow