Skip to content
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

feat: add discovery k8s dump data interface #11111

Merged
merged 13 commits into from
Apr 18, 2024

Conversation

hanqingwu
Copy link
Contributor

@hanqingwu hanqingwu commented Apr 2, 2024

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
Contributor

Test cases are also needed.

@hanqingwu
Copy link
Contributor Author

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

@shreemaan-abhishek
Copy link
Contributor

@hanqingwu
Copy link
Contributor Author

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

@@ -332,6 +339,8 @@ POST /operators
]
--- more_headers
Content-type: application/json
--- response_body_like
.*"endpoints".*
Copy link
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
Contributor

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

@hanqingwu
Copy link
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
Contributor

Please add docs then.

apisix/discovery/kubernetes/init.lua Show resolved Hide resolved
apisix/discovery/kubernetes/init.lua Show resolved Hide resolved
### Memory Dump API

```shell
GET /v1/discovery/kubernetes/dump
Copy link
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

docs/en/latest/discovery/kubernetes.md Outdated Show resolved Hide resolved
docs/en/latest/discovery/kubernetes.md Show resolved Hide resolved
t/kubernetes/discovery/kubernetes3.t Show resolved Hide resolved
@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
4 participants