美文网首页程序员
A PHP Client For Manage Kubernet

A PHP Client For Manage Kubernet

作者: AlicFeng | 来源:发表于2020-12-06 22:03 被阅读0次

    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

    ₤ 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 Kubernet

        本文链接:https://www.haomeiwen.com/subject/nbpawktx.html