P8P is a PHP SDK for interacting with Kubernetes APIs. It automatically generates strongly-typed PHP classes from Kubernetes OpenAPI specifications.
Check out the complete documentation to get started with P8P.
This project is organized as a monorepo. Each package is also available individually:
- p8p/client - HTTP client for communicating with Kubernetes APIs
- p8p/symfony-bundle - Symfony bundle for easy integration
- p8p/generator - Code generator from OpenAPI specifications
- p8p/sdk - Generated Kubernetes SDK (models and services)
use P8p\Client\ClientFactory;
use P8p\Sdk\Api\Core\V1\PodApi;
$client = ClientFactory::fromUrl('http://127.0.0.1:8001')->getClient();
$podApi = $client->getApi(PodApi::class);
$pods = $podApi->list(namespace: 'default');
dd($pods->getContent())use P8p\Client\ClientFactory;
use P8p\Sdk\Api\Core\V1\PodApi;
use P8p\Sdk\Schema\Core\V1\Container;
use P8p\Sdk\Schema\Core\V1\Pod;
use P8p\Sdk\Schema\Core\V1\PodSpec;
use P8p\Sdk\Schema\Core\V1\ObjectMeta;
$client = ClientFactory::fromUrl('http://127.0.0.1:8001')->getClient();
$podApi = $client->getApi(PodApi::class);
$rs = $podApi->create('default', new Pod(
metadata: new ObjectMeta(
name: 'test-pod',
),
spec: new PodSpec(
containers: [
new Container(
name: 'nginx',
image: 'nginx',
),
]
)
));
dd($rs->getContent())