exceptionfactory opened a new pull request, #6779: URL: https://github.com/apache/nifi/pull/6779
# Summary [NIFI-10975](https://issues.apache.org/jira/browse/NIFI-10975) Adds an initial implementation of Kubernetes cluster leader election and state management, supporting deployments without the need for ZooKeeper. ## State Management Implementation The state management implementation uses Kubernetes [ConfigMaps](https://kubernetes.io/docs/concepts/configuration/configmap/) to persist cluster information for stateful components. The `KubernetesConfigMapStateProvider` uses the standard `data` property, but encodes property names using Base64 URL encoding without padding to meet [ConfigMap object](https://kubernetes.io/docs/concepts/configuration/configmap/) property naming requirements. The new State Provider can be configured in `state-management.xml` using the following element definition, which is included in a commented section of the configuration: ``` <cluster-provider> <id>kubernetes-provider</id> <class>org.apache.nifi.kubernetes.state.provider.KubernetesConfigMapStateProvider</class> </cluster-provider> ``` ## Leader Election Implementation The leader election implementation uses Kubernetes [Leases](https://kubernetes.io/docs/concepts/architecture/leases/) for distributed tracking of the current cluster leader. Kubernetes Lease names must adhere to [RFC 1123 subdomain naming requirements](https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-subdomain-names), requiring a mapping from NiFi application names to Lease names. The new Leader Election implementation can be configured using a new property in `nifi.properties` as follows: ``` nifi.cluster.leader.election.implementation=KubernetesLeaderElectionManager ``` ## Framework Changes The leader election implementation required promoting the `LeaderElectionManager` interface to `nifi-framework-api` to support NAR bundle extension loading. The `LeaderElectionManager` had two methods without runtime references, which were removed. Refactoring also involved creating a new `nifi-framework-leader-election-shared` module for abstracting tracking operations. The `nifi.properties` configuration includes a new property with a default value of `CuratorLeaderElectionManager`, which provides current cluster coordination using ZooKeeper. ## Kubernetes Client The implementation includes a new `nifi-kubernetes-client` library which provides utility components for Kubernetes Client access and service namespace determination. The `nifi-kubernetes-client` library depends on the [Fabric8 Kubernetes Client](https://github.com/fabric8io/kubernetes-client) which supports current versions of Kubernetes and provides separation of API and implementation classes. Both the State Provider and Leader Election Manager implementations attempt to resolve the Kubernetes namespace based on the standard [Service Account](https://kubernetes.io/docs/reference/access-authn-authz/service-accounts-admin/) namespace secret. In absence of a readable namespace secret, the provider returns `default` as the namespace for storing Leases and ConfigMaps. ## Additional Changes Additional changes include removing several integration test classes specific to ZooKeeper. These integration tests are less useful with current system integration tests run on a scheduled basis. # Tracking Please complete the following tracking steps prior to pull request creation. ### Issue Tracking - [X] [Apache NiFi Jira](https://issues.apache.org/jira/browse/NIFI) issue created ### Pull Request Tracking - [X] Pull Request title starts with Apache NiFi Jira issue number, such as `NIFI-00000` - [X] Pull Request commit message starts with Apache NiFi Jira issue number, as such `NIFI-00000` ### Pull Request Formatting - [X] Pull Request based on current revision of the `main` branch - [X] Pull Request refers to a feature branch with one commit containing changes # Verification Please indicate the verification steps performed prior to pull request creation. ### Build - [X] Build completed using `mvn clean install -P contrib-check` - [X] JDK 8 - [X] JDK 11 - [X] JDK 17 ### Licensing - [ ] New dependencies are compatible with the [Apache License 2.0](https://apache.org/licenses/LICENSE-2.0) according to the [License Policy](https://www.apache.org/legal/resolved.html) - [ ] New dependencies are documented in applicable `LICENSE` and `NOTICE` files ### Documentation - [ ] Documentation formatting appears as expected in rendered files -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
