-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce new external endpoints controller #11905
Conversation
For mesh expansion, we need to register an ExternalWorkload's service membership. Service memberships describe which Service objects an ExternalWorkload is part of (i.e. which service can be used to route traffic to an external endpoint). Service membership will allow the control plane to discover configuration associated with an external endpoint when performing discovery on a service target. To build these memberships, we introduce a new controller to the destination service, responsible for watching Service and ExternalWorkload objects, and for writing out EndpointSlice objects for each Service that selects one or more external endpoints. As a first step, we add a new ExternalEndpointManager module in the destination service's package that watches services and workloads. In a follow-up change, the ExternalEndpointManager will additionally perform the necessary reconciliation by writing EndpointSlice objects. Since Linkerd's control plane may run in HA, we also add a lease object that will be used by the manager. When a lease is claimed, a flag is turned on in the manager to let it know it may perform writes. A more compact list of changes: * Add a new ExternalEndpointManager file and struct that wires up the necessary mechanisms to watch resources. * We also add a new test file; the tests are rudimentary for now. * Add RBAC rules to the destination service: * Allow policy and destination to read ExternalWorkload objects * Allow destination to create / update / read Lease objects * Wire-up mock clients for ExternalWorkload objects in anticipation of more involved tests Signed-off-by: Matei David <[email protected]>
Signed-off-by: Matei David <[email protected]>
Update now adds filtering to callbacks, including typecasts and a more comprehensive filter for which ExternalWorkload to update based on the spec changes. Signed-off-by: Matei David <[email protected]>
Signed-off-by: Matei David <[email protected]>
Signed-off-by: Matei David <[email protected]>
Signed-off-by: Matei David <[email protected]>
controller/api/destination/external-workload/endpoints_controller.go
Outdated
Show resolved
Hide resolved
Signed-off-by: Matei David <[email protected]>
Signed-off-by: Matei David <[email protected]>
Signed-off-by: Matei David <[email protected]>
Signed-off-by: Matei David <[email protected]>
controller/api/destination/external-workload/endpoints_controller.go
Outdated
Show resolved
Hide resolved
controller/api/destination/external-workload/endpoints_controller.go
Outdated
Show resolved
Hide resolved
controller/api/destination/external-workload/endpoints_controller.go
Outdated
Show resolved
Hide resolved
controller/api/destination/external-workload/endpoints_controller.go
Outdated
Show resolved
Hide resolved
controller/api/destination/external-workload/endpoints_controller.go
Outdated
Show resolved
Hide resolved
controller/api/destination/external-workload/endpoints_controller.go
Outdated
Show resolved
Hide resolved
controller/api/destination/external-workload/endpoints_controller.go
Outdated
Show resolved
Hide resolved
controller/api/destination/external-workload/endpoints_controller.go
Outdated
Show resolved
Hide resolved
Signed-off-by: Matei David <[email protected]>
Signed-off-by: Matei David <[email protected]>
Signed-off-by: Matei David <[email protected]>
Signed-off-by: Matei David <[email protected]>
Signed-off-by: Matei David <[email protected]>
Signed-off-by: Matei David <[email protected]>
Signed-off-by: Matei David <[email protected]>
controller/api/destination/external-workload/endpoints_controller.go
Outdated
Show resolved
Hide resolved
controller/api/destination/external-workload/endpoints_controller.go
Outdated
Show resolved
Hide resolved
controller/api/destination/external-workload/endpoints_controller.go
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job. We are getting there. I left some feedback that can hopefully make things easier to read. This diffing logic is always quite error-prone. This is why I think you need to rely on more isolated tests like the one I provided in the comments. This should make it easier to think through and verify stuff.
Also, it would be good you can provide some functional testing instructions for this change so anyone can try it out themselves.
controller/api/destination/external-workload/endpoints_controller.go
Outdated
Show resolved
Hide resolved
controller/api/destination/external-workload/endpoints_controller.go
Outdated
Show resolved
Hide resolved
controller/api/destination/external-workload/endpoints_controller.go
Outdated
Show resolved
Hide resolved
controller/api/destination/external-workload/endpoints_controller.go
Outdated
Show resolved
Hide resolved
controller/api/destination/external-workload/endpoints_controller.go
Outdated
Show resolved
Hide resolved
Signed-off-by: Matei David <[email protected]>
Signed-off-by: Matei David <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, one last question to think through.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Great job.
It may be worth noting in a comment that this is structurally based on https://github.com/kubernetes/kubernetes/blob/master/pkg/controller/endpoint/endpoints_controller.go and perhaps even noting cases where they significantly differ (if any). |
…ce-new-endpoint-controller
Signed-off-by: Matei David <[email protected]>
Signed-off-by: Matei David <[email protected]>
controller/api/destination/external-workload/endpoints_controller.go
Outdated
Show resolved
Hide resolved
Signed-off-by: Matei David <[email protected]>
For mesh expansion, we need to register an ExternalWorkload's service membership. Service memberships describe which Service objects an ExternalWorkload is part of (i.e. which service can be used to route traffic to an external endpoint).
Service membership will allow the control plane to discover configuration associated with an external endpoint when performing discovery on a service target.
To build these memberships, we introduce a new controller to the destination service, responsible for watching Service and ExternalWorkload objects, and for writing out EndpointSlice objects for each Service that selects one or more external endpoints.
As a first step, we add a new ExternalEndpointManager in the destination service's package that watches services and workloads. In a follow-up change, the ExternalEndpointManager will additionally perform the necessary reconciliation by writing EndpointSlice objects.
Since Linkerd's control plane may run in HA, we also add a lease object that will be used by the manager. When a lease is claimed, a flag is turned on in the manager to let it know it may perform writes.
A more compact list of changes:
Note to reviewers
You can run the controller locally to test the behaviour. You need to make a small change to
controller/destination/main
k8s.ExtWorkload
to informers configured (make sure it's the branch that uses endpointslices)You can then run it with
kubectl proxy
(as a bg job) andgo run controller/cmd/main.go destination
. You should see logs from the newexternal-endpoints-controller
component.Sample manifests: