Skip to content

Commit 248afaa

Browse files
committed
Add leader election namespace flag, and missing kustomization file.
1 parent b5b39eb commit 248afaa

2 files changed

Lines changed: 35 additions & 6 deletions

File tree

cmd/main.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func init() {
3939
func main() {
4040
var metricsAddr string
4141
var enableLeaderElection bool
42+
var leaderElectionNamespace string
4243
var probeAddr string
4344
var secureMetrics bool
4445
var enableHTTP2 bool
@@ -49,6 +50,7 @@ func main() {
4950
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
5051
"Enable leader election for controller manager. "+
5152
"Enabling this will ensure there is only one active controller manager.")
53+
flag.StringVar(&leaderElectionNamespace, "leader-elect-namespace", "", "The namespace to use for leader election.")
5254
flag.BoolVar(&secureMetrics, "metrics-secure", true,
5355
"If set, the metrics endpoint is served securely via HTTPS. Use --metrics-secure=false to use HTTP instead.")
5456
flag.BoolVar(&enableHTTP2, "enable-http2", false,
@@ -103,12 +105,13 @@ func main() {
103105
}
104106

105107
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
106-
Scheme: scheme,
107-
Metrics: metricsServerOptions,
108-
WebhookServer: webhookServer,
109-
HealthProbeBindAddress: probeAddr,
110-
LeaderElection: enableLeaderElection,
111-
LeaderElectionID: "6a7d51cc.datumapis.com",
108+
Scheme: scheme,
109+
Metrics: metricsServerOptions,
110+
WebhookServer: webhookServer,
111+
HealthProbeBindAddress: probeAddr,
112+
LeaderElection: enableLeaderElection,
113+
LeaderElectionID: "6a7d51cc.datumapis.com",
114+
LeaderElectionNamespace: leaderElectionNamespace,
112115
// LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily
113116
// when the Manager ends. This requires the binary to immediately end when the
114117
// Manager is stopped, otherwise, this setting is unsafe. Setting this significantly

config/crd/kustomization.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# This kustomization.yaml is not intended to be run by itself,
2+
# since it depends on service name and namespace that are out of this kustomize package.
3+
# It should be run by config/default
4+
resources:
5+
- bases/networking.datumapis.com_networks.yaml
6+
- bases/networking.datumapis.com_networkbindings.yaml
7+
- bases/networking.datumapis.com_networkcontexts.yaml
8+
- bases/networking.datumapis.com_networkpolicies.yaml
9+
- bases/networking.datumapis.com_subnets.yaml
10+
- bases/networking.datumapis.com_subnetclaims.yaml
11+
- bases/networking.datumapis.com_locations.yaml
12+
# +kubebuilder:scaffold:crdkustomizeresource
13+
14+
patches:
15+
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
16+
# patches here are for enabling the conversion webhook for each CRD
17+
# +kubebuilder:scaffold:crdkustomizewebhookpatch
18+
19+
# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
20+
# patches here are for enabling the CA injection for each CRD
21+
# +kubebuilder:scaffold:crdkustomizecainjectionpatch
22+
23+
# [WEBHOOK] To enable webhook, uncomment the following section
24+
# the following config is for teaching kustomize how to do kustomization for CRDs.
25+
#configurations:
26+
#- kustomizeconfig.yaml

0 commit comments

Comments
 (0)