client

package
v0.4.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2015 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Overview

Package client contains the implementation of the client side communication with the Kubernetes master. The Client class provides methods for reading, creating, updating, and deleting pods, replication controllers, services, and minions.

Most consumers should use the Config object to create a Client:

config := &client.Config{
  Host:     "http://localhost:8080",
  Username: "test",
  Password: "password",
}
client, err := client.New(&config)
if err != nil {
  // handle error
}
client.Pods(ns).List()

More advanced consumers may wish to provide their own transport via a http.RoundTripper:

config := &client.Config{
  Host:      "https://localhost:8080",
  Transport: oauthclient.Transport(),
}
client, err := client.New(&config)

The RESTClient type implements the Kubernetes API conventions (see `docs/api-conventions.md`) for a given API path and is intended for use by consumers implementing their own Kubernetes compatible APIs.

Index

Constants

This section is empty.

Variables

View Source
var ErrPodInfoNotAvailable = errors.New("no pod info available")

ErrPodInfoNotAvailable may be returned when the requested pod info is not available.

Functions

func BindClientConfigFlags

func BindClientConfigFlags(flags FlagSet, config *Config)

BindClientConfigFlags registers a standard set of CLI flags for connecting to a Kubernetes API server. TODO this method is superceded by pkg/client/clientcmd/client_builder.go

func BindKubeletClientConfigFlags added in v0.2.1

func BindKubeletClientConfigFlags(flags FlagSet, config *KubeletConfig)

func ControllerHasDesiredReplicas added in v0.2.1

func ControllerHasDesiredReplicas(c Interface, controller *api.ReplicationController) wait.ConditionFunc

ControllerHasDesiredReplicas returns a condition that will be true iff the desired replica count for a controller's ReplicaSelector equals the Replicas count.

func DefaultKubernetesUserAgent added in v0.3.1

func DefaultKubernetesUserAgent() string

DefaultKubernetesUserAgent returns the default user agent that clients can use.

func DefaultServerURL

func DefaultServerURL(host, prefix, version string, defaultTLS bool) (*url.URL, error)

DefaultServerURL converts a host, host:port, or URL string to the default base server API path to use with a Client at a given API version following the standard conventions for a Kubernetes API.

func HTTPWrappersForConfig added in v0.3.1

func HTTPWrappersForConfig(config *Config, rt http.RoundTripper) (http.RoundTripper, error)

HTTPWrappersForConfig wraps a round tripper with any relevant layered behavior from the config. Exposed to allow more clients that need HTTP-like behavior but then must hijack the underlying connection (like WebSocket or HTTP2 clients). Pure HTTP clients should use the higher level TransportFor or RESTClientFor methods.

func IsConfigTransportTLS added in v0.2.1

func IsConfigTransportTLS(config Config) bool

IsConfigTransportTLS returns true iff the provided config will result in a protected connection to the server when it is passed to client.New() or client.RESTClientFor(). Use to determine when to send credentials over the wire.

Note: the Insecure flag is ignored when testing for this value, so MITM attacks are still possible.

func IsTimeout added in v0.2.1

func IsTimeout(err error) bool

IsTimeout tests if this is a timeout error in the underlying transport. This is unbelievably ugly. See: http://stackoverflow.com/questions/23494950/specifically-check-for-timeout-error for details

func IsUnexpectedStatusError added in v0.4.2

func IsUnexpectedStatusError(err error) bool

IsUnexpectedStatusError determines if err is due to an unexpected status from the server.

func LoadTLSFiles added in v0.3.2

func LoadTLSFiles(config *Config) error

LoadTLSFiles copies the data from the CertFile, KeyFile, and CAFile fields into the CertData, KeyData, and CAFile fields, or returns an error. If no error is returned, all three fields are either populated or were empty to start.

func MatchesServerVersion added in v0.2.1

func MatchesServerVersion(c *Config) error

func NewBasicAuthRoundTripper

func NewBasicAuthRoundTripper(username, password string, rt http.RoundTripper) http.RoundTripper

func NewBearerAuthRoundTripper

func NewBearerAuthRoundTripper(bearer string, rt http.RoundTripper) http.RoundTripper

func NewClientCertTLSConfig added in v0.3.1

func NewClientCertTLSConfig(certData, keyData, caData []byte) (*tls.Config, error)

func NewTLSConfig added in v0.3.1

func NewTLSConfig(caData []byte) (*tls.Config, error)

func NewUnsafeTLSConfig added in v0.3.1

func NewUnsafeTLSConfig() *tls.Config

func NewUserAgentRoundTripper added in v0.3.1

func NewUserAgentRoundTripper(agent string, rt http.RoundTripper) http.RoundTripper

func SetKubernetesDefaults added in v0.2.1

func SetKubernetesDefaults(config *Config) error

SetKubernetesDefaults sets default values on the provided client config for accessing the Kubernetes API or returns an error if any of the defaults are impossible or invalid.

func TLSConfigFor added in v0.3.1

func TLSConfigFor(config *Config) (*tls.Config, error)

TLSConfigFor returns a tls.Config that will provide the transport level security defined by the provided Config. Will return nil if no transport level security is requested.

func TransportFor

func TransportFor(config *Config) (http.RoundTripper, error)

TransportFor returns an http.RoundTripper that will provide the authentication or transport level security defined by the provided Config. Will return the default http.DefaultTransport if no special case behavior is needed.

Types

type APIStatus

type APIStatus interface {
	Status() api.Status
}

APIStatus is exposed by errors that can be converted to an api.Status object for finer grained details.

type Client

type Client struct {
	*RESTClient
}

Client is the implementation of a Kubernetes client.

func New

func New(c *Config) (*Client, error)

New creates a Kubernetes client for the given config. This client works with pods, replication controllers and services. It allows operations such as list, get, update and delete on these objects. An error is returned if the provided configuration is not valid.

