Installation
Require the package with Composer. The service provider and the Kubernetes facade alias are auto-discovered — no manual registration:
composer require roundly-consulting/kubernetes-api-for-laravelPublishing the config is optional — the package works with zero configuration: set KUBERNETES_URL and KUBERNETES_TOKEN for a single cluster, add more under clusters, or define clusters in code. The default resource map ships built in. Publish the config to add clusters or tune rate limits, HTTP client options, the Traefik API group or the resource map:
php artisan vendor:publish --tag="kubernetes-config"kubernetes-config is the only publish tag. There are no migrations, views or routes — the package is a pure HTTP client. The provider binds KubernetesManager as a container singleton (the facade root), adds the kubernetes:ping command and contributes a Kubernetes section to php artisan about.
Your first request
Point the default cluster at your apiserver through the environment:
KUBERNETES_URL=https://api.my-cluster.example:6443
KUBERNETES_TOKEN=service-account-tokenThen list a namespace’s deployments through the facade:
use RoundlyConsulting\KubernetesApi\Facades\Kubernetes;
Kubernetes::ping(); // true when the apiserver answers
foreach (Kubernetes::namespace('shop')->deployments()->get() as $deployment) {
echo $deployment->getName().': '.$deployment->getReadyReplicasCount().' ready'.PHP_EOL;
}Show your open-source love
This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.
More ways to support, including cryptoBy donating, you agree to our donation terms.
Want this built into your product?
We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.