Download the PHP package keboola/k8s-client without Composer
On this page you can find all versions of the php package keboola/k8s-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package k8s-client
Kubernetes Client
High-level K8S client library. It is based on kubernetes/php-client library, but enhances
it in many ways:
- support connection to multiple clusters
- automatic handling of result type (you don't need to check if the result is what you expect,
Statusor something else) - integrated retries in case of networking problems
- high-level operations like
createmultiple resources at once,waitWhileExiststo wait while given resource exists etc.
Usage
To create a client, first pick a Keboola\K8sClient\ClientFactory\KubernetesApiClientFactory implementation that
matches how you obtain credentials, then pass the KubernetesApiClient it produces to
KubernetesApiClientFacade::create() to build the high-level facade:
StaticKubernetesApiClientFactoryif you have explicit cluster credentialsInClusterKubernetesApiClientFactoryif you run inside a Pod which has access to K8S APIEnvVariablesKubernetesApiClientFactoryif credentials are provided viaK8S_HOST/K8S_TOKEN/K8S_CA_CERT_PATH/K8S_NAMESPACEenv variablesAutoDetectKubernetesApiClientFactoryto try env variables first, falling back to in-cluster credentials
Custom resources (CRDs)
The facade also serves resources it doesn't ship. Implement an API client for your CRD by extending
Keboola\K8sClient\ApiClient\BaseNamespaceApiClient (or BaseClusterApiClient), then register it via the
$extraClients map — keyed by the CRD model class — when building the facade:
Symfony integration
The library ships no bundle, so wire the pieces as services. Minimal setup with auto-detected credentials
(env vars in dev, in-cluster ServiceAccount token in prod) using the shared-client + create() split:
For a single credential source you can skip AutoDetect and point the client at
StaticKubernetesApiClientFactory (explicit values) or InClusterKubernetesApiClientFactory directly.
Development
Prerequisites:
- configured
azandawsCLI tools (runaz loginand configure theKeboola-CI-Platform-Services-Team-AWSAdministratorAccessprofile — the AWS local env uses theci-ps-eu-central-1cluster in theCI-Platform-Services-Teamaccount) - installed
terraform(https://www.terraform.io) andjq(https://stedolan.github.io/jq) to setup local env - installed
dockerto run & develop the library
TL;DR:
Implementing new API
Only few K8S APIs we needed are implement so far. To implement new API, do following:
- create API client wrapper in
Keboola\K8sClient\ApiClient- this is a wrapper around
kubernetes/php-clientAPI class, takes care of handling results
- this is a wrapper around
- add the wrapper to
KubernetesApiClientFacade- inject the
kubernetes/php-clientclient through constructor - add support for the new resource to methods signatures
- inject the
- update
KubernetesApiClientFacade::create()to provide the new API class to the facade
License
MIT licensed, see LICENSE file.