Skip to content

Commit

Permalink
Merge pull request #189 from hhyasdf/bugfix/add-leader-election-for-m…
Browse files Browse the repository at this point in the history
…anager

bugfix: add leader election for manager
  • Loading branch information
mars1024 authored Mar 5, 2022
2 parents e9bdb94 + 9be0c4b commit da88868
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
9 changes: 6 additions & 3 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,12 @@ func main() {
signalContext := ctrl.SetupSignalHandler()

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
Logger: ctrl.Log.WithName("manager"),
MetricsBindAddress: fmt.Sprintf(":%d", metricsPort),
Scheme: scheme,
Logger: ctrl.Log.WithName("manager"),
MetricsBindAddress: fmt.Sprintf(":%d", metricsPort),
LeaderElection: true,
LeaderElectionID: "hybridnet-manager-election",
LeaderElectionNamespace: os.Getenv("NAMESPACE"),
})
if err != nil {
entryLog.Error(err, "unable to start manager")
Expand Down
4 changes: 4 additions & 0 deletions yamls/hybridnet-components.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ spec:
env:
- name: DEFAULT_NETWORK_TYPE
value: Overlay
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
nodeSelector:
node-role.kubernetes.io/master: ""

Expand Down
13 changes: 12 additions & 1 deletion yamls/hybridnet-init.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ rules:
- get
- list
- watch
- apiGroups:
- "coordination.k8s.io"
resources:
- leases
verbs:
- create
- get
- list
- update

---
apiVersion: rbac.authorization.k8s.io/v1
Expand Down Expand Up @@ -3043,7 +3052,7 @@ spec:
- jsonPath: .spec.range.gateway
name: Gateway
type: string
- jsonPath: .spec.range.networkType
- jsonPath: .spec.networkType
name: NetworkType
type: string
- jsonPath: .spec.clusterName
Expand Down Expand Up @@ -3193,8 +3202,10 @@ spec:
type: string
type: array
ip:
description: IP is the IP address of this VTEP.
type: string
mac:
description: MAC is the MAC address of this VTEP.
type: string
nodeName:
description: NodeName is the name of corresponding node in remote
Expand Down
9 changes: 9 additions & 0 deletions yamls/rbac/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ rules:
- get
- list
- watch
- apiGroups:
- "coordination.k8s.io"
resources:
- leases
verbs:
- create
- get
- list
- update

---
apiVersion: rbac.authorization.k8s.io/v1
Expand Down

0 comments on commit da88868

Please sign in to comment.