A PHP Client For Manage Kubernetes Cluster

Based on official of Kubernetest interface as well as dependent GuzzleHttp to generate.

Quick start

  • standard

    composer require alicfeng/kubernetes-client -vvv
    
  • Laravel

    php artisan vendor:publish --provider="AlicFeng\Kubernetes\ServiceProvider"
    # OR
    php artisan vendor:publish --tag=kubernetes
    

✨ Features

  • Service
  • Deployment
  • Pod
  • Job
  • ConfigMap
  • DaemonSet
  • Node
  • Secrets
  • StatefulSet
  • Event
  • Pvc
  • PersistentVolumeClaim
  • Ingress
  • ReplicationController

Usage

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

Thanks developer

  • lljiuzheyang
  • lsrong

₤ Kubernetes

See the API documentation for an explanation of the options:

https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/

你可能感兴趣的:(A PHP Client For Manage Kubernetes Cluster)