dotnetcore / CAP

Distributed transaction solution in micro-service base on eventually consistency, also an eventbus with Outbox pattern
http://cap.dotnetcore.xyz
MIT License
6.61k stars 1.28k forks source link

K8S node discovery with filtering options #1577

Open apatozi opened 2 weeks ago

apatozi commented 2 weeks ago

Description:

The K8s discovery was working ok but not great for a real life scenario use case. There were the following problems:

Changes in this PR address the above issues by doing the following measures:

Issue(s) addressed:

Changes:

Affected components:

How to test:

These changes can only be tested by running a project inside kubernetes. After setting up and having some test services in the list try the latter scenarios.

Scenario 1: Hide a node using label dotnetcore.cap.visibility: hide on a service.

Scenario 2: Hide all nodes if not explicitly shown

Additional notes (optional):

The GetNodes Method was always returning an empty list because the ns argument was always null in any case. I changed that method to return the list of the services that reside in the namespace of the K8s POD where the dashboard is running. This opens the possibility for the api-access ServiceAccount to not use a ClusterRole but only ose a Role that has access to the services inside the namespace where the dashboard runs. This is the only use case needed for my project as we have different namespaces for different enviorments inside the K8s.

Checklist:

Documentation updated.

Reviewers:

yang-xiaodong commented 2 weeks ago

Thanks for the PR, looks good. Can you add documentation about ShowOnlyExplicitVisibleNodes?

apatozi commented 2 weeks ago

Thanks for the PR, looks good. Can you add documentation about ShowOnlyExplicitVisibleNodes?

I found the documentation and added all the needed Information about the configuration option and the k8s labels that can be used to customize the view. I didn't do it in the beginning because I did open only with Visual Studio and did not find the docs at first.

For the Chinese part of the docs I did my best with google Translate but I strongly suggest for someone that speaks Chinese to check it out.