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 ¶
- Variables
- func GetClientVersion(w io.Writer)
- func GetKubeClient(config *client.Config, matchVersion bool) (*client.Client, error)
- func GetVersion(w io.Writer, kubeClient client.Interface)
- func MakeParams(cmd *cobra.Command, params []GeneratorParam) map[string]string
- func ParseLabels(labelString string) map[string]string
- func SaveNamespaceInfo(path string, ns *NamespaceInfo) error
- func ValidateParams(paramSpec []GeneratorParam, params map[string]string) error
- func WatchLoop(w watch.Interface, fn func(watch.Event) error)
- type BasicReplicationController
- type Describer
- type Generator
- type GeneratorParam
- type HumanReadablePrinter
- type JSONPrinter
- type MinionDescriber
- type NamespaceInfo
- type OutputVersionMapper
- type PodDescriber
- type PodReaper
- type PreconditionError
- type ProxyServer
- type RESTClient
- type Reaper
- type ReplicationControllerDescriber
- type ReplicationControllerReaper
- type ReplicationControllerResizer
- type ResizePrecondition
- type Resizer
- type ResourcePrinter
- type ResourcePrinterFunc
- type RollingUpdater
- type ServiceDescriber
- type ServiceReaper
- type ShortcutExpander
- type SortableEvents
- type TemplatePrinter
- type VersionedPrinter
- type YAMLPrinter
Constants ¶
This section is empty.
Variables ¶
var Generators map[string]Generator = map[string]Generator{ "run-container/v1": BasicReplicationController{}, }
Generators is a global list of known generators. TODO: Dynamically create this from a list of template files?
Functions ¶
func GetClientVersion ¶
func GetKubeClient ¶
func MakeParams ¶ added in v0.9.0
func MakeParams(cmd *cobra.Command, params []GeneratorParam) map[string]string
MakeParams is a utility that creates generator parameters from a command line
func ParseLabels ¶ added in v0.9.0
TODO: extract this to a common location.
func SaveNamespaceInfo ¶
func SaveNamespaceInfo(path string, ns *NamespaceInfo) error
SaveNamespaceInfo saves a NamespaceInfo object at the specified file path.
func ValidateParams ¶ added in v0.9.0
func ValidateParams(paramSpec []GeneratorParam, params map[string]string) error
ValidateParams ensures that all required params are present in the params map
Types ¶
type BasicReplicationController ¶ added in v0.9.0
type BasicReplicationController struct{}
func (BasicReplicationController) ParamNames ¶ added in v0.9.0
func (BasicReplicationController) ParamNames() []GeneratorParam
type Describer ¶
Describer generates output for the named resource or an error if the output could not be generated.
type Generator ¶ added in v0.9.0
type Generator interface { // Generate creates an API object given a set of parameters Generate(params map[string]string) (runtime.Object, error) // ParamNames returns the list of parameters that this generator uses ParamNames() []GeneratorParam }
Generator is an interface for things that can generate API objects from input parameters.
type GeneratorParam ¶ added in v0.9.0
GeneratorParam is a parameter for a generator TODO: facilitate structured json generator input schemes
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.
type JSONPrinter ¶
type JSONPrinter struct { }
JSONPrinter is an implementation of ResourcePrinter which outputs an object as JSON.
type MinionDescriber ¶
MinionDescriber generates information about a minion.
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 OutputVersionMapper ¶ added in v0.9.0
type OutputVersionMapper struct { meta.RESTMapper OutputVersion string }
OutputVersionMapper is a RESTMapper that will prefer mappings that correspond to a preferred output version (if feasible)
func (OutputVersionMapper) RESTMapping ¶ added in v0.9.0
func (m OutputVersionMapper) RESTMapping(kind string, versions ...string) (*meta.RESTMapping, error)
RESTMapping implements meta.RESTMapper by prepending the output version to the preferred version list.
type PodDescriber ¶
PodDescriber generates information about a pod and the replication controllers that create it.
type PreconditionError ¶ added in v0.9.0
func (*PreconditionError) Error ¶ added in v0.9.0
func (pe *PreconditionError) Error() string
type ProxyServer ¶
type ProxyServer struct { httputil.ReverseProxy Port int }
ProxyServer is a http.Handler which proxies Kubernetes APIs to remote API server.
func NewProxyServer ¶
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 ¶
ReplicationControllerDescriber generates information about a replication controller and the pods it has created.
type ReplicationControllerReaper ¶ added in v0.9.1
type ReplicationControllerResizer ¶ added in v0.9.0
func (*ReplicationControllerResizer) Resize ¶ added in v0.9.0
func (resize *ReplicationControllerResizer) Resize(namespace, name string, preconditions *ResizePrecondition, newSize uint) (string, error)
type ResizePrecondition ¶ added in v0.9.0
ResizePrecondition describes a condition that must be true for the resize to take place If CurrentSize == -1, it is ignored. If CurrentResourceVersion is the empty string, it is ignored. Otherwise they must equal the values in the replication controller for it to be valid.
func (*ResizePrecondition) Validate ¶ added in v0.9.0
func (precondition *ResizePrecondition) Validate(controller *api.ReplicationController) error
Validate ensures that the preconditions match. Returns nil if they are valid, an error otherwise
type Resizer ¶ added in v0.9.0
type Resizer interface {
Resize(namespace, name string, preconditions *ResizePrecondition, newSize uint) (string, error)
}
type ResourcePrinter ¶
type ResourcePrinter interface { // Print receives a runtime 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 string) (ResourcePrinter, bool, error)
GetPrinter takes a format type, an optional format argument. It will return true if the format is generic (untyped), otherwise it will return false. The printer is agnostic to schema versions, so you must send arguments to PrintObj in the version you wish them to be shown using a VersionedPrinter (typically when generic is true).
func NewVersionedPrinter ¶ added in v0.9.0
func NewVersionedPrinter(printer ResourcePrinter, convertor runtime.ObjectConvertor, version string) ResourcePrinter
NewVersionedPrinter wraps a printer to convert objects to a known API version prior to printing.
type ResourcePrinterFunc ¶ added in v0.9.0
ResourcePrinterFunc is a function that can print objects
type RollingUpdater ¶ added in v0.9.0
type RollingUpdater struct {
// contains filtered or unexported fields
}
RollingUpdater provides methods for updating replicated pods in a predictable, fault-tolerant way.
func NewRollingUpdater ¶ added in v0.9.0
func NewRollingUpdater(namespace string, c client.Interface) *RollingUpdater
NewRollingUpdater creates a RollingUpdater from a client
func (*RollingUpdater) Update ¶ added in v0.9.0
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 ¶
ServiceDescriber generates information about a service.
type ServiceReaper ¶ added in v0.9.1
type ShortcutExpander ¶ added in v0.9.0
type ShortcutExpander struct {
meta.RESTMapper
}
ShortcutExpander is a RESTMapper that can be used for Kubernetes resources.
func (ShortcutExpander) VersionAndKindForResource ¶ added in v0.9.0
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 ¶ added in v0.8.0
SortableEvents implements sort.Interface for []api.Event based on the Timestamp field
func (SortableEvents) Len ¶ added in v0.8.0
func (list SortableEvents) Len() int
func (SortableEvents) Less ¶ added in v0.8.0
func (list SortableEvents) Less(i, j int) bool
func (SortableEvents) Swap ¶ added in v0.8.0
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) (*TemplatePrinter, error)
type VersionedPrinter ¶ added in v0.9.0
type VersionedPrinter struct {
// contains filtered or unexported fields
}
VersionedPrinter takes runtime objects and ensures they are converted to a given API version prior to being passed to a nested printer.
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.