Skip to content

Commit

Permalink
Migrate away from configmaps as leader-eletion mechanism (#488)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkarlsen authored Sep 20, 2022
1 parent a7f1cdf commit c7fe20d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ rules:
- secrets
verbs:
- '*'
- apiGroups:
- coordination.k8s.io
resources:
- leases
verbs:
- '*'
- apiGroups:
- garo.tietoevry.com
resources:
Expand Down
1 change: 1 addition & 0 deletions controllers/githubactionrunner_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func (r *GithubActionRunnerReconciler) IsValid(obj metav1.Object) (bool, error)
// +kubebuilder:rbac:groups="",resources=pods,verbs="*"
// +kubebuilder:rbac:groups="",resources=secrets,verbs="*"
// +kubebuilder:rbac:groups="",resources=events,verbs=create;patch
// +kubebuilder:rbac:groups=coordination.k8s.io,resources=leases,verbs="*"

// Reconcile is the main loop implementing the controller action
func (r *GithubActionRunnerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func main() {
Namespace: namespace,
LeaderElection: enableLeaderElection,
LeaderElectionID: "4ef9cd91.tietoevry.com",
LeaderElectionResourceLock: "configmaps",
LeaderElectionResourceLock: "configmapsleases",
}
if strings.Contains(namespace, ",") {
options.Namespace = ""
Expand Down

0 comments on commit c7fe20d

Please sign in to comment.