travisghansen / kubernetes-client-php

No nonsense PHP Client for the Kubernetes API
Apache License 2.0
33 stars 10 forks source link
api client k8s kubernetes php

Intro

No nonsense PHP client for the Kubernetes API. It supports standard REST calls along with watches for a continuous feed of data. Because no models are used it's usable with CRDs and other functionality/endpoints that may not be built-in.

Example

See sample.php

Watches

Watches can (will) stay connected indefinitely, automatically reconnecting after server-side timeout. The client will keep track of the most recent resourceVersion processed to automatically start where you left off.

Watch callback closures should have the following signature:

$callback = function($event, $watch)..

Receiving the watch allows access to the client (and any other details on the watch) and also provides an ability to stop the watch (break the loop) based off of event logic.

Other notes:

Development

Note on resourceVersion per the doc:

When specified with a watch call, shows changes that occur after that particular version of a resource. Defaults to changes from the beginning of history. When specified for list: - if unset, then the result is returned from remote storage based on quorum-read flag; - if it's 0, then we simply return what we currently have in cache, no guarantee; - if set to non zero, then the result is at least as fresh as given rv.

Note that it's only changes after the version.

TODO

Links

Async