When NiFi runs with zookeeper (ZK) deployed in the same Kubernetes cluster, it cannot connect to ZK once all ZK pods get restarted. The root cause is NiFi uses Curator Framework with default ensembleTracker enabled so the NiFI zookeeper client resolves the ZK connection string (eg. zookeeper.test.svc.cluster.local) to IP addresses and then when all ZK pods get restarted, NiFi cannot connect to ZK cluster cause pod IP changed when it is restarted in Kubernetes.
The solution is to add a NiFi configuration option "nifi.zookeeper.client.ensembleTracker" to enable/disable NiFi zookeeper client ensembleTracker as mentioned in https://issues.apache.org/jira/browse/CURATOR-568. Default value is "true" for backward compatibility.