Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cmd/milo/controller-manager/controllermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@ func NewOptions() (*Options, error) {
KubeControllerManagerOptions: baseOpts,
InfraCluster: &infracluster.Options{
KubeconfigFile: baseOpts.Generic.ClientConnection.Kubeconfig,
LeaderElection: &infracluster.LeaderElectionConfig{
CandidateNamespace: "datum-system",
},
},
ControlPlane: &controlplane.Options{},
}
Expand Down Expand Up @@ -677,7 +680,7 @@ func Run(ctx context.Context, c *config.CompletedConfig, opts *Options) error {
// Start lease candidate controller for coordinated leader election
leaseCandidate, waitForSync, err := leaderelection.NewCandidate(
c.Client,
"datum-system",
opts.InfraCluster.LeaderElection.CandidateNamespace,
id,
"datum-controller-manager",
binaryVersion.FinalizeVersion(),
Expand Down
3 changes: 3 additions & 0 deletions config/controller-manager/base/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ spec:
- --leader-elect-renew-deadline=10s
- --leader-elect-retry-period=2s
- --leader-elect-resource-namespace=$(LEADER_ELECT_RESOURCE_NAMESPACE)
- --leader-election-candidate-namespace=$(LEADER_ELECTION_CANDIDATE_NAMESPACE)
- --authentication-skip-lookup
- --client-ca-file=$(CLIENT_CA_FILE)
- --secure-port=6443
Expand All @@ -45,6 +46,8 @@ spec:
env:
- name: LEADER_ELECT_RESOURCE_NAMESPACE
value: milo-system
- name: LEADER_ELECTION_CANDIDATE_NAMESPACE
value: datum-system
# Default to INFO level logging
- name: LOG_LEVEL
value: "4"
Expand Down
7 changes: 7 additions & 0 deletions internal/infra-cluster/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,21 @@ import (
"k8s.io/client-go/tools/clientcmd"
)

type LeaderElectionConfig struct {
CandidateNamespace string
}

// Options defines the configuration options available for modifying the
// behavior of the infrastructure cluster client.
type Options struct {
KubeconfigFile string
LeaderElection *LeaderElectionConfig
}

func (o *Options) AddFlags(fs *pflag.FlagSet) {
fs.StringVar(&o.KubeconfigFile, "infra-cluster-kubeconfig", "-", "The path to the kubeconfig file for the infrastructure cluster. Use '-' to use the in-cluster config.")
fs.StringVar(&o.LeaderElection.CandidateNamespace, "leader-election-candidate-namespace", o.LeaderElection.CandidateNamespace, "The candidate namespace in which the leader election will be created.")

}

func (o *Options) GetClient() (*rest.Config, error) {
Expand Down