alicfeng/kubernetes-client

Kubernetes PHP Client

v1.3.1 2021-05-06 02:58 UTC

This package is auto-updated.

Last update: 2024-11-06 10:51:52 UTC


README

KubernetesClient

A PHP Client For Manage Kubernetes Cluster
Based on official of Kubernetes interface as well as dependent GuzzleHttp to generate.

Build Status Latest Stable Version Total Downloads License

🚀 Quick start

  • standard
composer require alicfeng/kubernetes-client -vvv
  • Laravel
php artisan vendor:publish --provider="AlicFeng\Kubernetes\ServiceProvider\AsmServiceProvider"
php artisan vendor:publish --provider="AlicFeng\Kubernetes\ServiceProvider\KubernetesServiceProvider"
# OR
php artisan vendor:publish --tag=kubernetes
php artisan vendor:publish --tag=asm

✨ Features

  • Service

  • Deployment

  • Pod

  • Job

  • ConfigMap

  • DaemonSet

  • Node

  • Secrets

  • StatefulSet

  • Event

  • PersistentVolumeClaim

  • Ingress

  • ReplicationController

  • GagaWay

  • VirtualService

☛ Usage

Authorization support three method including token,username & password as well as cert file

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

# Patch Service
$service->apply('name');

# Delete Service
$service->delete('name');

# Service Exist
$service->list()->exist('name');

# Item Service
$service->list()->item('name');

💖 Thanks developer

₤ Kubernetes

See the API documentation for an explanation of the options:

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