Full Kubernetes API Support
Interact with 33+ resource types including Pods, Deployments, Services, ConfigMaps, and more.
Control your Kubernetes clusters with this modern PHP-based client. Supports exec API, CRDs, and any form of authentication.
<?php
use RenokiCo\PhpK8s\K8s;
use RenokiCo\PhpK8s\KubernetesCluster;
// Connect to your cluster
$cluster = new KubernetesCluster('https://127.0.0.1:8443');
// Create a pod
$pod = K8s::pod($cluster)
->setName('my-app')
->setNamespace('default')
->setContainers([
K8s::container()
->setName('app')
->setImage('nginx:latest')
->setPorts([
K8s::containerPort()->setContainerPort(80)
])
])
->create();
echo $pod->getName(); // my-app
echo $pod->getPodPhase(); // PodPhase::RUNNINGNote: This is a maintained fork of renoki-co/php-k8s with enhanced PHP 8.2+ support and additional features.
This fork was created to continue active development and modernization of the library. Key differences from the upstream project:
See the Fork Differences page for a detailed comparison with the upstream project.
Since this is a fork, add the repository to your composer.json:
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/cuppett/php-k8s"
}
]
}Then install the package:
composer require renoki-co/php-k8sFor Laravel projects:
composer require renoki-co/laravel-php-k8sNote: The laravel-php-k8s package is from the upstream project. Compatibility with this fork is not guaranteed.
This library is tested against multiple Kubernetes versions:
This project is licensed under the Apache-2.0 License.