Documentation ¶
Overview ¶
Package client contains the implementation of the client side communication with the Kubernetes master.
Index ¶
- Variables
- type AuthInfo
- type Client
- func (c *Client) ControllerHasDesiredReplicas(controller api.ReplicationController) wait.ConditionFunc
- func (c *Client) CreatePod(pod *api.Pod) (result *api.Pod, err error)
- func (c *Client) CreateReplicationController(controller *api.ReplicationController) (result *api.ReplicationController, err error)
- func (c *Client) CreateService(svc *api.Service) (result *api.Service, err error)
- func (c *Client) DeletePod(id string) error
- func (c *Client) DeleteReplicationController(id string) error
- func (c *Client) DeleteService(id string) error
- func (c *Client) GetPod(id string) (result *api.Pod, err error)
- func (c *Client) GetReplicationController(id string) (result *api.ReplicationController, err error)
- func (c *Client) GetService(id string) (result *api.Service, err error)
- func (c *Client) ListEndpoints(selector labels.Selector) (result *api.EndpointsList, err error)
- func (c *Client) ListMinions() (result *api.MinionList, err error)
- func (c *Client) ListPods(selector labels.Selector) (result *api.PodList, err error)
- func (c *Client) ListReplicationControllers(selector labels.Selector) (result *api.ReplicationControllerList, err error)
- func (c *Client) ListServices(selector labels.Selector) (result *api.ServiceList, err error)
- func (c *Client) ServerVersion() (*version.Info, error)
- func (c *Client) UpdatePod(pod *api.Pod) (result *api.Pod, err error)
- func (c *Client) UpdateReplicationController(controller *api.ReplicationController) (result *api.ReplicationController, err error)
- func (c *Client) UpdateService(svc *api.Service) (result *api.Service, err error)
- func (c *Client) WatchEndpoints(label, field labels.Selector, resourceVersion uint64) (watch.Interface, error)
- func (c *Client) WatchReplicationControllers(label, field labels.Selector, resourceVersion uint64) (watch.Interface, error)
- func (c *Client) WatchServices(label, field labels.Selector, resourceVersion uint64) (watch.Interface, error)
- type ContainerInfoGetter
- type EndpointsInterface
- type Fake
- func (c *Fake) CreatePod(pod *api.Pod) (*api.Pod, error)
- func (c *Fake) CreateReplicationController(controller *api.ReplicationController) (*api.ReplicationController, error)
- func (c *Fake) CreateService(service *api.Service) (*api.Service, error)
- func (c *Fake) DeletePod(name string) error
- func (c *Fake) DeleteReplicationController(controller string) error
- func (c *Fake) DeleteService(service string) error
- func (c *Fake) GetPod(name string) (*api.Pod, error)
- func (c *Fake) GetReplicationController(name string) (*api.ReplicationController, error)
- func (c *Fake) GetService(name string) (*api.Service, error)
- func (c *Fake) ListEndpoints(selector labels.Selector) (*api.EndpointsList, error)
- func (c *Fake) ListMinions() (*api.MinionList, error)
- func (c *Fake) ListPods(selector labels.Selector) (*api.PodList, error)
- func (c *Fake) ListReplicationControllers(selector labels.Selector) (*api.ReplicationControllerList, error)
- func (c *Fake) ListServices(selector labels.Selector) (*api.ServiceList, error)
- func (c *Fake) ServerVersion() (*version.Info, error)
- func (c *Fake) UpdatePod(pod *api.Pod) (*api.Pod, error)
- func (c *Fake) UpdateReplicationController(controller *api.ReplicationController) (*api.ReplicationController, error)
- func (c *Fake) UpdateService(service *api.Service) (*api.Service, error)
- func (c *Fake) WatchEndpoints(label, field labels.Selector, resourceVersion uint64) (watch.Interface, error)
- func (c *Fake) WatchReplicationControllers(label, field labels.Selector, resourceVersion uint64) (watch.Interface, error)
- func (c *Fake) WatchServices(label, field labels.Selector, resourceVersion uint64) (watch.Interface, error)
- type FakeAction
- type FakePodInfoGetter
- type HTTPContainerInfoGetter
- func (self *HTTPContainerInfoGetter) GetContainerInfo(host, podID, containerID string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error)
- func (self *HTTPContainerInfoGetter) GetMachineInfo(host string) (*info.MachineInfo, error)
- func (self *HTTPContainerInfoGetter) GetRootInfo(host string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error)
- type HTTPPodInfoGetter
- type Interface
- type MinionInterface
- type PodInfoGetter
- type PodInterface
- type RESTClient
- type ReplicationControllerInterface
- type Request
- func (r *Request) AbsPath(path string) *Request
- func (r *Request) Body(obj interface{}) *Request
- func (r *Request) Do() Result
- func (r *Request) ParseSelectorParam(paramName, item string) *Request
- func (r *Request) Path(item string) *Request
- func (r *Request) PollPeriod(d time.Duration) *Request
- func (r *Request) SelectorParam(paramName string, s labels.Selector) *Request
- func (r *Request) Sync(sync bool) *Request
- func (r *Request) Timeout(d time.Duration) *Request
- func (r *Request) UintParam(paramName string, u uint64) *Request
- func (r *Request) Watch() (watch.Interface, error)
- type Result
- type ServiceInterface
- type StatusErr
- type VersionInterface
Constants ¶
This section is empty.
Variables ¶
var ErrPodInfoNotAvailable = errors.New("no pod info available")
ErrPodInfoNotAvailable may be returned when the requested pod info is not available.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
*RESTClient
}
Client is the actual implementation of a Kubernetes client.
func New ¶
New creates a Kubernetes client. This client works with pods, replication controllers and services. It allows operations such as list, get, update and delete on these objects. host must be a host string, a host:port combo, or an http or https URL. Passing a prefix to a URL will prepend the server path. Returns an error if host cannot be converted to a valid URL.
func (*Client) ControllerHasDesiredReplicas ¶
func (c *Client) ControllerHasDesiredReplicas(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 (*Client) CreatePod ¶
CreatePod takes the representation of a pod. Returns the server's representation of the pod, and an error, if it occurs.
func (*Client) CreateReplicationController ¶
func (c *Client) CreateReplicationController(controller *api.ReplicationController) (result *api.ReplicationController, err error)
CreateReplicationController creates a new replication controller.
func (*Client) CreateService ¶
CreateService creates a new service.
func (*Client) DeleteReplicationController ¶
DeleteReplicationController deletes an existing replication controller.
func (*Client) DeleteService ¶
DeleteService deletes an existing service.
func (*Client) GetPod ¶
GetPod takes the id of the pod, and returns the corresponding Pod object, and an error if it occurs
func (*Client) GetReplicationController ¶
func (c *Client) GetReplicationController(id string) (result *api.ReplicationController, err error)
GetReplicationController returns information about a particular replication controller.
func (*Client) GetService ¶
GetService returns information about a particular service.
func (*Client) ListEndpoints ¶
ListEndpoints takes a selector, and returns the list of endpoints that match that selector
func (*Client) ListMinions ¶
func (c *Client) ListMinions() (result *api.MinionList, err error)
ListMinions lists all the minions in the cluster.
func (*Client) ListPods ¶
ListPods takes a selector, and returns the list of pods that match that selector.
func (*Client) ListReplicationControllers ¶
func (c *Client) ListReplicationControllers(selector labels.Selector) (result *api.ReplicationControllerList, err error)
ListReplicationControllers takes a selector, and returns the list of replication controllers that match that selector.
func (*Client) ListServices ¶
ListServices takes a selector, and returns the list of services that match that selector
func (*Client) ServerVersion ¶
ServerVersion retrieves and parses the server's version.
func (*Client) UpdatePod ¶
UpdatePod takes the representation of a pod to update. Returns the server's representation of the pod, and an error, if it occurs.
func (*Client) UpdateReplicationController ¶
func (c *Client) UpdateReplicationController(controller *api.ReplicationController) (result *api.ReplicationController, err error)
UpdateReplicationController updates an existing replication controller.
func (*Client) UpdateService ¶
UpdateService updates an existing service.
func (*Client) WatchEndpoints ¶
func (c *Client) WatchEndpoints(label, field labels.Selector, resourceVersion uint64) (watch.Interface, error)
WatchEndpoints returns a watch.Interface that watches the requested endpoints for a service.
type ContainerInfoGetter ¶
type ContainerInfoGetter interface { // GetContainerInfo returns information about a container. GetContainerInfo(host, podID, containerID string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error) // GetRootInfo returns information about the root container on a machine. GetRootInfo(host string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error) // GetMachineInfo returns the machine's information like number of cores, memory capacity. GetMachineInfo(host string) (*info.MachineInfo, error) }
type EndpointsInterface ¶
type EndpointsInterface interface { ListEndpoints(selector labels.Selector) (*api.EndpointsList, error) WatchEndpoints(label, field labels.Selector, resourceVersion uint64) (watch.Interface, error) }
EndpointsInterface has methods to work with Endpoints resources
type Fake ¶
type Fake struct { // Fake by default keeps a simple list of the methods that have been called. Actions []FakeAction Pods api.PodList Ctrl api.ReplicationController ServiceList api.ServiceList EndpointsList api.EndpointsList 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) CreateReplicationController ¶
func (c *Fake) CreateReplicationController(controller *api.ReplicationController) (*api.ReplicationController, error)
func (*Fake) CreateService ¶
func (*Fake) DeleteReplicationController ¶
func (*Fake) DeleteService ¶
func (*Fake) GetReplicationController ¶
func (c *Fake) GetReplicationController(name string) (*api.ReplicationController, error)
func (*Fake) ListEndpoints ¶
func (*Fake) ListMinions ¶
func (c *Fake) ListMinions() (*api.MinionList, error)
func (*Fake) ListReplicationControllers ¶
func (*Fake) ListServices ¶
func (*Fake) UpdateReplicationController ¶
func (c *Fake) UpdateReplicationController(controller *api.ReplicationController) (*api.ReplicationController, error)
func (*Fake) UpdateService ¶
func (*Fake) WatchEndpoints ¶
func (*Fake) WatchReplicationControllers ¶
type FakeAction ¶
type FakeAction struct { Action string Value interface{} }
type FakePodInfoGetter ¶
type FakePodInfoGetter struct {
// contains filtered or unexported fields
}
FakePodInfoGetter is a fake implementation of PodInfoGetter. It is useful for testing.
func (*FakePodInfoGetter) GetPodInfo ¶
func (c *FakePodInfoGetter) GetPodInfo(host, podID string) (api.PodInfo, error)
GetPodInfo is a fake implementation of PodInfoGetter.GetPodInfo.
type HTTPContainerInfoGetter ¶
func (*HTTPContainerInfoGetter) GetContainerInfo ¶
func (self *HTTPContainerInfoGetter) GetContainerInfo(host, podID, containerID string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error)
func (*HTTPContainerInfoGetter) GetMachineInfo ¶
func (self *HTTPContainerInfoGetter) GetMachineInfo(host string) (*info.MachineInfo, error)
func (*HTTPContainerInfoGetter) GetRootInfo ¶
func (self *HTTPContainerInfoGetter) GetRootInfo(host string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error)
type HTTPPodInfoGetter ¶
HTTPPodInfoGetter is the default implementation of PodInfoGetter, accesses the kubelet over HTTP.
func (*HTTPPodInfoGetter) GetPodInfo ¶
func (c *HTTPPodInfoGetter) GetPodInfo(host, podID string) (api.PodInfo, error)
GetPodInfo gets information about the specified pod.
type Interface ¶
type Interface interface { PodInterface ReplicationControllerInterface ServiceInterface VersionInterface MinionInterface }
Interface holds the methods for clients of Kubernetes, an interface to allow mock testing. TODO: these should return/take pointers.
type MinionInterface ¶
type MinionInterface interface {
ListMinions() (*api.MinionList, error)
}
type PodInfoGetter ¶
type PodInfoGetter interface { // GetPodInfo returns information about all containers which are part // Returns an api.PodInfo, or an error if one occurs. GetPodInfo(host, podID string) (api.PodInfo, 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 { ListPods(selector labels.Selector) (*api.PodList, error) GetPod(id string) (*api.Pod, error) DeletePod(id string) error CreatePod(*api.Pod) (*api.Pod, error) UpdatePod(*api.Pod) (*api.Pod, error) }
PodInterface has methods to work with Pod resources.
type RESTClient ¶
type RESTClient struct { Sync bool PollPeriod time.Duration Timeout time.Duration Codec runtime.Codec // contains filtered or unexported fields }
RESTClient holds common code used to work with API resources that follow the Kubernetes API pattern. Host is the http://... base for the URL
func NewRESTClient ¶
NewRESTClient creates a new RESTClient. This client performs generic REST functions such as Get, Put, Post, and Delete on specified paths.
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) PollFor ¶
func (c *RESTClient) PollFor(operationID string) *Request
PollFor makes a request to do a single poll of the completion of the given operation.
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) Secure ¶
func (c *RESTClient) Secure() bool
Secure returns true if the client is configured for secure connections.
func (*RESTClient) Verb ¶
func (c *RESTClient) Verb(verb string) *Request
Verb begins a request with a verb (GET, POST, PUT, DELETE).
Example usage of Client's request building interface: auth, err := LoadAuth(filename) c := New(url, auth) 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 { ListReplicationControllers(selector labels.Selector) (*api.ReplicationControllerList, error) GetReplicationController(id string) (*api.ReplicationController, error) CreateReplicationController(*api.ReplicationController) (*api.ReplicationController, error) UpdateReplicationController(*api.ReplicationController) (*api.ReplicationController, error) DeleteReplicationController(string) error WatchReplicationControllers(label, field labels.Selector, resourceVersion uint64) (watch.Interface, error) }
ReplicationControllerInterface has methods to work with ReplicationController resources.
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 (*Request) Body ¶
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 ¶
Do formats and executes the request. Returns the API object received, or an error.
func (*Request) ParseSelectorParam ¶
ParseSelectorParam parses the given string as a resource label selector. This is a convenience function so you don't have to first check that it's a validly formatted selector.
func (*Request) PollPeriod ¶
PollPeriod sets the poll period. If the server sends back a "working" status message, then repeatedly poll the server to see if the operation has completed yet, waiting 'd' between each poll. If you want to handle the "working" status yourself (it'll be delivered as StatusErr), set d to 0 to turn off this behavior.
func (*Request) SelectorParam ¶
SelectorParam adds the given selector as a query parameter with the name paramName.
func (*Request) Sync ¶
Sync sets sync/async call status by setting the "sync" parameter to "true"/"false".
func (*Request) Timeout ¶
Timeout makes the request use the given duration as a timeout. Sets the "timeout" parameter. Ignored if sync=false.
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
Result contains the result of calling Request.Do().
type ServiceInterface ¶
type ServiceInterface interface { ListServices(selector labels.Selector) (*api.ServiceList, error) GetService(id string) (*api.Service, error) CreateService(*api.Service) (*api.Service, error) UpdateService(*api.Service) (*api.Service, error) DeleteService(string) error WatchServices(label, field labels.Selector, resourceVersion uint64) (watch.Interface, error) }
ServiceInterface has methods to work with Service resources.
type StatusErr ¶
StatusErr might get returned from an api call if your request is still being processed and hence the expected return data is not available yet.
type VersionInterface ¶
VersionInterface has a method to retrieve the server version.