Skip to content

brianlmoon/kubernetes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kubernetes Objects

This library builds, imports, and exports Kubernetes objects. The classes are all built using the Swagger files in the kubernetes/kubernetes repository.

The original purpose for building this library was for writing applications that interact with Kubernetes objects. It is not the intention that this library be used to build configuration management repositories. The PHP code for managing objects would likely be more verbose and complex than simply writing the needed YAML.

Version Compatibility

The versions of this library follow the major/minor release versions of the official Kubernetes releases. Only versions from 1.21 forward are supported.

Example

$configmap = \Moonspot\Kubernetes\Kubernetes::new('ConfigMap');

$configmap->metadata->name = 'MyConfigMap';
$configmap->metadata->labels = [
    "app-name" => 'MyApp'
];
$configmap->data = [
    'config.ini' => "some_setting = 1\nsome_setting = 2\n"
];

echo $configmap->toYaml();

Result:

---
apiVersion: v1
data:
  config.ini: |
    some_setting = 1
    some_setting = 2
kind: ConfigMap
metadata:
  labels:
    app-name: MyApp
  name: MyConfigMap
...

Importing

The factory method of the Kubernetes class will auto-detect the kind of object and create it.

$configmap = \Moonspot\Kubernetes\Kubernetes::factory(file_get_contents('./configmap.yaml'));

echo $configmap->metadata->name . "\n";

Result:

MyConfigMap

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published