func NewOrDie

func NewOrDie(c *Config) *Client

NewOrDie creates a Kubernetes client and panics if the provided API version is not recognized.

func (*Client) Endpoints added in v0.2.1

func (c *Client) Endpoints(namespace string) EndpointsInterface

func (*Client) Events added in v0.2.1

func (c *Client) Events(namespace string) EventInterface

func (*Client) LimitRanges added in v0.2.2

func (c *Client) LimitRanges(namespace string) LimitRangeInterface

func (*Client) Namespaces added in v0.3.2

func (c *Client) Namespaces() NamespaceInterface

func (*Client) Nodes added in v0.2.1

func (c *Client) Nodes() NodeInterface

func (*Client) Pods added in v0.2.1

func (c *Client) Pods(namespace string) PodInterface

func (*Client) ReplicationControllers added in v0.2.1

func (c *Client) ReplicationControllers(namespace string) ReplicationControllerInterface

func (*Client) ResourceQuotas added in v0.2.2

func (c *Client) ResourceQuotas(namespace string) ResourceQuotaInterface

func (*Client) Secrets added in v0.4.1

func (c *Client) Secrets(namespace string) SecretsInterface

func (*Client) ServerAPIVersions added in v0.2.1

func (c *Client) ServerAPIVersions() (*api.APIVersions, error)

ServerAPIVersions retrieves and parses the list of API versions the server supports.

func (*Client) ServerVersion

func (c *Client) ServerVersion() (*version.Info, error)

ServerVersion retrieves and parses the server's version.

func (*Client) Services added in v0.2.1

func (c *Client) Services(namespace string) ServiceInterface

type Config

type Config struct {
	// Host must be a host string, a host:port pair, or a URL to the base of the API.
	Host string
	// Prefix is the sub path of the server. If not specified, the client will set
	// a default value.  Use "/" to indicate the server root should be used
	Prefix string
	// Version is the API version to talk to. Must be provided when initializing
	// a RESTClient directly. When initializing a Client, will be set with the default
	// code version.
	Version string
	// LegacyBehavior defines whether the RESTClient should follow conventions that
	// existed prior to v1beta3 in Kubernetes - namely, namespace (if specified)
	// not being part of the path, and resource names allowing mixed case. Set to
	// true when using Kubernetes v1beta1 or v1beta2.
	LegacyBehavior bool
	// Codec specifies the encoding and decoding behavior for runtime.Objects passed
	// to a RESTClient or Client. Required when initializing a RESTClient, optional
	// when initializing a Client.
	Codec runtime.Codec

	// Server requires Basic authentication
	Username string
	Password string

	// Server requires Bearer authentication. This client will not attempt to use
	// refresh tokens for an OAuth2 flow.
	// TODO: demonstrate an OAuth2 compatible client.
	BearerToken string

	// TLSClientConfig contains settings to enable transport layer security
	TLSClientConfig

	// Server should be accessed without verifying the TLS
	// certificate. For testing only.
	Insecure bool

	// UserAgent is an optional field that specifies the caller of this request.
	UserAgent string

	// Transport may be used for custom HTTP behavior. This attribute may not
	// be specified with the TLS client certificate options.
	Transport http.RoundTripper
}

Config holds the common attributes that can be passed to a Kubernetes client on initialization.

type ConnectionInfoGetter added in v0.4.3

type ConnectionInfoGetter interface {
	GetConnectionInfo(host string) (scheme string, port uint, transport http.RoundTripper, error error)
}

type ContainerInfoGetter

type ContainerInfoGetter interface {
	// GetContainerInfo returns information about a container.
	GetContainerInfo(host, podID, containerID string, req *cadvisorApi.ContainerInfoRequest) (*cadvisorApi.ContainerInfo, error)
	// GetRootInfo returns information about the root container on a machine.
	GetRootInfo(host string, req *cadvisorApi.ContainerInfoRequest) (*cadvisorApi.ContainerInfo, error)
	// GetMachineInfo returns the machine's information like number of cores, memory capacity.
	GetMachineInfo(host string) (*cadvisorApi.MachineInfo, error)
}

type EndpointsInterface

type EndpointsInterface interface {
	Create(endpoints *api.Endpoints) (*api.Endpoints, error)
	List(selector labels.Selector) (*api.EndpointsList, error)
	Get(name string) (*api.Endpoints, error)
	Update(endpoints *api.Endpoints) (*api.Endpoints, error)
	Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
}

EndpointsInterface has methods to work with Endpoints resources

type EndpointsNamespacer added in v0.2.1

type EndpointsNamespacer interface {
	Endpoints(namespace string) EndpointsInterface
}

EndpointsNamespacer has methods to work with Endpoints resources in a namespace

type EventInterface

type EventInterface interface {
	Create(event *api.Event) (*api.Event, error)
	Update(event *api.Event) (*api.Event, error)
	List(label labels.Selector, field fields.Selector) (*api.EventList, error)
	Get(name string) (*api.Event, error)
	Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
	// Search finds events about the specified object
	Search(objOrRef runtime.Object) (*api.EventList, error)
	Delete(name string) error
	// Returns the appropriate field selector based on the API version being used to communicate with the server.
	// The returned field selector can be used with List and Watch to filter desired events.
	GetFieldSelector(involvedObjectName, involvedObjectNamespace, involvedObjectKind, involvedObjectUID *string) fields.Selector
}

EventInterface has methods to work with Event resources

type EventNamespacer added in v0.2.1

type EventNamespacer interface {
	Events(namespace string) EventInterface
}

EventNamespacer can return an EventInterface for the given namespace.

type Fake

