mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
GT-474 Switch to Lease API
This commit is contained in:
parent
344924bfc6
commit
2e2333b412
3 changed files with 14 additions and 10 deletions
|
@ -6,6 +6,7 @@
|
|||
- (Feature) Optional Assertions
|
||||
- (Feature) Deprecate Actions
|
||||
- (Bugfix) Debug mode
|
||||
- (Improvement) Switch to Lease API
|
||||
|
||||
## [1.2.32](https://github.com/arangodb/kube-arangodb/tree/1.2.32) (2023-08-07)
|
||||
- (Feature) Backup lifetime - remove Backup once its lifetime has been reached
|
||||
|
|
|
@ -35,6 +35,9 @@ rules:
|
|||
- apiGroups: ["policy"]
|
||||
resources: ["poddisruptionbudgets"]
|
||||
verbs: ["*"]
|
||||
- apiGroups: ["coordination.k8s.io"]
|
||||
resources: ["leases"]
|
||||
verbs: ["*"]
|
||||
- apiGroups: ["backup.arangodb.com"]
|
||||
resources: ["arangobackuppolicies", "arangobackups"]
|
||||
verbs: ["get", "list", "watch"]
|
||||
|
|
|
@ -57,22 +57,22 @@ func (o *Operator) runLeaderElection(lockName, label string, onStart func(stop <
|
|||
o.Dependencies.EventRecorder.Event(eventTarget, core.EventTypeNormal, reason, message)
|
||||
}
|
||||
}
|
||||
rl, err := resourcelock.New("endpoints",
|
||||
namespace,
|
||||
lockName,
|
||||
kubecli.CoreV1(),
|
||||
kubecli.CoordinationV1(),
|
||||
resourcelock.ResourceLockConfig{
|
||||
|
||||
lock := &resourcelock.LeaseLock{
|
||||
LeaseMeta: meta.ObjectMeta{
|
||||
Name: lockName,
|
||||
Namespace: namespace,
|
||||
},
|
||||
Client: kubecli.CoordinationV1(),
|
||||
LockConfig: resourcelock.ResourceLockConfig{
|
||||
Identity: o.Config.ID,
|
||||
EventRecorder: o.Dependencies.EventRecorder,
|
||||
})
|
||||
if err != nil {
|
||||
log.Err(err).Fatal("Failed to create resource lock")
|
||||
},
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
leaderelection.RunOrDie(ctx, leaderelection.LeaderElectionConfig{
|
||||
Lock: rl,
|
||||
Lock: lock,
|
||||
LeaseDuration: 15 * time.Second,
|
||||
RenewDeadline: 10 * time.Second,
|
||||
RetryPeriod: 2 * time.Second,
|
||||
|
|
Loading…
Reference in a new issue