Skip to content

feat: add discovery k8s dump data interface#11111

Merged
moonming merged 13 commits into
apache:masterfrom
hanqingwu:add-k8s-dump-data
Apr 18, 2024
Merged

feat: add discovery k8s dump data interface#11111
moonming merged 13 commits into
apache:masterfrom
hanqingwu:add-k8s-dump-data

Conversation

@hanqingwu

@hanqingwu hanqingwu commented Apr 2, 2024

Copy link
Copy Markdown
Contributor

Description

Fix: #11057

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@shreemaan-abhishek

Copy link
Copy Markdown
Contributor

Test cases are also needed.

@hanqingwu

Copy link
Copy Markdown
Contributor Author

I have not find a k8s mock apiserver like one in the test case

@shreemaan-abhishek

Copy link
Copy Markdown
Contributor

@hanqingwu

Copy link
Copy Markdown
Contributor Author

@shreemaan-abhishek ,Thanks , I have found the method build k8s test env in workflows/kubernetes-ci.yml .

Comment thread t/kubernetes/discovery/kubernetes3.t Outdated
--- more_headers
Content-type: application/json
--- response_body_like
.*"endpoints".*

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

--- response_body_like
.*"endpoints".*

this doesn't seem sufficient to show that the feature works fine. The verification should be more descriptive.

@shreemaan-abhishek

Copy link
Copy Markdown
Contributor

@hanqingwu should we add docs as well? Also, could you please show how the response body looks like?

@hanqingwu

Copy link
Copy Markdown
Contributor Author

yes, we should add docs
response like this:
{"endpoints":[{"id":"first","endpoints":[{"name":"default/kubernetes","value":"{\"https\":[{\"host\":\"172.18.0.2\",\"port\":6443,\"weight\":50}]}"},{"name":"kube-system/kube-dns","value":"{\"dns-tcp\":[{\"host\":\"10.244.0.3\",\"port\":53,\"weight\":50},{\"host\":\"10.244.0.4\",\"port\":53,\"weight\":50}],\"dns\":[{\"host\":\"10.244.0.3\",\"port\":53,\"weight\":50},{\"host\":\"10.244.0.4\",\"port\":53,\"weight\":50}],\"metrics\":[{\"host\":\"10.244.0.3\",\"port\":9153,\"weight\":50},{\"host\":\"10.244.0.4\",\"port\":9153,\"weight\":50}]}"},{"name":"local-path-storage/rancher.io-local-path","value":"{}"},{"name":"ns-a/ep","value":"{}"},{"name":"ns-b/ep","value":"{}"},{"name":"ns-c/ep","value":"{}"}]},{"id":"second","endpoints":[{"name":"default/kubernetes","value":"{\"https\":[{\"host\":\"172.18.0.2\",\"port\":6443,\"weight\":50}]}"},{"name":"kube-system/kube-dns","value":"{\"dns-tcp\":[{\"host\":\"10.244.0.3\",\"port\":53,\"weight\":50},{\"host\":\"10.244.0.4\",\"port\":53,\"weight\":50}],\"dns\":[{\"host\":\"10.244.0.3\",\"port\":53,\"weight\":50},{\"host\":\"10.244.0.4\",\"port\":53,\"weight\":50}],\"metrics\":[{\"host\":\"10.244.0.3\",\"port\":9153,\"weight\":50},{\"host\":\"10.244.0.4\",\"port\":9153,\"weight\":50}]}"},{"name":"local-path-storage/rancher.io-local-path","value":"{}"},{"name":"ns-a/ep","value":"{}"},{"name":"ns-b/ep","value":"{}"},{"name":"ns-c/ep","value":"{}"}]}],"config":[{"id":"first","client":{"token_file":"/tmp/var/run/secrets/kubernetes.io/serviceaccount/token"},"service":{"host":"127.0.0.1","schema":"https","port":"6443"},"watch_endpoint_slices":true,"default_weight":50,"shared_size":"1m"},{"id":"second","client":{"token_file":"/tmp/var/run/secrets/kubernetes.io/serviceaccount/token"},"service":{"host":"127.0.0.1","schema":"http","port":"6445"},"watch_endpoint_slices":true,"default_weight":50,"shared_size":"1m"}]}

@shreemaan-abhishek

Copy link
Copy Markdown
Contributor

Please add docs then.

Comment thread apisix/discovery/kubernetes/init.lua
Comment thread apisix/discovery/kubernetes/init.lua
### Memory Dump API

```shell
GET /v1/discovery/kubernetes/dump

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
GET /v1/discovery/kubernetes/dump
curl http://127.0.0.1:9090/v1/discovery/kubernetes/dump | jq

Comment thread docs/en/latest/discovery/kubernetes.md Outdated
Comment thread docs/en/latest/discovery/kubernetes.md
Comment thread t/kubernetes/discovery/kubernetes3.t
Comment thread docs/en/latest/discovery/kubernetes.md Outdated
@Revolyssup
Revolyssup self-requested a review April 18, 2024 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Enabling discovery kubernetes services configuration doesn't list cluster existing endpoints in Dashboard Service list

4 participants