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

Is it working? #128

Open
lbcd opened this issue Feb 19, 2024 · 5 comments
Open

Is it working? #128

lbcd opened this issue Feb 19, 2024 · 5 comments

Comments

@lbcd
Copy link

lbcd commented Feb 19, 2024

Readme / doc is wrong :

$httpClient = Guzzle6Client::createWithConfig([
            'verify' => false,
        ]);

$client = new Client([
	'master' => 'https://master.mycluster.com',
], null, $httpClient);

Client take 2 parameters, not 3. And the second one is not an
Http\Adapter\Guzzle6\Client
but a
\GuzzleHttp\Client

But even by fixing that it is not working
cURL error 3: (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)

Seems that this lib is not really up to date and not tested or / and documentation out of date.

@lbcd
Copy link
Author

lbcd commented Feb 19, 2024

I have forget :
vendor/maclof/kubernetes-client/src/Models/Model.php

use Illuminate\Support\Contracts\ArrayableInterface as Arrayable;

And not
use Illuminate\Contracts\Support\Arrayable; that doesn't exists.

@lbcd
Copy link
Author

lbcd commented Feb 19, 2024

For those who want to use this lib, you will have to patch it:

  • vendor/maclof/kubernetes-client/src/Models/Model.php => use Illuminate\Support\Contracts\ArrayableInterface as Arrayable; instead of use Illuminate\Contracts\Support\Arrayable; that doesn't exists.

  • Here is an example of working code :

        $client = new Client([
            'master' => 'https://you-url/k8s/clusters/your-cluster-id/',
            'token' => 'your-token',
            'verify' => false      // if needed like self signed certificate
        ]);

        $client->setNamespace('your-namespace');
        $deployments =$client->deployments()->setLabelSelector(['app' => 'my-application'])->find();

        dump($deployments);

@MaSpeng would be nice to patch "vendor/maclof/kubernetes-client/src/Models/Model.php" and to update documentation

@MaSpeng
Copy link
Contributor

MaSpeng commented Feb 19, 2024

@lbcd I am sorry but I am only a contributor on my own and not one of the library maintainers. But please feel free to provide a PR addressing your mentioned issues and discoveries.

@lbcd
Copy link
Author

lbcd commented Feb 19, 2024

My bad I didn't see that composer get version 0.11 cause I'm on SF 7 and PHP 8.2. And dependencies are not compatible.
What is funny is that 0.11 is more compatible than the last version (0.30). I will try to push a PR.

@lbcd
Copy link
Author

lbcd commented Feb 19, 2024

Here is a working example with 0.30 :

$client = new Client([
            'master' => 'https://you-url/k8s/clusters/your-cluster-id',
            'token' => 'your-token',
            'namespace' => 'your-namespace'
        ], null, new \GuzzleHttp\Client(['verify' => false]));


        $deployment = $client->deployments()->setLabelSelector(['app' => 'my-app'])->first();
        dump($deployment);
        dump($deployment->toArray()['spec']['template']['spec']['containers'][0]['image']);
        $deployments = $client->deployments()->find();
        dump($deployments);

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

2 participants