type Fake struct {
	Actions             []FakeAction
	PodsList            api.PodList
	CtrlList            api.ReplicationControllerList
	Ctrl                api.ReplicationController
	ServiceList         api.ServiceList
	EndpointsList       api.EndpointsList
	MinionsList         api.NodeList
	EventsList          api.EventList
	LimitRangesList     api.LimitRangeList
	ResourceQuotaStatus api.ResourceQuota
	ResourceQuotasList  api.ResourceQuotaList
	NamespacesList      api.NamespaceList
	SecretList          api.SecretList
	Secret              api.Secret
	Err                 error
	Watch               watch.Interface
}

Fake implements Interface. Meant to be embedded into a struct to get a default implementation. This makes faking out just the method you want to test easier.

func (*Fake) Endpoints added in v0.2.1

func (c *Fake) Endpoints(namespace string) EndpointsInterface

func (*Fake) Events

func (c *Fake) Events(namespace string) EventInterface

func (*Fake) LimitRanges added in v0.2.2

func (c *Fake) LimitRanges(namespace string) LimitRangeInterface

func (*Fake) Namespaces added in v0.3.2

func (c *Fake) Namespaces() NamespaceInterface

func (*Fake) Nodes added in v0.2.1

func (c *Fake) Nodes() NodeInterface

func (*Fake) Pods

func (c *Fake) Pods(namespace string) PodInterface

func (*Fake) ReplicationControllers added in v0.2.1

func (c *Fake) ReplicationControllers(namespace string) ReplicationControllerInterface

func (*Fake) ResourceQuotas added in v0.2.2

func (c *Fake) ResourceQuotas(namespace string) ResourceQuotaInterface

func (*Fake) Secrets added in v0.4.1

func (c *Fake) Secrets(namespace string) SecretsInterface

func (*Fake) ServerAPIVersions added in v0.2.1

func (c *Fake) ServerAPIVersions() (*api.APIVersions, error)

func (*Fake) ServerVersion

func (c *Fake) ServerVersion() (*version.Info, error)

func (*Fake) Services added in v0.2.1

func (c *Fake) Services(namespace string) ServiceInterface

type FakeAction

type FakeAction struct {
	Action string
	Value  interface{}
}

type FakeEndpoints added in v0.2.1

type FakeEndpoints struct {
	Fake      *Fake
	Namespace string
}

FakeEndpoints implements EndpointInterface. Meant to be embedded into a struct to get a default implementation. This makes faking out just the method you want to test easier.

func (*FakeEndpoints) Create added in v0.2.1

func (c *FakeEndpoints) Create(endpoints *api.Endpoints) (*api.Endpoints, error)

func (*FakeEndpoints) Get added in v0.2.1

func (c *FakeEndpoints) Get(name string) (*api.Endpoints, error)

func (*FakeEndpoints) List added in v0.2.1

func (c *FakeEndpoints) List(selector labels.Selector) (*api.EndpointsList, error)

func (*FakeEndpoints) Update added in v0.2.1

func (c *FakeEndpoints) Update(endpoints *api.Endpoints) (*api.Endpoints, error)

func (*FakeEndpoints) Watch added in v0.2.1

func (c *FakeEndpoints) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)

type FakeEvents added in v0.2.1

type FakeEvents struct {
	Fake *Fake
}

FakeEvents implements EventInterface. Meant to be embedded into a struct to get a default implementation. This makes faking out just the method you want to test easier.

func (*FakeEvents) Create added in v0.2.1

func (c *FakeEvents) Create(event *api.Event) (*api.Event, error)

Create makes a new event. Returns the copy of the event the server returns, or an error.

func (*FakeEvents) Delete added in v0.4.2

func (c *FakeEvents) Delete(name string) error

func (*FakeEvents) Get added in v0.2.1

func (c *FakeEvents) Get(id string) (*api.Event, error)

Get returns the given event, or an error.

func (*FakeEvents) GetFieldSelector added in v0.4.3

func (c *FakeEvents) GetFieldSelector(involvedObjectName, involvedObjectNamespace, involvedObjectKind, involvedObjectUID *string) fields.Selector

func (*FakeEvents) List added in v0.2.1

func (c *FakeEvents) List(label labels.Selector, field fields.Selector) (*api.EventList, error)

List returns a list of events matching the selectors.

func (*FakeEvents) Search added in v0.2.1

func (c *FakeEvents) Search(objOrRef runtime.Object) (*api.EventList, error)

Search returns a list of events matching the specified object.

func (*FakeEvents) Update added in v0.3.2

func (c *FakeEvents) Update(event *api.Event) (*api.Event, error)

Update replaces an existing event. Returns the copy of the event the server returns, or an error.

func (*FakeEvents) Watch added in v0.2.1

func (c *FakeEvents) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)

Watch starts watching for events matching the given selectors.

type FakeKubeletClient added in v0.2.1

type FakeKubeletClient struct{}

FakeKubeletClient is a fake implementation of KubeletClient which returns an error when called. It is useful to pass to the master in a test configuration with no kubelets.

func (FakeKubeletClient) GetConnectionInfo added in v0.4.3

func (c FakeKubeletClient) GetConnectionInfo(host string) (string, uint, http.RoundTripper, error)

func (FakeKubeletClient) GetNodeInfo added in v0.4.2

func (c FakeKubeletClient) GetNodeInfo(host string) (api.NodeInfo, error)

GetNodeInfo is a fake implementation of PodInfoGetter.GetNodeInfo

func (FakeKubeletClient) GetPodStatus added in v0.2.2

func (c FakeKubeletClient) GetPodStatus(host, podNamespace string, podID string) (api.PodStatusResult, error)

GetPodInfo is a fake implementation of PodInfoGetter.GetPodInfo.

func (FakeKubeletClient) HealthCheck added in v0.2.1

func (c FakeKubeletClient) HealthCheck(host string) (probe.Result, error)

type FakeLimitRanges added in v0.2.2

type FakeLimitRanges struct {
	Fake      *Fake
	Namespace string
}

FakeLimitRanges implements PodsInterface. Meant to be embedded into a struct to get a default implementation. This makes faking out just the methods you want to test easier.

