### Install package with Composer Source: https://github.com/roundly-consulting/kubernetes-api-for-laravel/blob/main/README.md Install the package using Composer. Requires PHP 8.4 and Laravel 12 or 13. After installation, configure the cluster URL and token via KUBERNETES_URL and KUBERNETES_TOKEN in .env. ```bash composer require roundly-consulting/kubernetes-api-for-laravel ``` -------------------------------- ### Install Traefik CRDs on OrbStack with Helm Source: https://github.com/roundly-consulting/kubernetes-api-for-laravel/blob/main/tests/Integration/README.md Install Traefik on the local OrbStack cluster to enable the Traefik CRD tests (IngressRoute, Middleware). This installs the ingressroutes.traefik.io and middlewares.traefik.io CRDs (group traefik.io/v1alpha1) and the Traefik controller. The standalone TraefikService CRD is not covered. ```bash helm repo add traefik https://traefik.github.io/charts helm repo update helm install traefik traefik/traefik \ --namespace traefik --create-namespace \ --kube-context orbstack --wait ``` -------------------------------- ### List, create, scale, and restart resources in a namespace Source: https://github.com/roundly-consulting/kubernetes-api-for-laravel/blob/main/README.md Shows the fluent API for operating on resources within a single namespace of the default cluster. Includes listing pods by label, creating a deployment with a container, scaling via the /scale subresource, and performing a rollout restart. ```php 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` ``` -------------------------------- ### Connect to other clusters Source: https://github.com/roundly-consulting/kubernetes-api-for-laravel/blob/main/README.md Shows how to reach clusters other than the default: by name from config/kubernetes.php, by kubeconfig context, and a ping to check if the apiserver responds. ```php 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? ``` -------------------------------- ### Run integration tests with K8S_INTEGRATION=1 Source: https://github.com/roundly-consulting/kubernetes-api-for-laravel/blob/main/tests/Integration/README.md Run the integration test suite against the local OrbStack cluster. Requires OrbStack running with the 'orbstack' kube context available. The suite is excluded from the default composer test command. ```bash K8S_INTEGRATION=1 composer test-integration ```