---
title: "Kubernetes API for Laravel — docs | Roundly"
description: "Developer docs for Kubernetes API for Laravel: named clusters, kubeconfig, CRUD on 33 resources, patch, scale, logs, exec, watch and rate limiting."
url: https://roundly-consulting.com/open-source/docs/kubernetes-api-for-laravel
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

Open source

# Kubernetes API for Laravel

Install

`composer require roundly-consulting/kubernetes-api-for-laravel`

Requires: PHP ^8.4 · Laravel ^12.0|^13.0

[GitHub](https://github.com/roundly-consulting/kubernetes-api-for-laravel) [Packagist](https://packagist.org/packages/roundly-consulting/kubernetes-api-for-laravel) [Donate (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Patreon](https://www.patreon.com/cw/roundly)

## Overview

A fluent, Eloquent-style client for the Kubernetes API in Laravel. Talk to one or many clusters through Laravel’s own HTTP client — list, create, patch, scale and restart workloads, stream pod logs, exec into containers, mint short-lived service-account tokens and watch resources change — with 33 built-in resource types, the Traefik CRDs and your own custom resources. Everything starts at the Kubernetes facade — or an injected KubernetesManager — every request is paced per cluster, and Kubernetes::fake() swaps in an in-memory apiserver for tests. MIT-licensed and dependency-light: beyond Laravel it needs only symfony/yaml and three small Roundly packages.

### What you get

#### Eloquent-style resources

Fluent get, find, create, update, updateOrCreate, patch and delete on 33 typed resources, with selectors and continue-token pagination.

#### One facade, many clusters

Kubernetes::cluster('production') or an injected KubernetesManager. Clusters come from config, code, a kubeconfig or the pod — and are immutable.

#### Operational verbs

Scale, rollout restart, four patch strategies and server-validated dry runs — each a single call.

#### Logs, exec and watch

Fetch or stream pod logs, run commands inside a container over WebSocket, and watch resources change in real time.

#### An in-memory apiserver for tests

Kubernetes::fake() answers and records every request — seed objects, then assert what was created, scaled, restarted or deleted.

#### Per-cluster rate limiting

400 requests a minute per cluster by default — paced, not failed — honouring the apiserver’s 429 Retry-After.

#### Traefik and your own CRDs

IngressRoute, Middleware, TLSStore, ServersTransport and TLSOption built in; register custom resources in one line.

#### Short-lived service-account tokens

requestToken() mints a token like kubectl create token — lifetime, audiences, pod binding — and returns it with its UTC expiry.

### Documentation

#### [Installation](https://roundly-consulting.com/open-source/docs/kubernetes-api-for-laravel/installation.md)

Install via Composer, optionally publish config/kubernetes.php, and let auto-discovery register the provider and the Kubernetes facade.

#### [Configuration](https://roundly-consulting.com/open-source/docs/kubernetes-api-for-laravel/configuration.md)

Every config/kubernetes.php key with its env var and default — clusters, HTTP client options, rate limits, the Traefik group and the resource map.

#### [The Kubernetes facade](https://roundly-consulting.com/open-source/docs/kubernetes-api-for-laravel/facade.md)

The Kubernetes facade in full: default-cluster shortcuts, named and ad-hoc clusters, the Cluster handle, raw requests and the 33 resource accessors.

#### [DI and actions](https://roundly-consulting.com/open-source/docs/kubernetes-api-for-laravel/without-facade.md)

Inject KubernetesManager for the facade’s exact API without static calls, or bind resource objects to a managed cluster — the package has no actions.

#### [Connecting to a cluster](https://roundly-consulting.com/open-source/docs/kubernetes-api-for-laravel/connecting.md)

Build an immutable client by hand with a URL, token and certificates, from a kubeconfig context, from the pod’s service account or from a KubeConfig.

#### [Named clusters](https://roundly-consulting.com/open-source/docs/kubernetes-api-for-laravel/named-clusters.md)

Configure clusters in config/kubernetes.php or register them in code, then resolve them anywhere by name — through the facade or dependency injection.

#### [Resource accessors](https://roundly-consulting.com/open-source/docs/kubernetes-api-for-laravel/resources.md)

The 33 typed accessors — pods, deployments, services, RBAC, storage, Traefik and more — their kind, API version and scope, plus namespace scoping.

#### [CRUD operations](https://roundly-consulting.com/open-source/docs/kubernetes-api-for-laravel/crud.md)

List, find, check existence, create, update, updateOrCreate and delete any resource — with optimistic concurrency and delete options.

#### [Listing, pagination & watch](https://roundly-consulting.com/open-source/docs/kubernetes-api-for-laravel/listing.md)

Label and field selectors, all-namespace listing, continue-token pagination, lazy iteration and real-time watch streams.

#### [Patch, scale, rollout & dry-run](https://roundly-consulting.com/open-source/docs/kubernetes-api-for-laravel/patching.md)

Four patch strategies, scaling through the /scale subresource, kubectl-style rollout restarts and server-validated dry runs.

#### [Pod logs, exec & status](https://roundly-consulting.com/open-source/docs/kubernetes-api-for-laravel/pod-logs-exec.md)

Fetch or stream pod logs with PodLogOptions, run commands in a container over WebSocket, and read pod and container health.

#### [Attributes, labels & annotations](https://roundly-consulting.com/open-source/docs/kubernetes-api-for-laravel/attributes.md)

Dot-path attribute access, spec and status helpers, labels, annotations, magic accessors, dirty tracking and serialisation on every resource.

#### [Building resources with value objects](https://roundly-consulting.com/open-source/docs/kubernetes-api-for-laravel/value-objects.md)

Compose pods and services from typed Container, Port, Probe, Volume, VolumeMount and claim-template objects instead of raw arrays.

#### [Workloads](https://roundly-consulting.com/open-source/docs/kubernetes-api-for-laravel/workloads.md)

Deployments, stateful sets, daemon sets, replica sets, jobs, cron jobs and autoscalers — typed setters and readable status helpers.

#### [ConfigMaps, secrets & networking](https://roundly-consulting.com/open-source/docs/kubernetes-api-for-laravel/config-networking.md)

ConfigMap and Secret data helpers, TLS secrets in one call, services, ingresses and network policies with correct select-all selectors.

#### [Storage, RBAC & cluster objects](https://roundly-consulting.com/open-source/docs/kubernetes-api-for-laravel/cluster-objects.md)

Namespaces, nodes, events, endpoints, volumes and claims, storage classes, roles and bindings, service accounts, quotas and limit ranges.

#### [Service-account tokens](https://roundly-consulting.com/open-source/docs/kubernetes-api-for-laravel/service-account-tokens.md)

Mint short-lived service-account tokens like kubectl create token — lifetime, audiences and binding, with input checked before any request.

#### [Traefik CRDs](https://roundly-consulting.com/open-source/docs/kubernetes-api-for-laravel/traefik.md)

IngressRoute, Middleware, TLSStore, ServersTransport and TLSOption resources with pinned REST plurals and a configurable API group.

#### [Custom resources & macros](https://roundly-consulting.com/open-source/docs/kubernetes-api-for-laravel/extending.md)

Register your own CRDs, swap a built-in resource for your subclass, and extend the client and resources with macros and conditionals.

#### [Client-side rate limiting](https://roundly-consulting.com/open-source/docs/kubernetes-api-for-laravel/rate-limiting.md)

Every apiserver request is paced per cluster — 400 a minute by default, honouring 429 Retry-After, with an optional fail-fast ceiling.

#### [Error handling](https://roundly-consulting.com/open-source/docs/kubernetes-api-for-laravel/errors.md)

Typed exceptions with body-free messages and Status accessors — apiserver errors, cluster config, namespace scope, rate limits, kubeconfig and exec.

#### [Artisan & diagnostics](https://roundly-consulting.com/open-source/docs/kubernetes-api-for-laravel/commands.md)

Check connectivity with kubernetes:ping and inspect the default cluster, rate limits, resources and Traefik group in php artisan about.

#### [Testing](https://roundly-consulting.com/open-source/docs/kubernetes-api-for-laravel/testing.md)

Kubernetes::fake() swaps in an in-memory apiserver — seed objects, stub logs and exec, then assert creates, updates, scales, restarts and deletes.

#### [Requirements](https://roundly-consulting.com/open-source/docs/kubernetes-api-for-laravel/requirements.md)

PHP 8.4+, Laravel 12 or 13 and symfony/yaml — plus three small Roundly packages that install automatically.

## 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 crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## 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.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source.md)
