-
Notifications
You must be signed in to change notification settings - Fork 385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add kubernetes election module #3721
base: master
Are you sure you want to change the base?
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
922ebcf
to
68897bf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR. Are you happy to be an owner of the new k8s election code module? The core team doesn't have the time or expertise to take on ownership of this. On the whole this role is largely being responsible for reviewing code changes from other users and any dependency updates that require code changes.
I've left some comments on the old code that was refactored to make space for this but I haven't reviewed the new code yet. I'm at a summit this week but this is on my radar for when I have time.
cmd/trillian_log_signer/main.go
Outdated
@@ -76,6 +74,7 @@ var ( | |||
|
|||
storageSystem = flag.String("storage_system", provider.DefaultStorageSystem, fmt.Sprintf("Storage system to use. One of: %v", storage.Providers())) | |||
|
|||
electionSystem = flag.String("election_system", "etcd", fmt.Sprintf("Election systen ti use. One of: %v", election2.Providers())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
electionSystem = flag.String("election_system", "etcd", fmt.Sprintf("Election systen ti use. One of: %v", election2.Providers())) | |
electionSystem = flag.String("election_system", "etcd", fmt.Sprintf("Election system to use. One of: %v", election2.Providers())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
util/election2/etcd/provider.go
Outdated
"time" | ||
) | ||
|
||
// ElectionName identifies the kubernetes election implementation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// ElectionName identifies the kubernetes election implementation. | |
// ElectionName identifies the etcd election implementation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
util/election2/etcd/provider.go
Outdated
) | ||
|
||
func init() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: there are a few places in this PR where you have a blank line after opening braces. Can you remove them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
hostname, _ := os.Hostname() | ||
instanceID := fmt.Sprintf("%s.%d", hostname, os.Getpid()) | ||
|
||
servers := flag.Lookup("etcd_servers").Value.String() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flag.Lookup
is a bit gnarly but I see that there aren't many other options without rearchitecting a lot of stuff.
util/election2/etcd/provider.go
Outdated
// NewFactory builds an election factory that uses the given parameters. The | ||
// passed in etcd client should remain valid for the lifetime of the object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is a bit stale.
util/election2/provider.go
Outdated
@@ -0,0 +1,71 @@ | |||
// Copyright 2017 Google LLC. All Rights Reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: The year is out of date in a number of new files.
Introduce a new election module using the Kubernetes Lease API. Modify the existing mechanism to allow selection of election mechanisms by introducing the `--election_system` parameter, following the same pattern used for storage and quota system selection.
Yes, I can take ownership |
This PR adds a new leader election implementation using the Kubernetes Lease API.
By leveraging Kubernetes Lease resources, this implementation provides an alternative backend for leader election. It simplifies deployments on Kubernetes by removing the need for a secondary etcd cluster when running Kubernetes workloads.
Fixes #3431
Checklist