roundly-consulting / kubernetes-api-for-laravel
A fluent, Eloquent-style client for the Kubernetes API in Laravel.
Package info
github.com/roundly-consulting/kubernetes-api-for-laravel
pkg:composer/roundly-consulting/kubernetes-api-for-laravel
Fund package maintenance!
Requires
- php: ^8.4
- illuminate/contracts: ^12.0|^13.0
- roundly-consulting/enums-for-laravel: ^1.0
- roundly-consulting/http-client-rate-limits-for-laravel: ^1.0
- roundly-consulting/package-toolkit-for-laravel: ^1.0
- symfony/yaml: ^7.0|^8.0
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.0
- nunomaduro/collision: ^8.0
- orchestra/testbench: ^10.0|^11.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- roundly-consulting/testing-for-laravel: ^1.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Kubernetes API for Laravel
A fluent, Eloquent-style client for the Kubernetes API in Laravel. Talk to one or many clusters through a chainable API built on Laravel's HTTP client, with the core Kubernetes resources, Traefik CRDs and your own custom resources built in.
Installation
Requires PHP 8.4, Laravel 12 or 13.
composer require roundly-consulting/kubernetes-api-for-laravel
Point it at your cluster with KUBERNETES_URL and KUBERNETES_TOKEN in .env.
Usage
List, create, scale and restart resources in one namespace of the default cluster:
use RoundlyConsulting\KubernetesApi\Facades\Kubernetes; use RoundlyConsulting\KubernetesApi\Resources\Pod; use RoundlyConsulting\KubernetesApi\Resources\Types\Container; $shop = Kubernetes::namespace('shop'); // every request stays in `shop` $pods = $shop->pods()->whereLabel('app', 'web')->get(); // a collection of Pod resources $shop->deployments() ->setName('checkout') ->setReplicas(3) ->setPodsSelectors(['app' => 'checkout']) ->setTemplate(Pod::make() ->setLabels(['app' => 'checkout']) ->setContainers([Container::make()->setName('app')->setImage('nginx', '1.27-alpine')])) ->create(); $shop->deployments()->withName('checkout')->scale(5); // via the /scale subresource $shop->deployments()->withName('checkout')->rolloutRestart(); // like `kubectl rollout restart`
Reach any other cluster the same way:
Kubernetes::cluster('production')->nodes()->get(); // a cluster from config/kubernetes.php Kubernetes::fromKubeConfig(context: 'staging')->pods()->get(); // a kubeconfig context Kubernetes::ping(); // does the apiserver answer?
Documentation
The full documentation — configuration, every feature and its API, and testing — lives on our website: roundly-consulting.com/open-source/docs/kubernetes-api-for-laravel
Release notes are in CHANGELOG.md. To contribute, see the contributing guide.
Support our work
This package is free and open source, built and maintained by Roundly Consulting. If it saves you time, please consider supporting our open-source work — a one-time donation, a monthly pledge on Patreon or a crypto donation helps fund maintenance, new features and new packages.
License
The MIT License (MIT). Please see License File for more information.