kubernetes

package
v0.0.0-...-6c7e5b9 Latest Latest
Warning

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

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

Documentation

Overview

Package kubernetes provides abstractions for the Kubernetes platform. At the moment, Kubernetes is the only supported platform, so we are directly returning Kubernetes objects. As we add more platforms, we will create abstractions and common data types in package platform.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptySelector        = errors.New("empty selector")
	ErrWrongResourceKind    = errors.New("new definition does not match existing resource")
	ErrNoMatchingService    = errors.New("no matching service")
	ErrServiceHasNoSelector = errors.New("service has no selector")
	ErrNoMatching           = errors.New("no matching replication controllers or deployments")
	ErrMultipleMatching     = errors.New("multiple matching replication controllers or deployments")
	ErrNoMatchingImages     = errors.New("no matching images")
)

These errors are returned by cluster methods.

Functions

func FilesFor

func FilesFor(path, namespace, service string) (filenames []string, err error)

FilesFor returns the resource definition files in path (or any subdirectory) that are responsible for driving the given namespace/service. It presumes kubeservice is available in the PWD or PATH.

func UpdatePodController

func UpdatePodController(def []byte, newImageName string, trace io.Writer) ([]byte, error)

UpdatePodController takes the body of a ReplicationController or Deployment resource definition (specified in YAML) and the name of the new image that should be put in the definition (in the format "repo.org/group/name:tag"). It returns a new resource definition body where all references to the old image have been replaced with the new one.

This function has many additional requirements that are likely in flux. Read the source to learn about them.

Types

type Cluster

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

Cluster is a handle to a Kubernetes API server. (Typically, this code is deployed into the same cluster.)

func NewCluster

func NewCluster(config *restclient.Config, kubectl string, logger log.Logger) (*Cluster, error)

NewCluster returns a usable cluster. Host should be of the form "http://hostname:8080".

func (*Cluster) ContainersFor

func (c *Cluster) ContainersFor(namespace, serviceName string) (res []platform.Container, err error)

ContainersFor returns a list of container names with the image specified to run in that container, for a particular service. This is useful to see which images a particular service is presently running, to judge whether a release is needed.

func (*Cluster) Namespaces

func (c *Cluster) Namespaces() ([]string, error)

Namespaces returns the set of available namespaces on the platform.

func (*Cluster) Release

func (c *Cluster) Release(namespace, serviceName string, newDefinition []byte) error

Release performs a update of the service, from whatever it is currently, to what is described by the new resource, which can be a replication controller or deployment.

Release assumes there is a one-to-one mapping between services and replication controllers or deployments; this can be improved. Release blocks until the rolling update is complete; this can be improved. Release invokes `kubectl rolling-update` or `kubectl apply` in a seperate process, and assumes kubectl is in the PATH; this can be improved.

func (*Cluster) Service

func (c *Cluster) Service(namespace, service string) (platform.Service, error)

Service returns the platform.Service representation of the named service.

func (*Cluster) Services

func (c *Cluster) Services(namespace string) ([]platform.Service, error)

Services returns the set of services currently active on the platform in the given namespace. Maybe it makes sense to move the namespace to the constructor? Depends on how it will be used. For now it is here.

The user is expected to list services, and then choose the one that will receive a release. Releases operate on replication controllers, not services. For now, we make a simplifying assumption that there is a one-to-one mapping between services and replication controllers.

Jump to

Keyboard shortcuts

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