linkerd2/controller/cmd/service-mirror
Alex Leong 381f237f69
Add multicluster unlink command (#4802)
Fixes #4707 

In order to remove a multicluster link, we add a `linkerd multicluster unlink` command which produces the yaml necessary to delete all of the resources associated with a `linkerd multicluster link`.  These are:
* the link resource
* the service mirror controller deployment
* the service mirror controller's RBAC
* the probe gateway mirror for this link
* all mirror services for this link

This command follows the same pattern as the `linkerd uninstall` command in that its output is expected to be piped to `kubectl delete`.  The typical usage of this command is:

```
linkerd --context=source multicluster unlink --cluster-name=foo | kubectl --context=source delete -f -
```

This change also fixes the shutdown lifecycle of the service mirror controller by properly having it listen for the shutdown signal and exit its main loop.

A few alternative designs were considered:

I investigated using owner references as suggested [here](https://github.com/linkerd/linkerd2/issues/4707#issuecomment-653494591) but it turns out that owner references must refer to resources in the same namespace (or to cluster scoped resources).  This was not feasible here because a service mirror controller can create mirror services in many different namespaces.

I also considered having the service mirror controller delete the mirror services that it created during its own shutdown.  However, this could lead to scenarios where the controller is killed before it finishes deleting the services that it created.  It seemed more reliable to have all the deletions happen from `kubectl delete`.  Since this is the case, we avoid having the service mirror controller delete mirror services, even when the link is deleted, to avoid the race condition where the controller and CLI both attempt to delete the same mirror services and one of them fails with a potentially alarming error message.

Signed-off-by: Alex Leong <alex@buoyant.io>
2020-08-04 16:21:59 -07:00
..
cluster_watcher.go Add multicluster unlink command (#4802) 2020-08-04 16:21:59 -07:00
cluster_watcher_mirroring_test.go Add support for service-mirror selectors (#4795) 2020-07-30 10:07:14 -07:00
cluster_watcher_test_util.go Add support for service-mirror selectors (#4795) 2020-07-30 10:07:14 -07:00
events_formatting.go Make service mirror controller per target cluster (#4710) 2020-07-23 14:32:50 -07:00
jittered_ticker.go Add liveliness checks and metrics for multicluster gateway (#4233) 2020-04-27 13:06:58 +03:00
main.go Add multicluster unlink command (#4802) 2020-08-04 16:21:59 -07:00
metrics.go Make service mirror controller per target cluster (#4710) 2020-07-23 14:32:50 -07:00
probe_worker.go Make service mirror controller per target cluster (#4710) 2020-07-23 14:32:50 -07:00