PHPackages                             teknoo/kubernetes-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. teknoo/kubernetes-client

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

teknoo/kubernetes-client
========================

A simple yet elegant client for accessing and controlling a Kubernetes cluster.

2.0.5(1mo ago)411.1k↑25.6%12BSD-3-ClausePHPPHP ^8.4

Since Feb 5Pushed 4w ago2 watchersCompare

[ Source](https://github.com/TeknooSoftware/kubernetes-client)[ Packagist](https://packagist.org/packages/teknoo/kubernetes-client)[ Docs](https://teknoo.software/libraries/kubernetes-client)[ GitHub Sponsors](https://github.com/sponsors/TeknooSoftware)[ Patreon](https://www.patreon.com/teknoo_software)[ RSS](/packages/teknoo-kubernetes-client/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (72)Versions (99)Used By (2)

Teknoo Software - Kubernetes Client
===================================

[](#teknoo-software---kubernetes-client)

[![Latest Stable Version](https://camo.githubusercontent.com/cde81ad3441beba707d22bde96a3e314cb35d2fb88c99cc22d6ab64fe9d720de/68747470733a2f2f706f7365722e707567782e6f72672f74656b6e6f6f2f6b756265726e657465732d636c69656e742f762f737461626c65)](https://packagist.org/packages/teknoo/kubernetes-client)[![Latest Unstable Version](https://camo.githubusercontent.com/da1731923c0b227068d952bf290f1a7716fc5931e3a7afb6b2a3c9d34efba359/68747470733a2f2f706f7365722e707567782e6f72672f74656b6e6f6f2f6b756265726e657465732d636c69656e742f762f756e737461626c65)](https://packagist.org/packages/teknoo/kubernetes-client)[![Total Downloads](https://camo.githubusercontent.com/d90a23ca3f8bc2c81f93e8c136eda7e170cc9a26bb258fb58ebab3f8a5014ff5/68747470733a2f2f706f7365722e707567782e6f72672f74656b6e6f6f2f6b756265726e657465732d636c69656e742f646f776e6c6f616473)](https://packagist.org/packages/teknoo/kubernetes-client)[![License](https://camo.githubusercontent.com/4ae9e20f3fa22f7fdc9b5d59e57c4471fe54ae67dc298512d71e5aaf28be9fef/68747470733a2f2f706f7365722e707567782e6f72672f74656b6e6f6f2f6b756265726e657465732d636c69656e742f6c6963656e7365)](https://packagist.org/packages/teknoo/kubernetes-client)[![PHPStan](https://camo.githubusercontent.com/441b5874ce4df0a2defc892979c96c46889b69cb32119d04f0b48626349f8bc9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d656e61626c65642d627269676874677265656e2e7376673f7374796c653d666c6174)](https://github.com/phpstan/phpstan)

A PHP client for managing a Kubernetes cluster. Control your Kubernetes resources by manipulating manifests, as PHP array, through the Kubernetes HTTP API. The client supports all Kubernetes API V1.28 resources, but it's possible to define new resource usable with the client. This is a fork and a rework from [Maclof Kuebrnetes library](https://github.com/maclof/kubernetes-client).

Supported API Features
----------------------

[](#supported-api-features)

### v1

[](#v1)

- Config Maps
- Delete Options
- EndPoints
- Endpoints
- Events
- Namespaces
- Nodes
- Persistent Volume
- Persistent Volume Claims
- Pods
- Quota
- Replica Sets
- Replication Controllers
- Secrets
- Service Account
- Services

### autoscaling/v2

[](#autoscalingv2)

- Horizontal Pad Autoscaler

### batch/v1

[](#batchv1)

- CronJobs
- Jobs

### batch/v1beta1

[](#batchv1beta1)

- Cron Jobs

### apps/v1

[](#appsv1)

- Daemon Set
- Deployments
- ReplicaSet

### extensions/v1beta1

[](#extensionsv1beta1)

- Daemon Sets

### networking.k8s.io/v1

[](#networkingk8siov1)

- Ingresses
- Network Policies

### certmanager.k8s.io/v1

[](#certmanagerk8siov1)

- Certificates
- Issuers

### rbac.authorization.k8s.io/v1

[](#rbacauthorizationk8siov1)

- ClusterRole
- ClusterRoleBinding
- Role
- RoleBinding

### hnc.x-k8s.io/v1

[](#hncx-k8siov1)

- Subnamespace Anchor

Basic Usage
-----------

[](#basic-usage)

```
use Teknoo\Kubernetes\Client;

$client = new Client([
	'master' => 'http://master.mycluster.com',
]);

// Find pods by label selector
$pods = $client->pods()
    ->setLabelSelector(
        [
            'name'    => 'test',
            'version' => 'a',
        ]
    )->find();

// Both setLabelSelector and setFieldSelector can take an optional
// second parameter which lets you define inequality based selectors (ie using the != operator)
$pods = $client->pods()
    ->setLabelSelector(
        ['name' => 'test'],
	    ['env' => 'staging']
    )->find();

// Find pods by field selector
$pods = $client->pods()->setFieldSelector(['metadata.name' => 'test'])->find();

// Find first pod with label selector (same for field selector)
$pod = $client->pods()->setLabelSelector(['name' => 'test'])->first();

```

Authentication Examples
-----------------------

[](#authentication-examples)

### Insecure HTTP

[](#insecure-http)

```
use Teknoo\Kubernetes\Client;
$client = new Client([
	'master' => 'http://master.mycluster.com',
]);
```

### Connecting from a kubeconfig file

[](#connecting-from-a-kubeconfig-file)

```
use Teknoo\Kubernetes\Client;

// Parsing from the file data directly
$client = Client::loadFromKubeConfig('kubeconfig yaml data');

// Parsing from the file path
$client = Client::loadFromKubeConfigFile('~/.kube/config.yml');
```

Extending a library
-------------------

[](#extending-a-library)

### Custom repositories

[](#custom-repositories)

```
use Teknoo\Kubernetes\Client;

$repositories = new RepositoryRegistry();
$repositories['things'] = MyApp\Kubernetes\Repository\ThingRepository::class;

$client = new Client(
    [
        'master' => 'https://master.mycluster.com',
    ],
    $repositories
);

$client->things(); //ThingRepository
```

Usage Examples
--------------

[](#usage-examples)

### Create/Update a Replication Controller

[](#createupdate-a-replication-controller)

The below example uses an array to specify the replication controller's attributes. You can specify the attributes either as an array, JSON encoded string or a YAML encoded string. The second parameter to the model constructor is the data type and defaults to array.

```
use Teknoo\Kubernetes\Model\ReplicationController;

$replicationController = new ReplicationController([
	'metadata' => [
		'name' => 'nginx-test',
		'labels' => [
			'name' => 'nginx-test',
		],
	],
	'spec' => [
		'replicas' => 1,
		'template' => [
			'metadata' => [
				'labels' => [
					'name' => 'nginx-test',
				],
			],
			'spec' => [
				'containers' => [
					[
						'name'  => 'nginx',
						'image' => 'nginx',
						'ports' => [
							[
								'containerPort' => 80,
								'protocol'      => 'TCP',
							],
						],
					],
				],
			],
		],
	],
]);

if ($client->replicationControllers()->exists($replicationController->getMetadata('name'))) {
	$client->replicationControllers()->update($replicationController);
} else {
	$client->replicationControllers()->create($replicationController);
}
$client->replicationControllers()->apply($replicationController);
// or
```

### Delete a Replication Controller

[](#delete-a-replication-controller)

```
$replicationController = $client->replicationControllers()->setLabelSelector(['name' => 'nginx-test'])->first();
$client->replicationControllers()->delete($replicationController);
```

You can also specify options when performing a deletion, eg. to perform [cascading delete](https://kubernetes.io/docs/concepts/workloads/controllers/garbage-collection/#setting-the-cascading-deletion-policy)

```
use Teknoo\Kubernetes\Model\DeleteOptions;

$client->replicationControllers()->delete(
	$replicationController,
	new DeleteOptions(['propagationPolicy' => 'Background'])
);
```

Support this project
--------------------

[](#support-this-project)

This project is free and will remain free. It is fully supported by the activities of the EIRL. If you like it and help me maintain it and evolve it, don't hesitate to support me on [Patreon](https://patreon.com/teknoo_software) or [Github](https://github.com/sponsors/TeknooSoftware).

Thanks :) Richard.

Credits
-------

[](#credits)

EIRL Richard Déloge -  - Lead developer. SASU Teknoo Software -

About Teknoo Software
---------------------

[](#about-teknoo-software)

**Teknoo Software** is a PHP software editor, founded by Richard Déloge, as part of EIRL Richard Déloge. Teknoo Software's goals : Provide to our partners and to the community a set of high quality services or software, sharing knowledge and skills.

License
-------

[](#license)

Kubernetes Client is licensed under the 3-Clause BSD License - see the licenses folder for details.

Installation &amp; Requirements
-------------------------------

[](#installation--requirements)

To install this library with composer, run this command :

```
composer require teknoo/kubernetes-client

```

This library requires :

```
* PHP 8.1+
* A PHP autoloader (Composer is recommended)
* Symfony/Yaml.
* Illuminate/Collections

```

Contribute :)
-------------

[](#contribute-)

You are welcome to contribute to this project. [Fork it on Github](CONTRIBUTING.md)

###  Health Score

66

—

FairBetter than 99% of packages

Maintenance92

Actively maintained with recent releases

Popularity30

Limited adoption so far

Community31

Small or concentrated contributor base

Maturity97

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~39 days

Recently: every ~63 days

Total

96

Last Release

52d ago

Major Versions

0.31.0 → 1.0.02023-01-11

1.7.3 → 2.0.02025-08-28

PHP version history (7 changes)0.0.1PHP &gt;=5.5

0.2.0PHP &gt;=5.4

0.22.0PHP ^7.1|^8.0

0.23.0PHP ^7.4|^8.0

0.30.0PHP ^8.1

1.5.3PHP ^8.2

2.0.0PHP ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/e78f8fa644d9bbbd96dc92b2210e1290250522e56365345442c56eb8d042fb53?d=identicon)[frenchcomp](/maintainers/frenchcomp)

---

Top Contributors

[![frenchcomp](https://avatars.githubusercontent.com/u/1397905?v=4)](https://github.com/frenchcomp "frenchcomp (108 commits)")[![maclof](https://avatars.githubusercontent.com/u/4358583?v=4)](https://github.com/maclof "maclof (106 commits)")[![dhemeier](https://avatars.githubusercontent.com/u/9382851?v=4)](https://github.com/dhemeier "dhemeier (6 commits)")[![leonboot](https://avatars.githubusercontent.com/u/1777675?v=4)](https://github.com/leonboot "leonboot (5 commits)")[![AviMoto](https://avatars.githubusercontent.com/u/1693242?v=4)](https://github.com/AviMoto "AviMoto (5 commits)")[![remicroset](https://avatars.githubusercontent.com/u/180333527?v=4)](https://github.com/remicroset "remicroset (5 commits)")[![jjtroberts](https://avatars.githubusercontent.com/u/18486187?v=4)](https://github.com/jjtroberts "jjtroberts (3 commits)")[![tvass](https://avatars.githubusercontent.com/u/1489618?v=4)](https://github.com/tvass "tvass (3 commits)")[![michaelbutler](https://avatars.githubusercontent.com/u/521702?v=4)](https://github.com/michaelbutler "michaelbutler (3 commits)")[![luceos](https://avatars.githubusercontent.com/u/504687?v=4)](https://github.com/luceos "luceos (2 commits)")[![b-t-927](https://avatars.githubusercontent.com/u/1644078?v=4)](https://github.com/b-t-927 "b-t-927 (2 commits)")[![danijelk](https://avatars.githubusercontent.com/u/580753?v=4)](https://github.com/danijelk "danijelk (2 commits)")[![glennschmidt](https://avatars.githubusercontent.com/u/1758170?v=4)](https://github.com/glennschmidt "glennschmidt (2 commits)")[![mwadon](https://avatars.githubusercontent.com/u/3395702?v=4)](https://github.com/mwadon "mwadon (2 commits)")[![sz-po](https://avatars.githubusercontent.com/u/2962046?v=4)](https://github.com/sz-po "sz-po (2 commits)")[![Jeroeny](https://avatars.githubusercontent.com/u/1517978?v=4)](https://github.com/Jeroeny "Jeroeny (1 commits)")[![lxm](https://avatars.githubusercontent.com/u/1918195?v=4)](https://github.com/lxm "lxm (1 commits)")[![m24te28](https://avatars.githubusercontent.com/u/38154095?v=4)](https://github.com/m24te28 "m24te28 (1 commits)")[![Jeroen-G](https://avatars.githubusercontent.com/u/1116853?v=4)](https://github.com/Jeroen-G "Jeroen-G (1 commits)")[![MaSpeng](https://avatars.githubusercontent.com/u/18685557?v=4)](https://github.com/MaSpeng "MaSpeng (1 commits)")

---

Tags

clustercontainerdockerkubernetescontainerdockerclusterkubernetes

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/teknoo-kubernetes-client/health.svg)

```
[![Health](https://phpackages.com/badges/teknoo-kubernetes-client/health.svg)](https://phpackages.com/packages/teknoo-kubernetes-client)
```

###  Alternatives

[laravel/sail

Docker files for running a basic Laravel application.

1.9k205.7M1.3k](/packages/laravel-sail)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M739](/packages/sylius-sylius)[telnyx/telnyx-php

Official Telnyx PHP SDK — APIs for Voice, SMS, MMS, WhatsApp, Fax, SIP Trunking, Wireless IoT, Call Control, and more. Build global communications on Telnyx's private carrier-grade network.

35789.4k2](/packages/telnyx-telnyx-php)[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[maclof/kubernetes-client

A simple yet elegant client for accessing and controlling a Kubernetes cluster.

237916.9k5](/packages/maclof-kubernetes-client)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