func (*FakeLimitRanges) Create added in v0.2.2

func (c *FakeLimitRanges) Create(limitRange *api.LimitRange) (*api.LimitRange, error)

func (*FakeLimitRanges) Delete added in v0.2.2

func (c *FakeLimitRanges) Delete(name string) error

func (*FakeLimitRanges) Get added in v0.2.2

func (c *FakeLimitRanges) Get(name string) (*api.LimitRange, error)

func (*FakeLimitRanges) List added in v0.2.2

func (c *FakeLimitRanges) List(selector labels.Selector) (*api.LimitRangeList, error)

func (*FakeLimitRanges) Update added in v0.2.2

func (c *FakeLimitRanges) Update(limitRange *api.LimitRange) (*api.LimitRange, error)

func (*FakeLimitRanges) Watch added in v0.4.2

func (c *FakeLimitRanges) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)

type FakeNamespaces added in v0.3.2

type FakeNamespaces struct {
	Fake *Fake
}

FakeNamespaces implements NamespacesInterface. Meant to be embedded into a struct to get a default implementation. This makes faking out just the methods you want to test easier.

func (*FakeNamespaces) Create added in v0.3.2

func (c *FakeNamespaces) Create(namespace *api.Namespace) (*api.Namespace, error)

func (*FakeNamespaces) Delete added in v0.3.2

func (c *FakeNamespaces) Delete(name string) error

func (*FakeNamespaces) Finalize added in v0.4.3

func (c *FakeNamespaces) Finalize(namespace *api.Namespace) (*api.Namespace, error)

func (*FakeNamespaces) Get added in v0.3.2

func (c *FakeNamespaces) Get(name string) (*api.Namespace, error)

func (*FakeNamespaces) List added in v0.3.2

func (c *FakeNamespaces) List(labels labels.Selector, field fields.Selector) (*api.NamespaceList, error)

func (*FakeNamespaces) Status added in v0.4.3

func (c *FakeNamespaces) Status(namespace *api.Namespace) (*api.Namespace, error)

func (*FakeNamespaces) Update added in v0.3.2

func (c *FakeNamespaces) Update(namespace *api.Namespace) (*api.Namespace, error)

func (*FakeNamespaces) Watch added in v0.3.2

func (c *FakeNamespaces) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)

type FakeNodes added in v0.2.1

type FakeNodes struct {
	Fake *Fake
}

FakeNodes implements MinionInterface. Meant to be embedded into a struct to get a default implementation. This makes faking out just the method you want to test easier.

func (*FakeNodes) Create added in v0.2.1

func (c *FakeNodes) Create(minion *api.Node) (*api.Node, error)

func (*FakeNodes) Delete added in v0.2.1

func (c *FakeNodes) Delete(id string) error

func (*FakeNodes) Get added in v0.2.1

func (c *FakeNodes) Get(name string) (*api.Node, error)

func (*FakeNodes) List added in v0.2.1

func (c *FakeNodes) List() (*api.NodeList, error)

func (*FakeNodes) Update added in v0.2.2

func (c *FakeNodes) Update(minion *api.Node) (*api.Node, error)

func (*FakeNodes) Watch added in v0.4.3

func (c *FakeNodes) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)

type FakePods added in v0.2.1

type FakePods struct {
	Fake      *Fake
	Namespace string
}

FakePods implements PodsInterface. Meant to be embedded into a struct to get a default implementation. This makes faking out just the methods you want to test easier.

func (*FakePods) Bind added in v0.4.2

func (c *FakePods) Bind(bind *api.Binding) error

func (*FakePods) Create added in v0.2.1

func (c *FakePods) Create(pod *api.Pod) (*api.Pod, error)

func (*FakePods) Delete added in v0.2.1

func (c *FakePods) Delete(name string) error

func (*FakePods) Get added in v0.2.1

func (c *FakePods) Get(name string) (*api.Pod, error)

func (*FakePods) List added in v0.2.1

func (c *FakePods) List(selector labels.Selector) (*api.PodList, error)

func (*FakePods) Update added in v0.2.1

func (c *FakePods) Update(pod *api.Pod) (*api.Pod, error)

func (*FakePods) UpdateStatus added in v0.4.2

func (c *FakePods) UpdateStatus(pod *api.Pod) (*api.Pod, error)

func (*FakePods) Watch added in v0.4.2

func (c *FakePods) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)

type FakeRESTClient added in v0.2.1

type FakeRESTClient struct {
	Client HTTPClient
	Codec  runtime.Codec
	Legacy bool
	Req    *http.Request
	Resp   *http.Response
	Err    error
}

FakeRESTClient provides a fake RESTClient interface.

func (*FakeRESTClient) Delete added in v0.2.1

func (c *FakeRESTClient) Delete() *Request

func (*FakeRESTClient) Do added in v0.2.1

func (c *FakeRESTClient) Do(req *http.Request) (*http.Response, error)

func (*FakeRESTClient) Get added in v0.2.1

func (c *FakeRESTClient) Get() *Request

func (*FakeRESTClient) Post added in v0.2.1

func (c *FakeRESTClient) Post() *Request

func (*FakeRESTClient) Put added in v0.2.1

func (c *FakeRESTClient) Put() *Request

type FakeReplicationControllers added in v0.2.1

type FakeReplicationControllers struct {
	Fake      *Fake
	Namespace string
}

FakeReplicationControllers implements ReplicationControllerInterface. Meant to be embedded into a struct to get a default implementation. This makes faking out just the method you want to test easier.

func (*FakeReplicationControllers) Create added in v0.2.1

func (*FakeReplicationControllers) Delete added in v0.2.1

func (c *FakeReplicationControllers) Delete(controller string) error

func (*FakeReplicationControllers) Get added in v0.2.1

func (*FakeReplicationControllers) List added in v0.2.1

