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

BaseUri doesn't work properly. #35

Closed
tamaspanczel opened this issue May 14, 2018 · 7 comments
Closed

BaseUri doesn't work properly. #35

tamaspanczel opened this issue May 14, 2018 · 7 comments

Comments

@tamaspanczel
Copy link

If kubernetes master url contains path like http://localhost/kubernetes/ then baseUri doesn't work properly because it calls http://localhost/v1/api/... instead of http://localhost/kubernetes/v1/api/... in Client.php:

public function sendRequest($method, $uri, $query = [], $body = [], $namespace = true, $apiVersion = null)
{
  $baseUri = $apiVersion ? '/apis/' . $apiVersion : '/api/' . $this->apiVersion;
@maclof
Copy link
Owner

maclof commented May 14, 2018

How are you deploying Kubernetes if your API is nested under a /kubernetes/ path? I've not seen this before

@tamaspanczel
Copy link
Author

We are using Rancher and our cluster k8s url is:
https://domain.com/k8s/clusters/c-cxwjp/

@jamesmcminn96
Copy link

Have run into the same issue, based on RFC3986, the guzzle client is being created incorrectly such that only the host will be used from the master parameter of the k8s Client, and dropping the path.

@tamaspanczel, before I submit a PR to patch this have you had any work arounds?

@tamaspanczel
Copy link
Author

You can override public sendRequest method:

class KubernetesClient extends Maclof\Kubernetes\Client
{

    public function sendRequest($method, $uri, $query = [], $body = [], $namespace = true, $apiVersion = null)
    {
        $baseUri = $apiVersion ? 'apis/' . $apiVersion : 'api/' . $this->apiVersion;
        ...
    }

}

@maclof
Copy link
Owner

maclof commented Nov 19, 2018

What happens if you initialise the client like the following?

$client = new Client([
	'master' => 'https://domain.com/k8s/clusters/c-cxwjp',
]);

According to the Guzzle client documentation the requests should then be relative to that URL?

@maclof maclof closed this as completed in 9715e04 Nov 19, 2018
@maclof
Copy link
Owner

maclof commented Nov 19, 2018

Nevermind I see the problem, I've pushed a commit to resolve this

@jamesmcminn96
Copy link

Thanks @maclof!

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

No branches or pull requests

3 participants