Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

Support leader election for Connect-Inject controller #903

Merged
merged 2 commits into from
Apr 13, 2021

Conversation

thisisnotashwin
Copy link

Changes proposed in this PR:

  • Support leader election for the connect-inject controller.

@@ -19,7 +19,7 @@ metadata:
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
spec:
replicas: 1
replicas: 3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious what our thoughts are on this? will 2 cause election issues?
wondering if we bound it to # of server replicas or something, in case this is a demo environment?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 should also be fine. I put up 3 as a shot in the dark. the number of instances here are irrelevant. If you have a single instance running, it will assume it is the leader as it does not use a "consensus" protocol to establish leadership.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, interesting!
Okay thanks for the clarification. I'm just trying to think of how this might look if we have a demo environment where we've got a single kind node or something and then three of these try to spin up? 2 even seems too high in that case, but would be ideal in any other case. thoughts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think 2 makes more sense to me. Demo env is tough, it definitely doesn't need 2 but folks won't change this for prod either and we default to 3 servers for the same reason. We could handle demo env another way maybe via profiles.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we're definitely pretty inconsistent. Although, if I were to guess it seems that we're leaning towards making it prod-ready by default rather than demo by default because servers and all gateways start with multiple instances. The only components that don't are sync-catalog, connect-injector, and controller. Sync catalog and injector could not run more than one instance, and for the controller we could probably switch too especially if we're thinking to combine it with the endpoints controller.

I think it'd make sense to default to a more HA setting (with 2 instances).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree! 2 sounds good then!

@kschoche kschoche force-pushed the tproxy-remove-cleanup-hc-controller-flags branch from 0f42db9 to ea056a4 Compare April 12, 2021 14:29
Base automatically changed from tproxy-remove-cleanup-hc-controller-flags to feature-tproxy April 13, 2021 13:54
@thisisnotashwin thisisnotashwin marked this pull request as ready for review April 13, 2021 13:58
- Leader election required creating a configmap that is owned by the
  instance of the controller that is the leader. This required RBAC to
perform CRUD operations on configmaps to the controller.
- Additionally the latest version of the controller runtime requires the
  controller to read "leases" from kubernetes and we now have to support
that for the connect-inject controller.
- Increase the number of replicas of the connect inject deployment to 3
  as we can now be HA.
Copy link
Contributor

@kschoche kschoche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work!

Copy link
Contributor

@ndhanushkodi ndhanushkodi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 Looks great! Nice work Ashwin!!

@thisisnotashwin thisisnotashwin merged commit 9a80268 into feature-tproxy Apr 13, 2021
@thisisnotashwin thisisnotashwin deleted the add-leader-election branch April 13, 2021 17:59
thisisnotashwin pushed a commit that referenced this pull request Apr 15, 2021
* Support leader election for Connect-Inject controller

- Leader election required creating a configmap that is owned by the
  instance of the controller that is the leader. This required RBAC to
perform CRUD operations on configmaps to the controller.
- Additionally the latest version of the controller runtime requires the
  controller to read "leases" from kubernetes and we now have to support
that for the connect-inject controller.
- Increase the number of replicas of the connect inject deployment to 2
  as we can now be HA.
ishustava pushed a commit that referenced this pull request Apr 16, 2021
* Support leader election for Connect-Inject controller

- Leader election required creating a configmap that is owned by the
  instance of the controller that is the leader. This required RBAC to
perform CRUD operations on configmaps to the controller.
- Additionally the latest version of the controller runtime requires the
  controller to read "leases" from kubernetes and we now have to support
that for the connect-inject controller.
- Increase the number of replicas of the connect inject deployment to 2
  as we can now be HA.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants