---
title: "DI and actions — Kubernetes API for Laravel | Roundly"
description: "Inject KubernetesManager for the facade’s exact API without static calls, or bind resource objects to a managed cluster — the package has no actions."
url: https://roundly-consulting.com/open-source/docs/kubernetes-api-for-laravel/without-facade
language: en
---

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

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

# DI and actions

The facade is the shortest route and the recommended default, but it is only sugar over RoundlyConsulting\\KubernetesApi\\KubernetesManager — the facade root, bound as a container singleton. Inject the manager for the same API with an explicit dependency and no static calls:

```php
use RoundlyConsulting\KubernetesApi\DataTransferObjects\Scale;
use RoundlyConsulting\KubernetesApi\KubernetesManager;

final class ScaleCheckout
{
    public function __construct(private KubernetesManager $kubernetes) {}

    public function __invoke(int $replicas): Scale
    {
        return $this->kubernetes->cluster('production')
            ->deployments()
            ->setName('checkout')
            ->scale($replicas);
    }
}
```

## Resource objects instead of actions

This package is a remote-API client, so there are no action classes: the use cases are the resource objects themselves. Build one directly and bind it to a cluster from the manager — it goes through the same transport, and the same fake:

```php
use RoundlyConsulting\KubernetesApi\Resources\ConfigMap;

ConfigMap::make()
    ->setCluster($kubernetes->cluster('production'))
    ->setNamespace('shop')
    ->setName('settings')
    ->setData(['FEATURE_X' => 'on'])
    ->create();
```

## Three entry points, one transport

| Entry point | Call | Use it when |
| --- | --- | --- |
| Facade | `Kubernetes::cluster('production')->deployments()->setName('checkout')->scale(5)` | The recommended default — shortest, and what every example here uses. |
| Injected manager | `$this->kubernetes->cluster('production')->deployments()->setName('checkout')->scale(5)` | You want an explicit constructor dependency and no static calls. |
| Resource object | `Deployment::make()->setCluster($kubernetes->cluster('production'))->setName('checkout')->scale(5)` | You build a resource first and bind it to a managed cluster later. |

- Kubernetes::fake() swaps the manager behind the facade and in the container, so an injected KubernetesManager receives the fake too.
- Resources bound to a cluster the manager handed out — named, default, ad-hoc or namespace-scoped — use that cluster’s transport, so they are faked as well.
- A cluster built without the manager (new Cluster, Cluster::make()) uses the real HTTP transport and bypasses the fake — resolve clusters through the facade or the manager.

## 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/docs/kubernetes-api-for-laravel.md)