func (*FakeReplicationControllers) Update added in v0.2.1

func (*FakeReplicationControllers) Watch added in v0.2.1

func (c *FakeReplicationControllers) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)

type FakeResourceQuotas added in v0.2.2

type FakeResourceQuotas struct {
	Fake      *Fake
	Namespace string
}

FakeResourceQuotas implements ResourceQuotaInterface. Meant to be embedded into a struct to get a default implementation. This makes faking out just the methods you want to test easier.

func (*FakeResourceQuotas) Create added in v0.2.2

func (c *FakeResourceQuotas) Create(resourceQuota *api.ResourceQuota) (*api.ResourceQuota, error)

func (*FakeResourceQuotas) Delete added in v0.2.2

func (c *FakeResourceQuotas) Delete(name string) error

func (*FakeResourceQuotas) Get added in v0.2.2

func (c *FakeResourceQuotas) Get(name string) (*api.ResourceQuota, error)

func (*FakeResourceQuotas) List added in v0.2.2

func (*FakeResourceQuotas) Update added in v0.2.2

func (c *FakeResourceQuotas) Update(resourceQuota *api.ResourceQuota) (*api.ResourceQuota, error)

func (*FakeResourceQuotas) UpdateStatus added in v0.4.3

func (c *FakeResourceQuotas) UpdateStatus(resourceQuota *api.ResourceQuota) (*api.ResourceQuota, error)

func (*FakeResourceQuotas) Watch added in v0.4.2

func (c *FakeResourceQuotas) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)

type FakeSecrets added in v0.4.1

type FakeSecrets struct {
	Fake      *Fake
	Namespace string
}

Fake implements SecretInterface. Meant to be embedded into a struct to get a default implementation. This makes faking out just the method you want to test easier.

func (*FakeSecrets) Create added in v0.4.1

func (c *FakeSecrets) Create(secret *api.Secret) (*api.Secret, error)

func (*FakeSecrets) Delete added in v0.4.1

func (c *FakeSecrets) Delete(secret string) error

func (*FakeSecrets) Get added in v0.4.1

func (c *FakeSecrets) Get(name string) (*api.Secret, error)

func (*FakeSecrets) List added in v0.4.1

func (c *FakeSecrets) List(labels labels.Selector, field fields.Selector) (*api.SecretList, error)

func (*FakeSecrets) Update added in v0.4.1

func (c *FakeSecrets) Update(secret *api.Secret) (*api.Secret, error)

func (*FakeSecrets) Watch added in v0.4.1

func (c *FakeSecrets) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)

type FakeServices added in v0.2.1

type FakeServices struct {
	Fake      *Fake
	Namespace string
}

Fake implements ServiceInterface. Meant to be embedded into a struct to get a default implementation. This makes faking out just the method you want to test easier.

func (*FakeServices) Create added in v0.2.1

func (c *FakeServices) Create(service *api.Service) (*api.Service, error)

func (*FakeServices) Delete added in v0.2.1

func (c *FakeServices) Delete(service string) error

func (*FakeServices) Get added in v0.2.1

func (c *FakeServices) Get(name string) (*api.Service, error)

func (*FakeServices) List added in v0.2.1

func (c *FakeServices) List(selector labels.Selector) (*api.ServiceList, error)

func (*FakeServices) Update added in v0.2.1

func (c *FakeServices) Update(service *api.Service) (*api.Service, error)

func (*FakeServices) Watch added in v0.2.1

func (c *FakeServices) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)

type FlagSet

type FlagSet interface {
	StringVar(p *string, name, value, usage string)
	BoolVar(p *bool, name string, value bool, usage string)
	UintVar(p *uint, name string, value uint, usage string)
	DurationVar(p *time.Duration, name string, value time.Duration, usage string)
}

FlagSet abstracts the flag interface for compatibility with both Golang "flag" and cobra pflags (Posix style).

type HTTPClient added in v0.2.1

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient is an interface for testing a request object.

type HTTPClientFunc added in v0.2.1

type HTTPClientFunc func(*http.Request) (*http.Response, error)

func (HTTPClientFunc) Do added in v0.2.1

func (f HTTPClientFunc) Do(req *http.Request) (*http.Response, error)

type HTTPContainerInfoGetter

type HTTPContainerInfoGetter struct {
	Client *http.Client
	Port   int
}

func (*HTTPContainerInfoGetter) GetContainerInfo

func (self *HTTPContainerInfoGetter) GetContainerInfo(host, podID, containerID string, req *cadvisorApi.ContainerInfoRequest) (*cadvisorApi.ContainerInfo, error)

func (*HTTPContainerInfoGetter) GetMachineInfo

func (self *HTTPContainerInfoGetter) GetMachineInfo(host string) (*cadvisorApi.MachineInfo, error)

func (*HTTPContainerInfoGetter) GetRootInfo

type HTTPKubeletClient added in v0.2.1

type HTTPKubeletClient struct {
	Client      *http.Client
	Port        uint
	EnableHttps bool
}

HTTPKubeletClient is the default implementation of PodInfoGetter and KubeletHealthchecker, accesses the kubelet over HTTP.

func (*HTTPKubeletClient) GetConnectionInfo added in v0.4.3

func (c *HTTPKubeletClient) GetConnectionInfo(host string) (string, uint, http.RoundTripper, error)

func (*HTTPKubeletClient) GetNodeInfo added in v0.4.2

func (c *HTTPKubeletClient) GetNodeInfo(host string) (api.NodeInfo, error)

GetNodeInfo gets information about the specified node.

func (*HTTPKubeletClient) GetPodStatus added in v0.2.2

func (c *HTTPKubeletClient) GetPodStatus(host, podNamespace, podID string) (api.PodStatusResult, error)

GetPodInfo gets information about the specified pod.

func (*HTTPKubeletClient) HealthCheck added in v0.2.1

