databricks / click

The "Command Line Interactive Controller for Kubernetes"
Apache License 2.0
1.49k stars 84 forks source link

Fix bug for K8s API servers behind proxy #224

Open goyalankit opened 10 months ago

goyalankit commented 10 months ago

We have multiple Kubernetes servers behind a proxy and the current logic removes the URL prefix which causes a Bad Request.

For example: According to the current logic:

self.endpoint = "https://hostname/cluster-1"
parts.uri = "/api/v1/namespaces/default/pods"
// strips the cluster-1 prefix
self.endpoint.join(&parts.uri.to_string())?; // https://hostname/api/v1/namespaces/default/pods

Error:

[cluster-1] [default] [none] > pods
Parse Error: Got unexpected status 400 Bad Request (Other(Err(Error("expected value", line: 1, column: 1))), 0)

The commit fixes the above situation by preserving the prefix url

MortezaRamezani commented 10 months ago

I think this line needs the change as well:

https://github.com/databricks/click/blob/bcf32999229cd86fef60d08115a49d51c6431924/src/k8s.rs#L383