Open lbcd opened 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.
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
@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.
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.
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);
Readme / doc is wrong :
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.