kubectl

package
v0.8.1-0...-6cd3763 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2015 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package kubectl is a set of libraries that are used by the kubectl command line tool. They are separated out into a library to support unit testing. Most functionality should be included in this package, and the main kubectl should really just be an entry point.

A set of common functions needed by cmd/kubectl and pkg/kubectl packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetClientVersion

func GetClientVersion(w io.Writer)

func GetKubeClient

func GetKubeClient(config *client.Config, matchVersion bool) (*client.Client, error)

func GetVersion

func GetVersion(w io.Writer, kubeClient client.Interface)

func SaveNamespaceInfo

func SaveNamespaceInfo(path string, ns *NamespaceInfo) error

SaveNamespaceInfo saves a NamespaceInfo object at the specified file path.

func WatchLoop

func WatchLoop(w watch.Interface, printer ResourcePrinter, out io.Writer)

WatchLoop loops, writing objects in the events from w to printer. If user sends interrupt signal, shut down cleanly. Otherwise, never return.

Types

type Describer

type Describer interface {
	Describe(namespace, name string) (output string, err error)
}

Describer generates output for the named resource or an error if the output could not be generated.

func DescriberFor

func DescriberFor(kind string, c *client.Client) (Describer, bool)

Describer returns the default describe functions for each of the standard Kubernetes types.

type HumanReadablePrinter

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

HumanReadablePrinter is an implementation of ResourcePrinter which attempts to provide more elegant output. It is not threadsafe, but you may call PrintObj repeatedly; headers will only be printed if the object type changes. This makes it useful for printing items recieved from watches.

func NewHumanReadablePrinter

func NewHumanReadablePrinter(noHeaders bool) *HumanReadablePrinter

NewHumanReadablePrinter creates a HumanReadablePrinter.

func (*HumanReadablePrinter) Handler

func (h *HumanReadablePrinter) Handler(columns []string, printFunc interface{}) error

Handler adds a print handler with a given set of columns to HumanReadablePrinter instance. printFunc is the function that will be called to print an object. It must be of the following type:

func printFunc(object ObjectType, w io.Writer) error

where ObjectType is the type of the object that will be printed.

func (*HumanReadablePrinter) PrintObj

func (h *HumanReadablePrinter) PrintObj(obj runtime.Object, output io.Writer) error

PrintObj prints the obj in a human-friendly format according to the type of the obj.

type JSONPrinter

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

JSONPrinter is an implementation of ResourcePrinter which outputs an object as JSON. The input object is assumed to be in the internal version of an API and is converted to the given version first.

func (*JSONPrinter) PrintObj

func (p *JSONPrinter) PrintObj(obj runtime.Object, w io.Writer) error

PrintObj is an implementation of ResourcePrinter.PrintObj which simply writes the object to the Writer.

type MinionDescriber

type MinionDescriber struct {
	client.Interface
}

MinionDescriber generates information about a minion.

func (*MinionDescriber) Describe

func (d *MinionDescriber) Describe(namespace, name string) (string, error)

type NamespaceInfo

type NamespaceInfo struct {
	Namespace string
}

func LoadNamespaceInfo

func LoadNamespaceInfo(path string) (*NamespaceInfo, error)

LoadNamespaceInfo parses a NamespaceInfo object from a file path. It creates a file at the specified path if it doesn't exist with the default namespace.

type PodDescriber

type PodDescriber struct {
	client.Interface
}

PodDescriber generates information about a pod and the replication controllers that create it.

func (*PodDescriber) Describe

func (d *PodDescriber) Describe(namespace, name string) (string, error)

type ProxyServer

type ProxyServer struct {
	httputil.ReverseProxy
	Port int
}

ProxyServer is a http.Handler which proxies Kubernetes APIs to remote API server.

func NewProxyServer

func NewProxyServer(filebase string, cfg *client.Config, port int) (*ProxyServer, error)

NewProxyServer creates and installs a new ProxyServer. It automatically registers the created ProxyServer to http.DefaultServeMux.

func (*ProxyServer) Serve

func (s *ProxyServer) Serve() error

Serve starts the server (http.DefaultServeMux) on TCP port 8001, loops forever.

type RESTClient

type RESTClient interface {
	Get() *client.Request
	Post() *client.Request
	Delete() *client.Request
	Put() *client.Request
}