func (c *HTTPKubeletClient) HealthCheck(host string) (probe.Result, error)

type KubeletClient added in v0.2.1

KubeletClient is an interface for all kubelet functionality

func NewKubeletClient added in v0.2.1

func NewKubeletClient(config *KubeletConfig) (KubeletClient, error)

TODO: this structure is questionable, it should be using client.Config and overriding defaults.

type KubeletConfig added in v0.2.1

type KubeletConfig struct {
	// ToDo: Add support for different kubelet instances exposing different ports
	Port        uint
	EnableHttps bool

	// TLSClientConfig contains settings to enable transport layer security
	TLSClientConfig

	// HTTPTimeout is used by the client to timeout http requests to Kubelet.
	HTTPTimeout time.Duration
}

type KubeletHealthChecker added in v0.2.1

type KubeletHealthChecker interface {
	HealthCheck(host string) (probe.Result, error)
}

KubeletHealthchecker is an interface for healthchecking kubelets

type LimitRangeInterface added in v0.2.2

type LimitRangeInterface interface {
	List(selector labels.Selector) (*api.LimitRangeList, error)
	Get(name string) (*api.LimitRange, error)
	Delete(name string) error
	Create(limitRange *api.LimitRange) (*api.LimitRange, error)
	Update(limitRange *api.LimitRange) (*api.LimitRange, error)
	Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
}

LimitRangeInterface has methods to work with LimitRange resources.

type LimitRangesNamespacer added in v0.2.2

type LimitRangesNamespacer interface {
	LimitRanges(namespace string) LimitRangeInterface
}

LimitRangesNamespacer has methods to work with LimitRange resources in a namespace

type NamespaceInterface added in v0.3.2

type NamespaceInterface interface {
	Create(item *api.Namespace) (*api.Namespace, error)
	Get(name string) (result *api.Namespace, err error)
	List(label labels.Selector, field fields.Selector) (*api.NamespaceList, error)
	Delete(name string) error
	Update(item *api.Namespace) (*api.Namespace, error)
	Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
	Finalize(item *api.Namespace) (*api.Namespace, error)
	Status(item *api.Namespace) (*api.Namespace, error)
}

type NamespacesInterface added in v0.3.2

type NamespacesInterface interface {
	Namespaces() NamespaceInterface
}

type NodeInfoGetter added in v0.4.2

type NodeInfoGetter interface {
	GetNodeInfo(host string) (api.NodeInfo, error)
}

type NodeInterface added in v0.2.1

type NodeInterface interface {
	Get(name string) (result *api.Node, err error)
	Create(node *api.Node) (*api.Node, error)
	List() (*api.NodeList, error)
	Delete(name string) error
	Update(*api.Node) (*api.Node, error)
	Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
}

type NodesInterface added in v0.2.1

type NodesInterface interface {
	Nodes() NodeInterface
}

type PodInfoGetter

type PodInfoGetter interface {
	// GetPodStatus returns information about all containers which are part
	// Returns an api.PodStatus, or an error if one occurs.
	GetPodStatus(host, podNamespace, podID string) (api.PodStatusResult, error)
}

PodInfoGetter is an interface for things that can get information about a pod's containers. Injectable for easy testing.

type PodInterface

type PodInterface interface {
	List(selector labels.Selector) (*api.PodList, error)
	Get(name string) (*api.Pod, error)
	Delete(name string) error
	Create(pod *api.Pod) (*api.Pod, error)
	Update(pod *api.Pod) (*api.Pod, error)
	Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
	Bind(binding *api.Binding) error
	UpdateStatus(pod *api.Pod) (*api.Pod, error)
}

PodInterface has methods to work with Pod resources.

type PodsNamespacer added in v0.2.1

type PodsNamespacer interface {
	Pods(namespace string) PodInterface
}

PodsNamespacer has methods to work with Pod resources in a namespace

type RESTClient

type RESTClient struct {

	// LegacyBehavior controls if URLs should encode the namespace as a query param,
	// and if resource case is preserved for supporting older API conventions of
	// Kubernetes.  Newer clients should leave this false.
	LegacyBehavior bool

	// Codec is the encoding and decoding scheme that applies to a particular set of
	// REST resources.
	Codec runtime.Codec

	// Set specific behavior of the client.  If not set http.DefaultClient will be
	// used.
	Client HTTPClient

	Timeout time.Duration
	// contains filtered or unexported fields
}

RESTClient imposes common Kubernetes API conventions on a set of resource paths. The baseURL is expected to point to an HTTP or HTTPS path that is the parent of one or more resources. The server should return a decodable API resource object, or an api.Status object which contains information about the reason for any failure.

Most consumers should use client.New() to get a Kubernetes API client.

func NewRESTClient

func NewRESTClient(baseURL *url.URL, apiVersion string, c runtime.Codec, legacyBehavior bool) *RESTClient

NewRESTClient creates a new RESTClient. This client performs generic REST functions such as Get, Put, Post, and Delete on specified paths. Codec controls encoding and decoding of responses from the server. If this client should use the older, legacy API conventions from Kubernetes API v1beta1 and v1beta2, set legacyBehavior true.

func RESTClientFor

func RESTClientFor(config *Config) (*RESTClient, error)

RESTClientFor returns a RESTClient that satisfies the requested attributes on a client Config object. Note that a RESTClient may require fields that are optional when initializing a Client. A RESTClient created by this method is generic - it expects to operate on an API that follows the Kubernetes conventions, but may not be the Kubernetes API.

func (*RESTClient) APIVersion added in v0.2.1

func (c *RESTClient) APIVersion() string

APIVersion returns the APIVersion this RESTClient is expected to use.

func (*RESTClient) Delete

func (c *RESTClient) Delete() *Request

Delete begins a DELETE request. Short for c.Verb("DELETE").

func (*RESTClient) Get

func (c *RESTClient) Get() *Request

Get begins a GET request. Short for c.Verb("GET").

