firehed/kube-sdk

SDK for interacting with the Kubernetes API

1.1.0 2018-12-18 20:36 UTC

This package is auto-updated.

Last update: 2024-12-19 11:03:31 UTC


README

Build Status codecov

A simple API wrapper for interacting with the Kubernetes API

Usage

There are two classes to interface with the Kubernetes API:

  • Kubernetes\LocalProxy is for use on your local machine, or anywhere else the kubectl proxy command may be running.
  • Kubernetes\ServiceAccount is for use inside of Kubernetes. It will auto-detect the auth information automatically configured in all Pods. This will respect the serviceAccountName configuration of the pod.

You will probably want to determine which one to load approximately like this:

// ... PSR-11 container definition
    Kubernetes\Api::class => function () {
        if (getenv('KUBERNETES_SERVICE_HOST')) {
            return new Kubernetes\ServiceAccount();
        } else {
            return new Kubernetes\LocalProxy('http://localhost:8001');
        }
    },

The SDK methods are defined in the Kubernetes\Api interface.

Network timeouts default to 500ms on connect and 3000ms for the request.