-
Notifications
You must be signed in to change notification settings - Fork 167
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
::Kubeclient::Client::handle_uri assumes k8s api mounted at / for paths longer than 2 components #318
Comments
Great find! Looking at the code, what kubeclient needs in addition to the combined path
|
Additionally, I'm not sure extracting apiVersion from the last path segment works at all, apparently apiVersion != groupVersion ?
|
Ran into the same issue as @dirkd many thanks to suggestion re: nginx proxy at rancher/rancher#13058 (comment) got it working (Rancher 1.6; Gitlab 10.7) |
(btw - |
Any update on this issue ? It prevents me using Gitlab's Kubernetes integration with my cluster 😞 I don't have enough knowledge to try a reverse proxy as suggested... |
Thanks for the nag. I got carried away thinking of future APIs, perfect is the enemy of good...
|
Hmm, we already accidentally(?) have 2 interfaces :-(
We didn't really notice the inconsistency because bare domain works too!
EDIT: Oh, wait, now I mixed another way to initialize! According to current docs, I'm not supposed to pass version "autoscaling/v1" (though that worked?), I'm supposed to split it:
Welp... |
Anybody knows how the official kubernetes client libs express these params? |
I'm interested to see this fixed. In the meantime this is the workaround I'm using: config = Kubeclient::Config.read("#{ENV['HOME']}/.kube/config")
client = Kubeclient::Client.new(
config.context.api_endpoint + "/apis",
"v1beta1",
ssl_options: config.context.ssl_options,
auth_options: config.context.auth_options
)
client.instance_variable_set(:@api_group, "extensions")
client.instance_variable_get(:@api_endpoint).path += "/extensions"
client |
Simpler Idea: get groupVersion from discovery ?Stop caring how exactly endpoint / version are split in constructor. (well, with compatibility special casing for bare domain without |
great gem! i am also running into this issue with gitlab. would appreciate it if someone can get a fix ironed out. |
I started a small project to help understand backward-compat, and possibly for future pseudo-integration testing: https://github.com/cben/kubernetes-discovery-samples
Of course you can't actually run any actions. OK, now what can I learn from it? :-)
|
Any news on this one? |
Indeed, I'm interested as well. This breaks a lot of gitlab functionality, it would be nice to have sane api url handling. |
Sorry, I'm aware this is high priority, more or less know what to do but not finding the time :-(. Did I mention PRs always welcome? ;-)
(See also above #318 (comment) about the multiple forms that already work) And the formats we might like for this issue (not sure we need all, and not sure none of these work):
In the future I'd love the ones marked 👍 to become the recommended ways. Again, PRs for any subset of this — even just tests for just what works now — would help! |
Any news on this one? It's still not possible to use a Rancher Kubernetes Cluster with Gitlab. |
`handle_uri` expected the Kubernetes API to be rooted at `/` if more than 2 components were included in the provided URL. This was done to extract a potential `api_group` from the URL. This commit changes that behaviour, to parse that `api_group` via a regex, rather than leaning on a strict URL pattern. This commit also takes into account, that OpenShift uses `/oapi`, as well as including a test-suite for that new API URL handling. Implements ManageIQ#318 Fixes ManageIQ#418
`handle_uri` expected the Kubernetes API to be rooted at `/` if more than 2 components were included in the provided URL. This was done to extract a potential `api_group` from the URL. This commit changes that behaviour, to parse that `api_group` via a regex, rather than leaning on a strict URL pattern. This commit also takes into account, that OpenShift uses `/oapi`, as well as including a test-suite for that new API URL handling. Tests also include checks for the `@api_group` and `@api_version` instance variables and a non-default version. Implements ManageIQ#318 Fixes ManageIQ#418
`handle_uri` expected the Kubernetes API to be rooted at `/` if more than 2 components were included in the provided URL. This was done to extract a potential `api_group` from the URL. This commit changes that behaviour, to parse that `api_group` via a regex, rather than leaning on a strict URL pattern. This commit also takes into account, that OpenShift uses `/oapi`, as well as including a test-suite for that new API URL handling. Tests also include checks for the `@api_group` and `@api_version` instance variables and a non-default version. Implements ManageIQ#318 Fixes ManageIQ#418
`handle_uri` expected the Kubernetes API to be rooted at `/` if more than 2 components were included in the provided URL. This was done to extract a potential `api_group` from the URL. This commit changes that behaviour, to parse that `api_group` via a regex, rather than leaning on a strict URL pattern. This commit also takes into account, that OpenShift uses `/oapi`, as well as including a test-suite for that new API URL handling. Tests also include checks for the `@api_group` and `@api_version` instance variables and a non-default version. Implements ManageIQ#318 Fixes ManageIQ#418
Should be fixed by #457 (thanks T4cC0re!), released in kubeclient 4.9.1. Please test. |
Hi all, I'm not sure if that's the correct place to ask for this but I feel that the PR that got merged that closed this issue changed how URLs are generated (at least for our use case). I'm pretty confident that our use case falls under (above mentioned)
As of now we're using version With kubernetes URL (for the needs of our tests) set to
So with
which makes calls like
which makes calls like So the question is how to create the client in this case? The tests added in the PR that fixed this issue don't include a case like this. EDIT I've tried the approach listed in https://github.com/abonas/kubeclient#usage for the group api so that I call it like this (and get the values below accordingly):
but then a couple of assertions tests running just fine with |
The latter approach from your EDIT is correct. Can you give more info on your test? |
@cben Thanks for the prompt response! We're stubbing all of the requests here and we've noticed a problem because real requests are disabled and hence we were getting webmock errors
An example of a problematic test that fails when upgraded to
and for
As for the |
@cben I've managed to fix the problem described above with the approach that you pointed out as correct - a bit troublesome but it works. Thanks. |
Hi,
when trying to use kubeclient (v3.0.0 via Gitlab's Kubernetes integration) with a Rancher k8s cluster (both in v1.6 and v2) there's a problem regarding kubeclients assumptions (rancher/rancher#13058).
The following code assumes that as soon as there's more than two path components the second one (third entry in components after splitting) has to be the k8s api_group the user wants set:
https://github.com/abonas/kubeclient/blob/e37a8029275a6032a6f9b641b3800601ff1a2a0b/lib/kubeclient/common.rb#L149-L150
This works as long as the k8s apiserver is mounted at the
/
-route on the host providing the apiserver. As Rancher provides a common endpoint for multi-cluster environments it mounts the k8s apiserver at a deeper point of the path (to differentiate the environment) which breaks kubeclients assumptions on URL structure.The text was updated successfully, but these errors were encountered: