feat: add etcd-based leader election to reduce kubeapi coupling#7810
Open
eveningcafe wants to merge 2 commits intoKong:mainfrom
Open
feat: add etcd-based leader election to reduce kubeapi coupling#7810eveningcafe wants to merge 2 commits intoKong:mainfrom
eveningcafe wants to merge 2 commits intoKong:mainfrom
Conversation
This adds etcd-based leader election as an alternative backend for environments where Kubernetes API server stability is a concern (e.g., managed Kubernetes services). Motivation: - Reduce coupling with Kubernetes API for leader election - Leader election continues working even when kubeapi is unstable - Faster election/re-election by bypassing K8s API server overhead Changes: - New package `internal/leaderelection/etcd/` implementing resourcelock.Interface - New CLI flag: `--leader-election-backend` (options: `lease`, `etcd`) - Environment variables for etcd configuration: - ETCD_ENDPOINTS (required): comma-separated list of etcd endpoints - ETCD_CERT_FILE, ETCD_KEY_FILE: TLS client certificate - ETCD_CA_FILE: CA certificate for TLS verification - ETCD_USERNAME, ETCD_PASSWORD: authentication credentials Usage: export ETCD_ENDPOINTS="http://etcd-0:2379,http://etcd-1:2379" ./kong-ingress-controller --leader-election-backend=etcd
|
Ngô Quang Hòa seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds etcd-based leader election as an alternative backend for environments where Kubernetes API server stability is a concern (e.g., managed Kubernetes services).
Motivation
In managed Kubernetes environments, the kubeapi server can become unstable or slow under load. This causes issues with the default Kubernetes Lease-based leader election:
By using etcd directly for leader election:
Changes
internal/leaderelection/etcd/implementingresourcelock.Interface--leader-election-backend(options:lease,etcd)ETCD_ENDPOINTS(required): comma-separated list of etcd endpointsETCD_CERT_FILE,ETCD_KEY_FILE: TLS client certificateETCD_CA_FILE: CA certificate for TLS verificationETCD_USERNAME,ETCD_PASSWORD: authentication credentialsUsage
Kubernetes Deployment Example
Test Plan
leasebackend continues to work unchangedChecklist
resourcelock.Interface)go vetandgofmtpass