func (*RESTClient) Patch added in v0.4.2

func (c *RESTClient) Patch() *Request

Patch begins a PATCH request. Short for c.Verb("Patch").

func (*RESTClient) Post

func (c *RESTClient) Post() *Request

Post begins a POST request. Short for c.Verb("POST").

func (*RESTClient) Put

func (c *RESTClient) Put() *Request

Put begins a PUT request. Short for c.Verb("PUT").

func (*RESTClient) Verb

func (c *RESTClient) Verb(verb string) *Request

Verb begins a request with a verb (GET, POST, PUT, DELETE).

Example usage of RESTClient's request building interface: c := NewRESTClient(url, codec) resp, err := c.Verb("GET").

Path("pods").
SelectorParam("labels", "area=staging").
Timeout(10*time.Second).
Do()

if err != nil { ... } list, ok := resp.(*api.PodList)

type ReplicationControllerInterface

type ReplicationControllerInterface interface {
	List(selector labels.Selector) (*api.ReplicationControllerList, error)
	Get(name string) (*api.ReplicationController, error)
	Create(ctrl *api.ReplicationController) (*api.ReplicationController, error)
	Update(ctrl *api.ReplicationController) (*api.ReplicationController, error)
	Delete(name string) error
	Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
}

ReplicationControllerInterface has methods to work with ReplicationController resources.

type ReplicationControllersNamespacer added in v0.2.1

type ReplicationControllersNamespacer interface {
	ReplicationControllers(namespace string) ReplicationControllerInterface
}

ReplicationControllersNamespacer has methods to work with ReplicationController resources in a namespace

type Request

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

Request allows for building up a request to a server in a chained fashion. Any errors are stored until the end of your call, so you only have to check once.

func NewRequest added in v0.2.1

func NewRequest(client HTTPClient, verb string, baseURL *url.URL, apiVersion string,
	codec runtime.Codec, namespaceInQuery bool, preserveResourceCase bool) *Request

NewRequest creates a new request helper object for accessing runtime.Objects on a server.

func (*Request) AbsPath

func (r *Request) AbsPath(segments ...string) *Request

AbsPath overwrites an existing path with the segments provided. Trailing slashes are preserved when a single segment is passed.

func (*Request) Body

func (r *Request) Body(obj interface{}) *Request

Body makes the request use obj as the body. Optional. If obj is a string, try to read a file of that name. If obj is a []byte, send it directly. If obj is an io.Reader, use it directly. If obj is a runtime.Object, marshal it correctly. Otherwise, set an error.

func (*Request) Do

func (r *Request) Do() Result

Do formats and executes the request. Returns a Result object for easy response processing.

Error type:

  • If the request can't be constructed, or an error happened earlier while building its arguments: *RequestConstructionError
  • If the server responds with a status: *errors.StatusError or *errors.UnexpectedObjectError
  • If the status code and body don't make sense together: *UnexpectedStatusError
  • http.Client.Do errors are returned directly.

func (*Request) DoRaw added in v0.4.2

func (r *Request) DoRaw() ([]byte, error)

DoRaw executes a raw request which is not subject to interpretation as an API response.

func (*Request) FieldsSelectorParam added in v0.4.2

func (r *Request) FieldsSelectorParam(paramName string, s fields.Selector) *Request

FieldsSelectorParam adds the given selector as a query parameter with the name paramName.

func (*Request) LabelsSelectorParam added in v0.4.2

func (r *Request) LabelsSelectorParam(paramName string, s labels.Selector) *Request

LabelsSelectorParam adds the given selector as a query parameter

func (*Request) Name added in v0.2.1

func (r *Request) Name(resourceName string) *Request

Name sets the name of a resource to access (<resource>/[ns/<namespace>/]<name>)

func (*Request) Namespace

func (r *Request) Namespace(namespace string) *Request

Namespace applies the namespace scope to a request (<resource>/[ns/<namespace>/]<name>)

func (*Request) NamespaceIfScoped added in v0.4.1

func (r *Request) NamespaceIfScoped(namespace string, scoped bool) *Request

NamespaceIfScoped is a convenience function to set a namespace if scoped is true

func (*Request) Param

func (r *Request) Param(paramName, s string) *Request

Param creates a query parameter with the given string value.

func (*Request) ParseSelectorParam

func (r *Request) ParseSelectorParam(paramName, item string) *Request

ParseSelectorParam parses the given string as a resource selector. This is a convenience function so you don't have to first check that it's a validly formatted selector.

func (*Request) Prefix added in v0.2.1

func (r *Request) Prefix(segments ...string) *Request

Prefix adds segments to the relative beginning to the request path. These items will be placed before the optional Namespace, Resource, or Name sections. Setting AbsPath will clear any previously set Prefix segments

func (*Request) RequestURI added in v0.4.1

func (r *Request) RequestURI(uri string) *Request

RequestURI overwrites existing path and parameters with the value of the provided server relative URI. Some parameters (those in specialParameters) cannot be overwritten.

func (*Request) Resource added in v0.2.1

func (r *Request) Resource(resource string) *Request

Resource sets the resource to access (<resource>/[ns/<namespace>/]<name>)

func (*Request) Stream

func (r *Request) Stream() (io.ReadCloser, error)

Stream formats and executes the request, and offers streaming of the response. Returns io.ReadCloser which could be used for streaming of the response, or an error

func (*Request) SubResource added in v0.4.2

func (r *Request) SubResource(subresources ...string) *Request

SubResource sets a sub-resource path which can be multiple segments segment after the resource name but before the suffix.

func (*Request) Suffix added in v0.2.1

func (r *Request) Suffix(segments ...string) *Request

Suffix appends segments to the end of the path. These items will be placed after the prefix and optional Namespace, Resource, or Name sections.

func (*Request) Timeout

func (r *Request) Timeout(d time.Duration) *Request

