unversioned

package
v1.2.2 Latest Latest
Warning

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

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

Documentation

Overview

Package unversioned 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, daemons, services, and nodes.

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

import (
  client "k8s.io/kubernetes/pkg/client/unversioned"
  "k8s.io/kubernetes/pkg/api"
  "k8s.io/kubernetes/pkg/fields"
  "k8s.io/kubernetes/pkg/labels"
)

[...]

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

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/devel/api-conventions.md`) for a given API path and is intended for use by consumers implementing their own Kubernetes compatible APIs.

Index

Constants

View Source
const (
	ConfigMapResourceName string = "configmaps"
)

Variables

View Source
var DefaultBackoff = wait.Backoff{
	Steps:    4,
	Duration: 10 * time.Millisecond,
	Factor:   5.0,
	Jitter:   0.1,
}

DefaultBackoff is the recommended backoff for a conflict where a client may be attempting to make an unrelated modification to a resource under active management by one or more controllers.

View Source
var DefaultRetry = wait.Backoff{
	Steps:    5,
	Duration: 10 * time.Millisecond,
	Factor:   1.0,
	Jitter:   0.1,
}

DefaultRetry is the recommended retry for a conflict where multiple clients are making changes to the same resource.

Functions

func ControllerHasDesiredReplicas

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

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

func DeploymentHasDesiredReplicas added in v1.2.0

func DeploymentHasDesiredReplicas(c ExtensionsInterface, deployment *extensions.Deployment) wait.ConditionFunc

DeploymentHasDesiredReplicas returns a condition that will be true if and only if the desired replica count for a deployment equals its updated replicas count. (non-terminated pods that have the desired template spec).

func GetInvolvedObjectNameFieldLabel added in v1.2.0

func GetInvolvedObjectNameFieldLabel(version string) string

Returns the appropriate field label to use for name of the involved object as per the given API version.

func IsTimeout

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 JobHasDesiredParallelism

func JobHasDesiredParallelism(c ExtensionsInterface, job *extensions.Job) wait.ConditionFunc

JobHasDesiredParallelism returns a condition that will be true if the desired parallelism count for a job equals the current active counts or is less by an appropriate successful/unsuccessful count.

func MatchesServerVersion

func MatchesServerVersion(client *Client, c *restclient.Config) error

MatchesServerVersion queries the server to compares the build version (git hash) of the client with the server's build version. It returns an error if it failed to contact the server or if the versions are not an exact match.

func NegotiateVersion

func NegotiateVersion(client *Client, c *restclient.Config, requestedGV *unversioned.GroupVersion, clientRegisteredGVs []unversioned.GroupVersion) (*unversioned.GroupVersion, error)

NegotiateVersion queries the server's supported api versions to find a version that both client and server support.

  • If no version is provided, try registered client versions in order of preference.
  • If version is provided, but not default config (explicitly requested via commandline flag), and is unsupported by the server, print a warning to stderr and try client's registered versions in order of preference.
  • If version is config default, and the server does not support it, return an error.

func ReplicaSetHasDesiredReplicas added in v1.2.0

func ReplicaSetHasDesiredReplicas(c ExtensionsInterface, replicaSet *extensions.ReplicaSet) wait.ConditionFunc

ReplicaSetHasDesiredReplicas returns a condition that will be true if and only if the desired replica count for a ReplicaSet's ReplicaSelector equals the Replicas count.

func RetryOnConflict added in v1.2.0

func RetryOnConflict(backoff wait.Backoff, fn func() error) error

RetryConflict executes the provided function repeatedly, retrying if the server returns a conflicting write. Callers should preserve previous executions if they wish to retry changes. It performs an exponential backoff.

var pod *api.Pod
err := RetryOnConflict(DefaultBackoff, func() (err error) {
  pod, err = c.Pods("mynamespace").UpdateStatus(podStatus)
  return
})
if err != nil {
  // may be conflict if max retries were hit
  return err
}
...

TODO: Make Backoff an interface?

func SetKubernetesDefaults

func SetKubernetesDefaults(config *restclient.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. TODO: this method needs to be split into one that sets defaults per group, expected to be fix in PR "Refactoring clientcache.go and helper.go #14592"

Types

type AutoscalingClient added in v1.2.0

type AutoscalingClient struct {
	*restclient.RESTClient
}

AutoscalingClient is used to interact with Kubernetes autoscaling features.

func NewAutoscaling added in v1.2.0

func NewAutoscaling(c *restclient.Config) (*AutoscalingClient, error)

func NewAutoscalingOrDie added in v1.2.0

func NewAutoscalingOrDie(c *restclient.Config) *AutoscalingClient

func (*AutoscalingClient) HorizontalPodAutoscalers added in v1.2.0

func (c *AutoscalingClient) HorizontalPodAutoscalers(namespace string) HorizontalPodAutoscalerInterface

type AutoscalingInterface added in v1.2.0

type AutoscalingInterface interface {
	HorizontalPodAutoscalersNamespacer
}

type BatchClient added in v1.2.0

type BatchClient struct {
	*restclient.RESTClient
}

BatchClient is used to interact with Kubernetes batch features.

func NewBatch added in v1.2.0

func NewBatch(c *restclient.Config) (*BatchClient, error)

func NewBatchOrDie added in v1.2.0

func NewBatchOrDie(c *restclient.Config) *BatchClient

func (*BatchClient) Jobs added in v1.2.0

func (c *BatchClient) Jobs(namespace string) JobInterface

type BatchInterface added in v1.2.0

type BatchInterface interface {
	JobsNamespacer
}

type Client

Client is the implementation of a Kubernetes client.

func New

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

New creates a Kubernetes client for the given config. This client works with pods, replication controllers, daemons, 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 NewInCluster

func NewInCluster() (*Client, error)

NewInCluster is a shortcut for calling InClusterConfig() and then New().

func NewOrDie

func NewOrDie(c *restclient.Config) *Client

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

func (*Client) Autoscaling added in v1.2.0

func (c *Client) Autoscaling() AutoscalingInterface

func (*Client) Batch added in v1.2.0

func (c *Client) Batch() BatchInterface

func (*Client) ComponentStatuses

func (c *Client) ComponentStatuses() ComponentStatusInterface

func (*Client) ConfigMaps added in v1.2.0

func (c *Client) ConfigMaps(namespace string) ConfigMapsInterface

func (*Client) Discovery added in v1.1.1

func (c *Client) Discovery() discovery.DiscoveryInterface

func (*Client) Endpoints

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

func (*Client) Events

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

func (*Client) Extensions added in v1.1.1

func (c *Client) Extensions() ExtensionsInterface

func (*Client)