build: golang.org/x/build/kubernetes Index | Files | Directories

package kubernetes

import "golang.org/x/build/kubernetes"

Package kubernetes contains a minimal client for the Kubernetes API.

Index

Package Files

client.go

Constants

const (
    // APIEndpoint defines the base path for kubernetes API resources.
    APIEndpoint = "/api/v1"
)

type Client

type Client struct {
    // contains filtered or unexported fields
}

Client is a client for the Kubernetes master.

func NewClient

func NewClient(baseURL string, client *http.Client) (*Client, error)

NewClient returns a new Kubernetes client. The provided host is an url (scheme://hostname[:port]) of a Kubernetes master without any path. The provided client is an authorized http.Client used to perform requests to the Kubernetes API master.

func (*Client) AwaitPodNotPending

func (c *Client) AwaitPodNotPending(ctx context.Context, podName, podResourceVersion string) (*api.Pod, error)

awaitPodNotPending will return a pod's status in a podStatusResult when the pod is no longer in the pending state. The podResourceVersion is required to prevent a pod's entire history from being retrieved when the watch is initiated. If there is an error polling for the pod's status, or if ctx.Done is closed, podStatusResult will contain an error.

func (*Client) DeletePod

func (c *Client) DeletePod(ctx context.Context, podName string) error

PodDelete deletes the specified Kubernetes pod.

func (*Client) GetNodes

func (c *Client) GetNodes(ctx context.Context) ([]api.Node, error)

PodNodes returns the list of nodes that comprise the Kubernetes cluster

func (*Client) GetPods

func (c *Client) GetPods(ctx context.Context) ([]api.Pod, error)

GetPods returns all pods in the cluster, regardless of status.

func (*Client) PodLog

func (c *Client) PodLog(ctx context.Context, podName string) (string, error)

PodLog retrieves the container log for the first container in the pod.

func (*Client) PodStatus

func (c *Client) PodStatus(ctx context.Context, podName string) (*api.PodStatus, error)

Retrieve the status of a pod synchronously from the Kube API server.

func (*Client) RunPod

func (c *Client) RunPod(ctx context.Context, pod *api.Pod) (*api.Pod, error)

Run creates a new pod resource in the default pod namespace with the given pod API specification. It returns the pod status once it has entered the Running phase. An error is returned if the pod can not be created, or if ctx.Done is closed.

func (*Client) WatchPod

func (c *Client) WatchPod(ctx context.Context, podName, podResourceVersion string) (<-chan PodStatusResult, error)

WatchPod long-polls the Kubernetes watch API to be notified of changes to the specified pod. Changes are sent on the returned PodStatusResult channel as they are received. The podResourceVersion is required to prevent a pod's entire history from being retrieved when the watch is initiated. The provided context must be canceled or timed out to stop the watch. If any error occurs communicating with the Kubernetes API, the error will be sent on the returned PodStatusResult channel and it will be closed.

type PodStatusResult

type PodStatusResult struct {
    Pod  *api.Pod
    Type string
    Err  error
}

PodStatusResult wraps an api.PodStatus and error.

Directories

PathSynopsis
apiPackage api contains the Kubernetes v1 API types.

Package kubernetes imports 12 packages (graph) and is imported by 2 packages. Updated 6 days ago. Refresh now. Tools for package owners.