PHPackages                             devstub/kubernetes-api-php-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. [HTTP &amp; Networking](/categories/http)
4. /
5. devstub/kubernetes-api-php-client

ActiveLibrary[HTTP &amp; Networking](/categories/http)

devstub/kubernetes-api-php-client
=================================

PHP client for the kubernetes api

v0.1.1(11y ago)175810[1 issues](https://github.com/devstub/kubernetes-api-php-client/issues)Apache-2.0PHPPHP &gt;=5.4.0

Since Nov 17Pushed 6y ago2 watchersCompare

[ Source](https://github.com/devstub/kubernetes-api-php-client)[ Packagist](https://packagist.org/packages/devstub/kubernetes-api-php-client)[ Docs](https://github.com/devstub/kubernetes-api-php-client)[ RSS](/packages/devstub-kubernetes-api-php-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

> This project is not being maintained, you should use something else.

kubernetesAPI-PHP-client
========================

[](#kubernetesapi-php-client)

PHP client library for the [Kubernetes](https://github.com/GoogleCloudPlatform/Kubernetes) API

\*\* Current Version : v0.1.0 \*\*

### Contents

[](#contents)

- [Usage](#usage)
    - [Basic Usage](#basic_usage)
    - [How to use the library](#howto)
    - [Configuration](#config)
    - [API Endpoints](#endpoints)
    - [Response](#response)
- [Installation](#installation)
    - [Requirements](#requirements)
    - [Install with composer](#composer)
- [To Do](#todo)
- [About](#about)

Usage
--------------------------------------

[](#usage)

### Basic Usage

[](#basic-usage)

- Install the client and all of its required libraries ([instructions](#installation))
- Register an PSR-0 compatible autoloader
- Create `\DevStub\KubernetesAPIClient\Client()` object instance
- Setup all of the configuration options
- Send a request

```
require '../vendor/autoload.php';
$client = new \DevStub\KubernetesAPIClient\Client();
$client->config()
    ->setAPINodeUrl("https://kubernetesServerAPI.com/api/") //
    ->setAPIVersion('v1beta1')
    ->setAuthType(\DevStub\KubernetesAPIClient\Config::AUTH_TYPE_HTTP_BASIC) // if we are using http authentication
    ->setAuthOptions(['username' => 'username', 'password' => 'password']); // we set the auth credentials

$response = null;

// here we create a new service by passing a json text
// we can also create the request structure with objects and method chaining .. read below for instructions
$client->services()->create(
    '{
  "id": "framework-dev",
  "kind": "Service",
  "apiVersion": "v1beta1",
  "port": 80,
  "containerPort": 80,
  "selector": {
    "name": "app-instance"
  }
}
',$response
);

$statusObj = $response->getContentObject();
// ... process the response here...
```

### How to use the library

[](#how-to-use-the-library)

For most of the functionality Client supports 3 ways of setting properties and options. *Not all 3 ways are always supported yet so check the each object and it's method for it support*

1. Explicitly instantiating objects and passing them as properties

    ```
    $pod  = new \DevStub\KubernetesAPIClient\Entity\v1beta1\Pod();
    $pod->setId("app-instance-dev-test".time());
    $pod->setKind("Pod");
    $pod->setApiVersion("v1beta1");

    $desiredState = new \DevStub\KubernetesAPIClient\Entity\v1beta1\PodState();
    // we prepare the desired state object
    // ...
    // then we pass it to the pod
    $pod->setDesiredState($desiredState);
    // ...
    // ... we continue the same process for all other options
    // ...
    ```
2. Implicit creation of object by not setting the param

    ```
    $client->pods()->create(null,$response)
    	->setId("app-instance-dev-test".time())
    	->setKind("Pod")
    	->setApiVersion("v1beta1")
    	->setDesiredState() // new object is automatically instantiated here
    		->setManifest() //new object is automatically instantiated here
    			->setVolumes() new object is automatically instantiated here
    				->append() // add array item
    					->setName("data") // set property name
    					->setSource() new object is automatically instantiated here
    						->setEmptyDir()->end() new object is automatically instantiated here and closed
    						->end() // we close the setSource
    					->end() //we close the append
    				->end() // we close the setVolumes
    			->setVersion("v1beta1")
    			->setId("app-instance-dev-test".time())
    			->setContainers()
    				->append()
    					->setName("framework")
    					->setImage("registry.domain/user/dev-framework:v0.1.304")
    					->setImagePullPolicy("PullIfNotPresent")
    					->setLifecycle()
    						->setPostStart()
    							->setExec()
    								->setCommand()
    									->append("/opt/conf/poststart.sh")
    									->end()
    								->end()
    							->end()
    						->end()
    					->setVolumeMounts()
    						->append()
    							->setName("data")
    							->setMountPath("/data")
    							->end()
    						->end()
    					->setPorts()
    						->append()
    							->setContainerPort(80)
    							->end()
    						->end()
    					->end()
    				->end()
    			->end()
    		->end()
    	->end();
    ```
3. Passing a json string as an argument

    In below example we are just passing the full service request as json

    ```
    $response = '';

    $client->services()->create(
    	'{
      "id": "framework-dev",
      "kind": "Service",
      "apiVersion": "v1beta1",
      "port": 80,
      "containerPort": 80,
      "selector": {
    	"name": "app-instance"
      }
    }
    ',$response
    );
    var_dump($response);
    ```

### Configuration

[](#configuration)

Before any requests can be made with the client you will need to setup some configuration options.

Following options are available

**setSslVerify($value)***$value = TRUE | FALSE - defaults: \[TRUE\]*Set it to false when you don't want to verify the SSL cert. (Useful for development)

**setAPINodeUrl($value)**\*$value = String \* Set it to the full url of the Kubernetes API server. Note: don't include the version path portion. It is added by the client.

```
->setAPINodeUrl("https://kubernetesServerAPI.com/api/") //
```

**setAPIVersion($value)***$value = String - defaults: \[v1beta1\]*Set the version of the API Schema

```
->setApiVersion("v1beta1");
```

**setAuthType($value)***$value = String - defaults: \[Config::AUTH\_TYPE\_HTTP\_BASIC\]**Options: Config::AUTH\_TYPE\_HTTP\_BASIC, Config::AUTH\_TYPE\_NONE*At this time only one type of auth type is supported

```
->setAuthType(\DevStub\KubernetesAPIClient\Config::AUTH_TYPE_HTTP_BASIC)
```

**setAuthOptions($value)**\*$value = Array \* \*Options: username, password Set the array which provides auth data based on the authType Selected

```
->setAuthOptions(['username' => 'username', 'password' => 'password']); // we set the auth credentials
```

**setConnectionAdapter($value)***$value = String - defaults: \[Config::CONNECTION\_ADAPTER\_GUZZLE\]*\*Options: CONNECTION\_ADAPTER\_GUZZLE Sets the type of rest http adapter to use, currently only guzzle is supported.

```
->setConnectionAdapter(\DevStub\KubernetesAPIClient\Config::CONNECTION_ADAPTER_GUZZLE)
```

*Configuration setting Example:*

```
$clientConfig = new \DevStub\KubernetesAPIClient\Config();

$clientConfig->setAPINodeUrl("https://162.242.254.164/api/");
$clientConfig->setAPIVersion('v1beta1');
$client->config($clientConfig)

// or you can use method chaining on config

$clientConfig->setAPINodeUrl("https://162.242.254.164/api/")
			 ->setAPIVersion('v1beta1');
$client->config($clientConfig)
```

### API Endpoints

[](#api-endpoints)

To make requests to the API endpoints you call endpoint methods on the client object, which returns an endpoint object on which you can call: create, update, delete and get methods.

```
$client->services()->create($serviceObject);
```

Available endpoint methods on the client object:

- pods()
- replicationControllers()
- endpoints()
- services()
- minions()
- events()
- bindings()

### Response

[](#response)

All of the requests will return an instance AdapterResponse class. With it you can check the status of the response:

```
$response = $client->pods()->get();
if ($response->getStatusCode() == 500) { // we check against http status code 500
    throw \Exception("error retrieving the response");
}
```

or retrieve the response content as JSON :

```
$response = $client->pods()->get();
$responseContent = $response->getContentRaw(); // this returns a json string
var_dump($responseContent);
```

or as nested objects :

```
$response = $client->pods()->get();
/* @var \DevStub\KubernetesAPIClient\Entity\v1beta1\PodList $podList */
$podList = $response->getContentObject();
/* @var \DevStub\KubernetesAPIClient\Entity\v1beta1\Pod $pod */
foreach ($podList->getItems() as $pod) {
	print "\n".$pod->getId();
}
```

For a full list of available kubernetes entities check the `\DevStub\KubernetesAPIClient\Entity` namespace

Installation
----------------------------------------------------

[](#installation)

### Requirements

[](#requirements)

- [Guzzle Http client](https://github.com/guzzle/guzzle)
- [JsonMapper](https://github.com/netresearch/jsonmapper)

Easies way to retrieve all of the dependencies is by using composer

### Install with composer

[](#install-with-composer)

The recommended way is to use [Composer](http://getcomposer.org) to install the kubernetes PHP API Client

```
# Install Composer
curl -sS https://getcomposer.org/installer | php
```

Next run composer to install the latest version of the kubernetes PHP API Client:

```
composer require devstub/kubernetes-api-php-client
```

And don't forget to require the autoloader in your project:

```
require 'vendor/autoload.php';
```

Alternatively you can also specify the dependency in your exisitng composer.json

```
 {
   "require": {
      "devstub/kubernetes-api-php-client": "*"
   }
}
```

To do
-------------------------------------

[](#to-do)

- Add unit tests
- Support other API Versions
- Support additional REST adapters
- Add way to poll/watch the endpoints for changes

About
--------------------------------------

[](#about)

### License

[](#license)

Kubernetes PHP API Client is licensed under [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0)

### Author

[](#author)

Faruk Brbovic, [DevStub.com](http://www.devstub.com)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.1% of commits — single point of failure

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 ~0 days

Total

2

Last Release

4200d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5519f5b8fd9fc554f3f378b5ad316e9cf72b99fc5a8a45252619a634d53b688b?d=identicon)[devstub](/maintainers/devstub)

---

Top Contributors

[![darkgaro](https://avatars.githubusercontent.com/u/3021484?v=4)](https://github.com/darkgaro "darkgaro (16 commits)")[![fbrbovic](https://avatars.githubusercontent.com/u/10214215?v=4)](https://github.com/fbrbovic "fbrbovic (1 commits)")

---

Tags

httpapiclientrestfulkubernetes

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/devstub-kubernetes-api-php-client/health.svg)

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

###  Alternatives

[printu/labelary

PHP API for Labelary.com

34616.9k](/packages/printu-labelary)[printu/customerio

PHP API for Customer.io

241.1M2](/packages/printu-customerio)[e-moe/guzzle6-bundle

Integrates Guzzle 6 into your Symfony application

11259.2k](/packages/e-moe-guzzle6-bundle)[meteocontrol/vcom-api-client

HTTP Client for meteocontrol's VCOM API - The VCOM API enables you to directly access your data on the meteocontrol platform.

175.7k1](/packages/meteocontrol-vcom-api-client)[rap2hpoutre/jacky

Opinionated REST JSON HTTP API client for laravel

174.4k](/packages/rap2hpoutre-jacky)[laragear/api-manager

Manage multiple REST servers to make requests in few lines and fluently.

161.8k](/packages/laragear-api-manager)

PHPackages © 2026

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