A PHP Client For Manage Kubernetes Cluster Based on official of Kubernetest interface as well as dependent GuzzleHttp to generate.
standard
composer require alicfeng/kubernetes-client -vvv
Laravel
php artisan vendor:publish --provider="AlicFeng\Kubernetes\ServiceProvider"
OR
php artisan vendor:publish --tag=kubernetes
use AlicFeng\Kubernetes\Kubernetes;
$config = [
'base_uri' => 'https://127.0.0.1:6443',
'token' => 'token',
'namespace' => 'default'
];
$service = Kubernetes::service($config);
$metadata = [
'name' => 'demo-service'
];
$spec = [
'type' => 'NodePort',
'selector' =>
'k8s-app' => 'demo-service',
],
'ports' => [
[
'protocol' => 'TCP',
'port' => 80,
'targetPort' => 80,
'nodePort' => 30008
]
]
];
# Create Service
$service->setMetadata($metadata)->setSpec($spec)->create();
# or
$service->setApiVersion('v1')->setKind('Service')->create($yaml);
# Patch Service
$service->apply();
# Delete Service
$service->delete('service-name');
# Service Exist
$service->list()->exist('service-name');
# Item Service
$service->list()->item('service-name');
See the API documentation for an explanation of the options:
https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。