maclof / kubernetes-client

A simple yet elegant client for accessing and controlling a Kubernetes cluster (https://github.com/kubernetes/kubernetes)
MIT License
231 stars 82 forks source link

Is it working? #128

Open lbcd opened 8 months ago

lbcd commented 8 months ago

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 commented 8 months ago

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 commented 8 months ago

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

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

MaSpeng commented 8 months ago

@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 commented 8 months ago

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 commented 8 months ago

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);