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
- Variables
- func AbortRollingUpdate(c *RollingUpdaterConfig) error
- func AddDeploymentKeyToReplicationController(oldRc *api.ReplicationController, client client.Interface, ...) (*api.ReplicationController, error)
- func AddJsonFilenameFlag(cmd *cobra.Command, value *[]string, usage string)
- func CreateNewControllerFromCurrentController(c *client.Client, namespace, oldName, newName, image, deploymentKey string) (*api.ReplicationController, error)
- func DescribableResources() []string
- func DescribeEvents(el *api.EventList, w io.Writer)
- func DescribeLimitRanges(limitRanges *api.LimitRangeList, w io.Writer)
- func DescribeResourceQuotas(quotas *api.ResourceQuotaList, w io.Writer)
- func FindSourceController(r client.ReplicationControllersNamespacer, namespace, name string) (*api.ReplicationController, error)
- func GetBool(params map[string]string, key string, defValue bool) (bool, error)
- func GetClientVersion(w io.Writer)
- func GetModifiedConfiguration(info *resource.Info, annotate bool) ([]byte, error)
- func GetNewTabWriter(output io.Writer) *tabwriter.Writer
- func GetNextControllerAnnotation(rc *api.ReplicationController) (string, bool)
- func GetOriginalConfiguration(info *resource.Info) ([]byte, error)
- func GetServerVersion(w io.Writer, kubeClient client.Interface)
- func GetSwaggerSchema(apiVer string, kubeClient client.Interface) (*swagger.ApiDeclaration, error)
- func HandleResourceRequirements(params map[string]string) (api.ResourceRequirements, error)
- func IsNoSuchReaperError(err error) bool
- func IsZero(i interface{}) bool
- func LoadExistingNextReplicationController(c client.ReplicationControllersNamespacer, namespace, newName string) (*api.ReplicationController, error)
- func MakeLabels(labels map[string]string) string
- func MakeParams(cmd *cobra.Command, params []GeneratorParam) map[string]interface{}
- func MakeRegexpArray(str string) ([]*regexp.Regexp, error)
- func MakeRegexpArrayOrDie(str string) []*regexp.Regexp
- func ParseLabels(labelSpec interface{}) (map[string]string, error)
- func PrintModelDescription(inModel string, fieldsPath []string, w io.Writer, ...) error
- func Rename(c client.ReplicationControllersNamespacer, rc *api.ReplicationController, ...) error
- func ScaleCondition(r Scaler, precondition *ScalePrecondition, namespace, name string, count uint) wait.ConditionFunc
- func SetNextControllerAnnotation(rc *api.ReplicationController, name string)
- func SetOriginalConfiguration(info *resource.Info, original []byte) error
- func SplitAndParseResourceRequest(inResource string, mapper meta.RESTMapper) (string, []string, error)
- func UpdateApplyAnnotation(info *resource.Info) error
- func UpdateExistingReplicationController(c client.Interface, oldRc *api.ReplicationController, ...) (*api.ReplicationController, error)
- func ValidateParams(paramSpec []GeneratorParam, params map[string]interface{}) error
- func WatchLoop(w watch.Interface, fn func(watch.Event) error)
- type BasicPod
- type BasicReplicationController
- type Column
- type ControllerScaleError
- type ControllerScaleErrorType
- type CustomColumnsPrinter
- type DaemonSetDescriber
- type DaemonSetReaper
- type DeploymentDescriber
- type Describer
- type Describers
- type ErrNoDescriber
- type FilterServer
- type Generator
- type GeneratorParam
- type HorizontalPodAutoscalerDescriber
- type HorizontalPodAutoscalerV1Beta1
- type HumanReadablePrinter
- type JSONPathPrinter
- type JSONPrinter
- type JobDescriber
- type JobReaper
- type JobScaler
- type LimitRangeDescriber
- type NamePrinter
- type NamespaceDescriber
- type NamespaceInfo
- type NoSuchReaperError
- type NodeDescriber
- type ObjectDescriber
- type OutputVersionMapper
- type PersistentVolumeClaimDescriber
- type PersistentVolumeDescriber
- type PodDescriber
- type PodReaper
- type PreconditionError
- type ProxyServer
- type RESTClient
- type Reaper
- type ReplicationControllerDescriber
- type ReplicationControllerReaper
- type ReplicationControllerScaler
- type ResourcePrinter
- type ResourcePrinterFunc
- type ResourceQuotaDescriber
- type RetryParams
- type RollingUpdater
- type RollingUpdaterCleanupPolicy
- type RollingUpdaterConfig
- type RuntimeSort
- type ScalePrecondition
- type Scaler
- type SecretDescriber
- type ServiceAccountDescriber
- type ServiceDescriber
- type ServiceGeneratorV1
- type ServiceGeneratorV2
- type ServiceReaper
- type ShortcutExpander
- type SortableEvents
- type SortableResourceNames
- type SortingPrinter
- type TemplatePrinter
- type VersionedPrinter
- type YAMLPrinter
Constants ¶
const ( DefaultHostAcceptRE = "^localhost$,^127\\.0\\.0\\.1$,^\\[::1\\]$" DefaultPathAcceptRE = "^/.*" DefaultPathRejectRE = "^/api/.*/exec,^/api/.*/run,^/api/.*/attach" DefaultMethodRejectRE = "POST,PUT,PATCH" )
const ( Interval = time.Second * 1 Timeout = time.Minute * 5 )
const LastAppliedConfigAnnotation = kubectlAnnotationPrefix + "last-applied-configuration"
LastAppliedConfigAnnotation is the annotation used to store the previous configuration of a resource for use in a three way diff by UpdateApplyAnnotation.
const MaxRetries = 3
Variables ¶
var ( // The reverse proxy will periodically flush the io writer at this frequency. // Only matters for long poll connections like the one used to watch. With an // interval of 0 the reverse proxy will buffer content sent on any connection // with transfer-encoding=chunked. // TODO: Flush after each chunk so the client doesn't suffer a 100ms latency per // watch event. ReverseProxyFlushInterval = 100 * time.Millisecond )
Functions ¶
func AbortRollingUpdate ¶
func AbortRollingUpdate(c *RollingUpdaterConfig) error
func AddDeploymentKeyToReplicationController ¶
func AddDeploymentKeyToReplicationController(oldRc *api.ReplicationController, client client.Interface, deploymentKey, deploymentValue, namespace string, out io.Writer) (*api.ReplicationController, error)
func AddJsonFilenameFlag ¶
func DescribableResources ¶
func DescribableResources() []string
List of all resource types we can describe
func DescribeLimitRanges ¶
func DescribeLimitRanges(limitRanges *api.LimitRangeList, w io.Writer)
DescribeLimitRanges merges a set of limit range items into a single tabular description
func DescribeResourceQuotas ¶
func DescribeResourceQuotas(quotas *api.ResourceQuotaList, w io.Writer)
DescribeResourceQuotas merges a set of quota items into a single tabular description of all quotas
func FindSourceController ¶
func FindSourceController(r client.ReplicationControllersNamespacer, namespace, name string) (*api.ReplicationController, error)
func GetClientVersion ¶
func GetModifiedConfiguration ¶
GetModifiedConfiguration retrieves the modified configuration of the object. If annotate is true, it embeds the result as an anotation in the modified configuration. If an object was read from the command input, it will use that version of the object. Otherwise, it will use the version from the server.
func GetNewTabWriter ¶
GetNewTabWriter returns a tabwriter that translates tabbed columns in input into properly aligned text.
func GetNextControllerAnnotation ¶
func GetNextControllerAnnotation(rc *api.ReplicationController) (string, bool)
func GetOriginalConfiguration ¶
GetOriginalConfiguration retrieves the original configuration of the object from the annotation, or nil if no annotation was found.
func GetSwaggerSchema ¶
GetSwaggerSchema returns the swagger spec from master
func HandleResourceRequirements ¶
func HandleResourceRequirements(params map[string]string) (api.ResourceRequirements, error)
HandleResourceRequirements parses the limits and requests parameters if specified
func IsNoSuchReaperError ¶
func LoadExistingNextReplicationController ¶
func LoadExistingNextReplicationController(c client.ReplicationControllersNamespacer, namespace, newName string) (*api.ReplicationController, error)
func MakeLabels ¶
func MakeParams ¶
func MakeParams(cmd *cobra.Command, params []GeneratorParam) map[string]interface{}
MakeParams is a utility that creates generator parameters from a command line
func MakeRegexpArray ¶
Splits a comma separated list of regexps into a array of Regexp objects.
func MakeRegexpArrayOrDie ¶
func ParseLabels ¶
ParseLabels turns a string representation of a label set into a map[string]string
func PrintModelDescription ¶
func PrintModelDescription(inModel string, fieldsPath []string, w io.Writer, swaggerSchema *swagger.ApiDeclaration, r bool) error
PrintModelDescription prints the description of a specific model or dot path
func Rename ¶
func Rename(c client.ReplicationControllersNamespacer, rc *api.ReplicationController, newName string) error
func ScaleCondition ¶
func ScaleCondition(r Scaler, precondition *ScalePrecondition, namespace, name string, count uint) wait.ConditionFunc
ScaleCondition is a closure around Scale that facilitates retries via util.wait
func SetNextControllerAnnotation ¶
func SetNextControllerAnnotation(rc *api.ReplicationController, name string)
func SetOriginalConfiguration ¶
SetOriginalConfiguration sets the original configuration of the object as the annotation on the object for later use in computing a three way patch.
func SplitAndParseResourceRequest ¶
func SplitAndParseResourceRequest(inResource string, mapper meta.RESTMapper) (string, []string, error)
SplitAndParseResourceRequest separates the users input into a model and fields
func UpdateApplyAnnotation ¶
If the last applied configuration annotation is already present, then UpdateApplyAnnotation gets the modified configuration of the object, without embedding it again, and then sets it on the object as the annotation. Otherwise, it does nothing.
func UpdateExistingReplicationController ¶
func UpdateExistingReplicationController(c client.Interface, oldRc *api.ReplicationController, namespace, newName, deploymentKey, deploymentValue string, out io.Writer) (*api.ReplicationController, error)
func ValidateParams ¶
func ValidateParams(paramSpec []GeneratorParam, params map[string]interface{}) error
ValidateParams ensures that all required params are present in the params map
Types ¶
type BasicPod ¶
type BasicPod struct{}
func (BasicPod) ParamNames ¶
func (BasicPod) ParamNames() []GeneratorParam
type BasicReplicationController ¶
type BasicReplicationController struct{}
func (BasicReplicationController) Generate ¶
func (BasicReplicationController) Generate(genericParams map[string]interface{}) (runtime.Object, error)
func (BasicReplicationController) ParamNames ¶
func (BasicReplicationController) ParamNames() []GeneratorParam
type Column ¶
type Column struct { // The header to print above the column, general style is ALL_CAPS Header string // The pointer to the field in the object to print in JSONPath form // e.g. {.ObjectMeta.Name}, see pkg/util/jsonpath for more details. FieldSpec string }
Column represents a user specified column
type ControllerScaleError ¶
type ControllerScaleError struct { FailureType ControllerScaleErrorType ResourceVersion string ActualError error }
A ControllerScaleError is returned when a scale request passes preconditions but fails to actually scale the controller.
func (ControllerScaleError) Error ¶
func (c ControllerScaleError) Error() string
type ControllerScaleErrorType ¶
type ControllerScaleErrorType int
const ( ControllerScaleGetFailure ControllerScaleErrorType = iota ControllerScaleUpdateFailure ControllerScaleUpdateInvalidFailure )
type CustomColumnsPrinter ¶
type CustomColumnsPrinter struct {
Columns []Column
}
CustomColumnPrinter is a printer that knows how to print arbitrary columns of data from templates specified in the `Columns` array
func NewCustomColumnsPrinterFromSpec ¶
func NewCustomColumnsPrinterFromSpec(spec string) (*CustomColumnsPrinter, error)
NewCustomColumnsPrinterFromSpec creates a custom columns printer from a comma separated list of <header>:<jsonpath-field-spec> pairs. e.g. NAME:metadata.name,API_VERSION:apiVersion creates a printer that prints:
NAME API_VERSION foo bar
func NewCustomColumnsPrinterFromTemplate ¶
func NewCustomColumnsPrinterFromTemplate(templateReader io.Reader) (*CustomColumnsPrinter, error)
NewCustomColumnsPrinterFromTemplate creates a custom columns printer from a template stream. The template is expected to consist of two lines, whitespace separated. The first line is the header line, the second line is the jsonpath field spec For example the template below: NAME API_VERSION {metadata.name} {apiVersion}
func (*CustomColumnsPrinter) HandledResources ¶
func (s *CustomColumnsPrinter) HandledResources() []string
type DaemonSetDescriber ¶
DaemonSetDescriber generates information about a daemon set and the pods it has created.
type DaemonSetReaper ¶
func (*DaemonSetReaper) Stop ¶
func (reaper *DaemonSetReaper) Stop(namespace, name string, timeout time.Duration, gracePeriod *api.DeleteOptions) (string, error)
type DeploymentDescriber ¶
DeploymentDescriber generates information about a deployment.
type Describer ¶
Describer generates output for the named resource or an error if the output could not be generated. Implementors typically abstract the retrieval of the named object from a remote server.
type Describers ¶
type Describers struct {
// contains filtered or unexported fields
}
Describers implements ObjectDescriber against functions registered via Add. Those functions can be strongly typed. Types are exactly matched (no conversion or assignable checks).
func (*Describers) Add ¶
func (d *Describers) Add(fns ...interface{}) error
Add adds one or more describer functions to the Describer. The passed function must match the signature:
func(...) (string, error)
Any number of arguments may be provided.
func (*Describers) DescribeObject ¶
func (d *Describers) DescribeObject(exact interface{}, extra ...interface{}) (string, error)
DescribeObject implements ObjectDescriber and will attempt to print the provided object to a string, if at least one describer function has been registered with the exact types passed, or if any describer can print the exact object in its first argument (the remainder will be provided empty values). If no function registered with Add can satisfy the passed objects, an ErrNoDescriber will be returned TODO: reorder and partial match extra.
type ErrNoDescriber ¶
type ErrNoDescriber struct {
Types []string
}
ErrNoDescriber is a structured error indicating the provided object or objects cannot be described.
func (ErrNoDescriber) Error ¶
func (e ErrNoDescriber) Error() string
Error implements the error interface.
type FilterServer ¶
type FilterServer struct { // Only paths that match this regexp will be accepted AcceptPaths []*regexp.Regexp // Paths that match this regexp will be rejected, even if they match the above RejectPaths []*regexp.Regexp // Hosts are required to match this list of regexp AcceptHosts []*regexp.Regexp // Methods that match this regexp are rejected RejectMethods []*regexp.Regexp // contains filtered or unexported fields }
FilterServer rejects requests which don't match one of the specified regular expressions
func (*FilterServer) HandlerFor ¶
func (f *FilterServer) HandlerFor(delegate http.Handler) *FilterServer
Make a copy of f which passes requests along to the new delegate.
func (*FilterServer) ServeHTTP ¶
func (f *FilterServer) ServeHTTP(rw http.ResponseWriter, req *http.Request)
type Generator ¶
type Generator interface { // Generate creates an API object given a set of parameters Generate(params map[string]interface{}) (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 ¶
GeneratorParam is a parameter for a generator TODO: facilitate structured json generator input schemes
type HorizontalPodAutoscalerDescriber ¶
type HorizontalPodAutoscalerDescriber struct {
// contains filtered or unexported fields
}
HorizontalPodAutoscalerDescriber generates information about a horizontal pod autoscaler.
type HorizontalPodAutoscalerV1Beta1 ¶
type HorizontalPodAutoscalerV1Beta1 struct{}
func (HorizontalPodAutoscalerV1Beta1) Generate ¶
func (HorizontalPodAutoscalerV1Beta1) Generate(genericParams map[string]interface{}) (runtime.Object, error)
func (HorizontalPodAutoscalerV1Beta1) ParamNames ¶
func (HorizontalPodAutoscalerV1Beta1) ParamNames() []GeneratorParam
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 received from watches.
func NewHumanReadablePrinter ¶
func NewHumanReadablePrinter(noHeaders, withNamespace bool, wide bool, showAll bool, columnLabels []string) *HumanReadablePrinter
NewHumanReadablePrinter creates a HumanReadablePrinter.
func (*HumanReadablePrinter) HandledResources ¶
func (h *HumanReadablePrinter) HandledResources() []string
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. See validatePrintHandlerFunc for required method signature.
type JSONPathPrinter ¶
JSONPathPrinter is an implementation of ResourcePrinter which formats data with jsonpath expression.
func NewJSONPathPrinter ¶
func NewJSONPathPrinter(tmpl string) (*JSONPathPrinter, error)
func (*JSONPathPrinter) HandledResources ¶
func (p *JSONPathPrinter) HandledResources() []string
TODO: implement HandledResources()
type JSONPrinter ¶
type JSONPrinter struct { }
JSONPrinter is an implementation of ResourcePrinter which outputs an object as JSON.
func (*JSONPrinter) HandledResources ¶
func (p *JSONPrinter) HandledResources() []string
TODO: implement HandledResources()
type JobDescriber ¶
type JobDescriber struct {
// contains filtered or unexported fields
}
JobDescriber generates information about a job and the pods it has created.
type JobScaler ¶
type JobScaler struct {
// contains filtered or unexported fields
}
func (*JobScaler) Scale ¶
func (scaler *JobScaler) Scale(namespace, name string, newSize uint, preconditions *ScalePrecondition, retry, waitForReplicas *RetryParams) error
Scale updates a Job to a new size, with optional precondition check (if preconditions is not nil), optional retries (if retry is not nil), and then optionally waits for parallelism to reach desired number, which can be less than requested based on job's current progress.
func (*JobScaler) ScaleSimple ¶
func (scaler *JobScaler) ScaleSimple(namespace, name string, preconditions *ScalePrecondition, newSize uint) error
ScaleSimple is responsible for updating job's parallelism.
type LimitRangeDescriber ¶
LimitRangeDescriber generates information about a limit range
type NamePrinter ¶
type NamePrinter struct { }
NamePrinter is an implementation of ResourcePrinter which outputs "resource/name" pair of an object.
func (*NamePrinter) HandledResources ¶
func (p *NamePrinter) HandledResources() []string
TODO: implement HandledResources()
type NamespaceDescriber ¶
NamespaceDescriber generates information about a namespace
type NamespaceInfo ¶
type NamespaceInfo struct {
Namespace string
}
type NoSuchReaperError ¶
type NoSuchReaperError struct {
// contains filtered or unexported fields
}
func (*NoSuchReaperError) Error ¶
func (n *NoSuchReaperError) Error() string
type NodeDescriber ¶
NodeDescriber generates information about a node.
type ObjectDescriber ¶
type ObjectDescriber interface {
DescribeObject(object interface{}, extra ...interface{}) (output string, err error)
}
ObjectDescriber is an interface for displaying arbitrary objects with extra information. Use when an object is in hand (on disk, or already retrieved). Implementors may ignore the additional information passed on extra, or use it by default. ObjectDescribers may return ErrNoDescriber if no suitable describer is found.
var DefaultObjectDescriber ObjectDescriber
DefaultObjectDescriber can describe the default Kubernetes objects.
type OutputVersionMapper ¶
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 ¶
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 ¶
A PreconditionError is returned when a replication controller fails to match the scale preconditions passed to kubectl.
func (PreconditionError) Error ¶
func (pe PreconditionError) Error() string
type ProxyServer ¶
type ProxyServer struct {
// contains filtered or unexported fields
}
ProxyServer is a http.Handler which proxies Kubernetes APIs to remote API server.
func NewProxyServer ¶
func NewProxyServer(filebase string, apiProxyPrefix string, staticPrefix string, filter *FilterServer, cfg *client.Config) (*ProxyServer, error)
NewProxyServer creates and installs a new ProxyServer. It automatically registers the created ProxyServer to http.DefaultServeMux. 'filter', if non-nil, protects requests to the api only.
func (*ProxyServer) ListenUnix ¶
func (s *ProxyServer) ListenUnix(path string) (net.Listener, error)
ListenUnix does net.Listen for a unix socket
func (*ProxyServer) ServeOnListener ¶
func (s *ProxyServer) ServeOnListener(l net.Listener) error
Serve starts the server using given listener, loops forever.
type RESTClient ¶
type RESTClient interface { Get() *client.Request Post() *client.Request Patch(api.PatchType) *client.Request Delete() *client.Request Put() *client.Request }
RESTClient is a client helper for dealing with RESTful resources in a generic way.
type Reaper ¶
type Reaper interface {
Stop(namespace, name string, timeout time.Duration, gracePeriod *api.DeleteOptions) (string, error)
}
A Reaper handles terminating an object as gracefully as possible. timeout is how long we'll wait for the termination to be successful gracePeriod is time given to an API object for it to delete itself cleanly (e.g. pod shutdown)
type ReplicationControllerDescriber ¶
ReplicationControllerDescriber generates information about a replication controller and the pods it has created.
type ReplicationControllerReaper ¶
type ReplicationControllerReaper struct { client.Interface // contains filtered or unexported fields }
func (*ReplicationControllerReaper) Stop ¶
func (reaper *ReplicationControllerReaper) Stop(namespace, name string, timeout time.Duration, gracePeriod *api.DeleteOptions) (string, error)
type ReplicationControllerScaler ¶
type ReplicationControllerScaler struct {
// contains filtered or unexported fields
}
func (*ReplicationControllerScaler) Scale ¶
func (scaler *ReplicationControllerScaler) Scale(namespace, name string, newSize uint, preconditions *ScalePrecondition, retry, waitForReplicas *RetryParams) error
Scale updates a ReplicationController to a new size, with optional precondition check (if preconditions is not nil), optional retries (if retry is not nil), and then optionally waits for it's replica count to reach the new value (if wait is not nil).
func (*ReplicationControllerScaler) ScaleSimple ¶
func (scaler *ReplicationControllerScaler) ScaleSimple(namespace, name string, preconditions *ScalePrecondition, newSize uint) 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 HandledResources() []string }
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 ¶
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 ¶
ResourcePrinterFunc is a function that can print objects
func (ResourcePrinterFunc) HandledResources ¶
func (fn ResourcePrinterFunc) HandledResources() []string
TODO: implement HandledResources()
type ResourceQuotaDescriber ¶
ResourceQuotaDescriber generates information about a resource quota
type RetryParams ¶
RetryParams encapsulates the retry parameters used by kubectl's scaler.
func NewRetryParams ¶
func NewRetryParams(interval, timeout time.Duration) *RetryParams
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, client client.Interface) *RollingUpdater
NewRollingUpdater creates a RollingUpdater from a client.
func (*RollingUpdater) Update ¶
func (r *RollingUpdater) Update(config *RollingUpdaterConfig) error
Update all pods for a ReplicationController (oldRc) by creating a new controller (newRc) with 0 replicas, and synchronously scaling oldRc and newRc until oldRc has 0 replicas and newRc has the original # of desired replicas. Cleanup occurs based on a RollingUpdaterCleanupPolicy.
Each interval, the updater will attempt to make progress however it can without violating any availability constraints defined by the config. This means the amount scaled up or down each interval will vary based on the timeliness of readiness and the updater will always try to make progress, even slowly.
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.
A scaling event (either up or down) is considered progress; if no progress is made within the config.Timeout, an error is returned.
TODO: make this handle performing a rollback of a partially completed rollout.
type RollingUpdaterCleanupPolicy ¶
type RollingUpdaterCleanupPolicy string
RollingUpdaterCleanupPolicy is a cleanup action to take after the deployment is complete.
const ( // DeleteRollingUpdateCleanupPolicy means delete the old controller. DeleteRollingUpdateCleanupPolicy RollingUpdaterCleanupPolicy = "Delete" // PreserveRollingUpdateCleanupPolicy means keep the old controller. PreserveRollingUpdateCleanupPolicy RollingUpdaterCleanupPolicy = "Preserve" // RenameRollingUpdateCleanupPolicy means delete the old controller, and rename // the new controller to the name of the old controller. RenameRollingUpdateCleanupPolicy RollingUpdaterCleanupPolicy = "Rename" )
type RollingUpdaterConfig ¶
type RollingUpdaterConfig struct { // Out is a writer for progress output. Out io.Writer // OldRC is an existing controller to be replaced. OldRc *api.ReplicationController // NewRc is a controller that will take ownership of updated pods (will be // created if needed). NewRc *api.ReplicationController // UpdatePeriod is the time to wait between individual pod updates. UpdatePeriod time.Duration // Interval is the time to wait between polling controller status after // update. Interval time.Duration // Timeout is the time to wait for controller updates before giving up. Timeout time.Duration // CleanupPolicy defines the cleanup action to take after the deployment is // complete. CleanupPolicy RollingUpdaterCleanupPolicy // Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). // Absolute number is calculated from percentage by rounding up. // This can not be 0 if MaxSurge is 0. // By default, a fixed value of 1 is used. // Example: when this is set to 30%, the old RC can be scaled down to 70% of desired pods // immediately when the rolling update starts. Once new pods are ready, old RC // can be scaled down further, followed by scaling up the new RC, ensuring // that the total number of pods available at all times during the update is at // least 70% of desired pods. MaxUnavailable util.IntOrString // MaxSurge is the maximum number of pods that can be scheduled above the desired number of pods. // Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). // This can not be 0 if MaxUnavailable is 0. // Absolute number is calculated from percentage by rounding up. // By default, a value of 1 is used. // Example: when this is set to 30%, the new RC can be scaled up immediately // when the rolling update starts, such that the total number of old and new pods do not exceed // 130% of desired pods. Once old pods have been killed, new RC can be scaled up // further, ensuring that total number of pods running at any time during // the update is atmost 130% of desired pods. MaxSurge util.IntOrString }
RollingUpdaterConfig is the configuration for a rolling deployment process.
type RuntimeSort ¶
type RuntimeSort struct {
// contains filtered or unexported fields
}
RuntimeSort is an implementation of the golang sort interface that knows how to sort lists of runtime.Object
func (*RuntimeSort) Len ¶
func (r *RuntimeSort) Len() int
func (*RuntimeSort) Less ¶
func (r *RuntimeSort) Less(i, j int) bool
func (*RuntimeSort) Swap ¶
func (r *RuntimeSort) Swap(i, j int)
type ScalePrecondition ¶
ScalePrecondition describes a condition that must be true for the scale 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 (*ScalePrecondition) ValidateJob ¶
func (precondition *ScalePrecondition) ValidateJob(job *extensions.Job) error
ValidateJob ensures that the preconditions match. Returns nil if they are valid, an error otherwise
func (*ScalePrecondition) ValidateReplicationController ¶
func (precondition *ScalePrecondition) ValidateReplicationController(controller *api.ReplicationController) error
ValidateReplicationController ensures that the preconditions match. Returns nil if they are valid, an error otherwise
type Scaler ¶
type Scaler interface { // Scale scales the named resource after checking preconditions. It optionally // retries in the event of resource version mismatch (if retry is not nil), // and optionally waits until the status of the resource matches newSize (if wait is not nil) Scale(namespace, name string, newSize uint, preconditions *ScalePrecondition, retry, wait *RetryParams) error // ScaleSimple does a simple one-shot attempt at scaling - not useful on it's own, but // a necessary building block for Scale ScaleSimple(namespace, name string, preconditions *ScalePrecondition, newSize uint) error }
type SecretDescriber ¶
SecretDescriber generates information about a secret
type ServiceAccountDescriber ¶
ServiceAccountDescriber generates information about a service.
type ServiceDescriber ¶
ServiceDescriber generates information about a service.
type ServiceGeneratorV1 ¶
type ServiceGeneratorV1 struct{}
The only difference between ServiceGeneratorV1 and V2 is that the service port is named "default" in V1, while it is left unnamed in V2.
func (ServiceGeneratorV1) Generate ¶
func (ServiceGeneratorV1) Generate(params map[string]interface{}) (runtime.Object, error)
func (ServiceGeneratorV1) ParamNames ¶
func (ServiceGeneratorV1) ParamNames() []GeneratorParam
type ServiceGeneratorV2 ¶
type ServiceGeneratorV2 struct{}
func (ServiceGeneratorV2) Generate ¶
func (ServiceGeneratorV2) Generate(params map[string]interface{}) (runtime.Object, error)
func (ServiceGeneratorV2) ParamNames ¶
func (ServiceGeneratorV2) ParamNames() []GeneratorParam
type ServiceReaper ¶
func (*ServiceReaper) Stop ¶
func (reaper *ServiceReaper) Stop(namespace, name string, timeout time.Duration, gracePeriod *api.DeleteOptions) (string, error)
type ShortcutExpander ¶
type ShortcutExpander struct {
meta.RESTMapper
}
ShortcutExpander is a RESTMapper that can be used for Kubernetes resources.
func (ShortcutExpander) ResourceIsValid ¶
func (e ShortcutExpander) ResourceIsValid(resource string) bool
ResourceIsValid takes a string (kind) and checks if it's a valid resource. It expands the resource first, then invokes the wrapped mapper.
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 ¶
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 SortableResourceNames ¶
type SortableResourceNames []api.ResourceName
func (SortableResourceNames) Len ¶
func (list SortableResourceNames) Len() int
func (SortableResourceNames) Less ¶
func (list SortableResourceNames) Less(i, j int) bool
func (SortableResourceNames) Swap ¶
func (list SortableResourceNames) Swap(i, j int)
type SortingPrinter ¶
type SortingPrinter struct { SortField string Delegate ResourcePrinter }
Sorting printer sorts list types before delegating to another printer. Non-list types are simply passed through
func (*SortingPrinter) HandledResources ¶
func (p *SortingPrinter) HandledResources() []string
TODO: implement HandledResources()
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)
func (*TemplatePrinter) HandledResources ¶
func (p *TemplatePrinter) HandledResources() []string
TODO: implement HandledResources()
type VersionedPrinter ¶
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.
func (*VersionedPrinter) HandledResources ¶
func (p *VersionedPrinter) HandledResources() []string
TODO: implement HandledResources()
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) HandledResources ¶
func (p *YAMLPrinter) HandledResources() []string
TODO: implement HandledResources()
Source Files ¶
- apply.go
- autoscale.go
- bash_comp_utils.go
- custom_column_printer.go
- describe.go
- doc.go
- explain.go
- generate.go
- interfaces.go
- kubectl.go
- proxy_server.go
- resource_printer.go
- rolling_updater.go
- run.go
- scale.go
- service.go
- sorted_event_list.go
- sorted_resource_name_list.go
- sorting_printer.go
- stop.go
- version.go
- watchloop.go
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. |