RESTClient is a client helper for dealing with RESTful resources in a generic way.

type ReplicationControllerDescriber

type ReplicationControllerDescriber struct {
	client.Interface
}

ReplicationControllerDescriber generates information about a replication controller and the pods it has created.

func (*ReplicationControllerDescriber) Describe

func (d *ReplicationControllerDescriber) Describe(namespace, name string) (string, error)

type ResourcePrinter

type ResourcePrinter interface {
	// Print receives an arbitrary object, formats it and prints it to a writer.
	PrintObj(runtime.Object, io.Writer) error
}

ResourcePrinter is an interface that knows how to print runtime objects.

func GetPrinter

func GetPrinter(format, formatArgument, version string, convertor runtime.ObjectConvertor, defaultPrinter ResourcePrinter) (ResourcePrinter, error)

GetPrinter takes a format type, an optional format argument, a version and a convertor to be used if the underlying printer requires the object to be in a specific schema ( any of the generic formatters), and the default printer to use for this object.

type RollingUpdater

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

RollingUpdater provides methods for updating replicated pods in a predictable, fault-tolerant way.

func NewRollingUpdater

func NewRollingUpdater(namespace string, c client.Interface) *RollingUpdater

NewRollingUpdater creates a RollingUpdater from a client

func (*RollingUpdater) Update

func (r *RollingUpdater) Update(out io.Writer, oldRc, newRc *api.ReplicationController, updatePeriod, interval, timeout time.Duration) error

Update all pods for a ReplicationController (oldRc) by creating a new controller (newRc) with 0 replicas, and synchronously resizing oldRc,newRc by 1 until oldRc has 0 replicas and newRc has the original # of desired replicas. oldRc is then deleted. If an update from newRc to oldRc is already in progress, we attempt to drive it to completion. If an error occurs at any step of the update, the error will be returned.

'out' writer for progress output
'oldRc' existing controller to be replaced
'newRc' controller that will take ownership of updated pods (will be created if needed)
'updatePeriod' time to wait between individual pod updates
'interval' time to wait between polling controller status after update
'timeout' time to wait for controller updates before giving up

TODO: make this handle performing a rollback of a partially completed rollout.

type ServiceDescriber

type ServiceDescriber struct {
	client.Interface
}

ServiceDescriber generates information about a service.

func (*ServiceDescriber) Describe

func (d *ServiceDescriber) Describe(namespace, name string) (string, error)

type ShortcutExpander

type ShortcutExpander struct {
	meta.RESTMapper
}

ShortcutExpander is a RESTMapper that can be used for Kubernetes resources.

func (ShortcutExpander) VersionAndKindForResource

func (e ShortcutExpander) VersionAndKindForResource(resource string) (defaultVersion, kind string, err error)

VersionAndKindForResource implements meta.RESTMapper. It expands the resource first, then invokes the wrapped mapper.

type SortableEvents

type SortableEvents []api.Event

SortableEvents implements sort.Interface for []api.Event based on the Timestamp field

func (SortableEvents) Len

func (list SortableEvents) Len() int

func (SortableEvents) Less

func (list SortableEvents) Less(i, j int) bool

func (SortableEvents) Swap

func (list SortableEvents) Swap(i, j int)

type TemplatePrinter

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

TemplatePrinter is an implementation of ResourcePrinter which formats data with a Go Template.

func NewTemplatePrinter

func NewTemplatePrinter(tmpl []byte, asVersion string, convertor runtime.ObjectConvertor) (*TemplatePrinter, error)

func (*TemplatePrinter) PrintObj

func (p *TemplatePrinter) PrintObj(obj runtime.Object, w io.Writer) error

PrintObj formats the obj with the Go Template.

type YAMLPrinter

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

YAMLPrinter is an implementation of ResourcePrinter which outputs an object as YAML. The input object is assumed to be in the internal version of an API and is converted to the given version first.

func (*YAMLPrinter) PrintObj

func (p *YAMLPrinter) PrintObj(obj runtime.Object, w io.Writer) error

PrintObj prints the data as YAML.

Directories

Path Synopsis
Package resource assists clients in dealing with RESTful objects that match the Kubernetes API conventions.
Package resource assists clients in dealing with RESTful objects that match the Kubernetes API conventions.

Jump to

Keyboard shortcuts

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