Timeout makes the request use the given duration as a timeout. Sets the "timeout" parameter.

func (*Request) UintParam

func (r *Request) UintParam(paramName string, u uint64) *Request

UintParam creates a query parameter with the given value.

func (*Request) Upgrade added in v0.4.1

func (r *Request) Upgrade(config *Config, newRoundTripperFunc func(*tls.Config) httpstream.UpgradeRoundTripper) (httpstream.Connection, error)

Upgrade upgrades the request so that it supports multiplexed bidirectional streams. The current implementation uses SPDY, but this could be replaced with HTTP/2 once it's available, or something else.

func (*Request) Watch

func (r *Request) Watch() (watch.Interface, error)

Watch attempts to begin watching the requested location. Returns a watch.Interface, or an error.

type RequestConstructionError added in v0.2.1

type RequestConstructionError struct {
	Err error
}

RequestConstructionError is returned when there's an error assembling a request.

func (*RequestConstructionError) Error added in v0.2.1

func (r *RequestConstructionError) Error() string

Error returns a textual description of 'r'.

type ResourceQuotaInterface added in v0.2.2

type ResourceQuotaInterface interface {
	List(selector labels.Selector) (*api.ResourceQuotaList, error)
	Get(name string) (*api.ResourceQuota, error)
	Delete(name string) error
	Create(resourceQuota *api.ResourceQuota) (*api.ResourceQuota, error)
	Update(resourceQuota *api.ResourceQuota) (*api.ResourceQuota, error)
	UpdateStatus(resourceQuota *api.ResourceQuota) (*api.ResourceQuota, error)
	Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
}

ResourceQuotaInterface has methods to work with ResourceQuota resources.

type ResourceQuotasNamespacer added in v0.2.2

type ResourceQuotasNamespacer interface {
	ResourceQuotas(namespace string) ResourceQuotaInterface
}

ResourceQuotasNamespacer has methods to work with ResourceQuota resources in a namespace

type Result

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

Result contains the result of calling Request.Do().

func (Result) Error

func (r Result) Error() error

Error returns the error executing the request, nil if no error occurred. See the Request.Do() comment for what errors you might get.

func (Result) Get

func (r Result) Get() (runtime.Object, error)

Get returns the result as an object.

func (Result) Into

func (r Result) Into(obj runtime.Object) error

Into stores the result into obj, if possible.

func (Result) Raw

func (r Result) Raw() ([]byte, error)

Raw returns the raw result.

func (Result) WasCreated added in v0.2.1

func (r Result) WasCreated(wasCreated *bool) Result

WasCreated updates the provided bool pointer to whether the server returned 201 created or a different response.

type SecretsInterface added in v0.4.1

type SecretsInterface interface {
	Create(secret *api.Secret) (*api.Secret, error)
	Update(secret *api.Secret) (*api.Secret, error)
	Delete(name string) error
	List(label labels.Selector, field fields.Selector) (*api.SecretList, error)
	Get(name string) (*api.Secret, error)
	Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
}

type SecretsNamespacer added in v0.4.1

type SecretsNamespacer interface {
	Secrets(namespace string) SecretsInterface
}

type ServiceInterface

type ServiceInterface interface {
	List(selector labels.Selector) (*api.ServiceList, error)
	Get(name string) (*api.Service, error)
	Create(srv *api.Service) (*api.Service, error)
	Update(srv *api.Service) (*api.Service, error)
	Delete(name string) error
	Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
}

ServiceInterface has methods to work with Service resources.

type ServicesNamespacer added in v0.2.1

type ServicesNamespacer interface {
	Services(namespace string) ServiceInterface
}

ServicesNamespacer has methods to work with Service resources in a namespace

type TLSClientConfig added in v0.3.1

type TLSClientConfig struct {
	// Server requires TLS client certificate authentication
	CertFile string
	// Server requires TLS client certificate authentication
	KeyFile string
	// Trusted root certificates for server
	CAFile string

	// CertData holds PEM-encoded bytes (typically read from a client certificate file).
	// CertData takes precedence over CertFile
	CertData []byte
	// KeyData holds PEM-encoded bytes (typically read from a client certificate key file).
	// KeyData takes precedence over KeyFile
	KeyData []byte
	// CAData holds PEM-encoded bytes (typically read from a root certificates bundle).
	// CAData takes precedence over CAFile
	CAData []byte
}

TLSClientConfig contains settings to enable transport layer security

type UnexpectedStatusError added in v0.2.1

type UnexpectedStatusError struct {
	Request  *http.Request
	Response *http.Response
	Body     string
}

UnexpectedStatusError is returned as an error if a response's body and HTTP code don't make sense together.

func (*UnexpectedStatusError) Error added in v0.2.1

func (u *UnexpectedStatusError) Error() string

Error returns a textual description of 'u'.

type VersionInterface

type VersionInterface interface {
	ServerVersion() (*version.Info, error)
	ServerAPIVersions() (*api.APIVersions, error)
}

VersionInterface has a method to retrieve the server version.

Directories

Path Synopsis
Package cache is a client-side caching mechanism.
Package cache is a client-side caching mechanism.
Package clientcmd provides one stop shopping for building a working client from a fixed config, from a .kubeconfig file, from command line flags, or from any merged combination.
Package clientcmd provides one stop shopping for building a working client from a fixed config, from a .kubeconfig file, from command line flags, or from any merged combination.
api
Package portforward adds support for SSH-like port forwarding from the client's local host to remote containers.
Package portforward adds support for SSH-like port forwarding from the client's local host to remote containers.
Package record has all client logic for recording and reporting events.
Package record has all client logic for recording and reporting events.
Package remotecommand adds support for executing commands in containers, with support for separate stdin, stdout, and stderr streams, as well as TTY.
Package remotecommand adds support for executing commands in containers, with support for separate stdin, stdout, and stderr streams, as well as TTY.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL