kube

package
v2.16.9+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2020 License: Apache-2.0 Imports: 54 Imported by: 0

Documentation

Index

Constants

View Source
const MissingGetHeader = "==> MISSING\nKIND\t\tNAME\n"

MissingGetHeader is added to Get's output when a resource is not found.

View Source
const (
	// ResourcePolicyAnno is the annotation name for a resource policy
	ResourcePolicyAnno = "helm.sh/resource-policy"
)

Variables

View Source
var ErrNoObjectsVisited = goerrors.New("no objects visited")

ErrNoObjectsVisited indicates that during a visit operation, no matching objects were found.

Functions

func GetConfig

func GetConfig(context string, kubeconfig string) clientcmd.ClientConfig

GetConfig returns a Kubernetes client config for a given context.

func ResourcePolicyIsKeep

func ResourcePolicyIsKeep(annotations map[string]string) bool

ResourcePolicyIsKeep accepts a map of Kubernetes resource annotations and

returns true if the resource should be kept, otherwise false if it is safe
for Helm to delete.

Types

type Client

type Client struct {
	cmdutil.Factory
	Log func(string, ...interface{})
}

Client represents a client capable of communicating with the Kubernetes API.

func New

New creates a new Client.

func (*Client) Build

func (c *Client) Build(namespace string, reader io.Reader) (Result, error)

Build validates for Kubernetes objects and returns resource Infos from a io.Reader.

func (*Client) BuildUnstructured

func (c *Client) BuildUnstructured(namespace string, reader io.Reader) (Result, error)

BuildUnstructured reads Kubernetes objects and returns unstructured infos.

func (*Client) BuildUnstructuredTable

func (c *Client) BuildUnstructuredTable(namespace string, reader io.Reader) (Result, error)

BuildUnstructuredTable reads Kubernetes objects and returns unstructured infos as a Table. This is meant for viewing resources and displaying them in a table. This is similar to BuildUnstructured but transforms the request for table display.

func (*Client) Create

func (c *Client) Create(namespace string, reader io.Reader, timeout int64, shouldWait bool) error

Create creates Kubernetes resources from an io.reader.

Namespace will set the namespace.

func (*Client) Delete

func (c *Client) Delete(namespace string, reader io.Reader) error

Delete deletes Kubernetes resources from an io.reader.

Namespace will set the namespace.

func (*Client) DeleteWithTimeout

func (c *Client) DeleteWithTimeout(namespace string, reader io.Reader, timeout int64, shouldWait bool) error

DeleteWithTimeout deletes Kubernetes resources from an io.reader. If shouldWait is true, the function will wait for all resources to be deleted from etcd before returning, or when the timeout has expired.

Namespace will set the namespace.

func (*Client) Get

func (c *Client) Get(namespace string, reader io.Reader) (string, error)

Get gets Kubernetes resources as pretty-printed string.

Namespace will set the namespace.

func (*Client) GetPodLogs

func (c *Client) GetPodLogs(name, ns string) (io.ReadCloser, error)

GetPodLogs takes pod name and namespace and returns the current logs (streaming is NOT enabled).

func (*Client) Update deprecated

func (c *Client) Update(namespace string, originalReader, targetReader io.Reader, force bool, recreate bool, timeout int64, shouldWait bool) error

Update reads the current configuration and a target configuration from io.reader and creates resources that don't already exist, updates resources that have been modified in the target configuration and deletes resources from the current configuration that are not present in the target configuration.

Namespace will set the namespaces.

Deprecated: use UpdateWithOptions instead.

func (*Client) UpdateWithOptions

func (c *Client) UpdateWithOptions(namespace string, originalReader, targetReader io.Reader, opts UpdateOptions) error

UpdateWithOptions reads the current configuration and a target configuration from io.reader and creates resources that don't already exist, updates resources that have been modified in the target configuration and deletes resources from the current configuration that are not present in the target configuration.

Namespace will set the namespaces. UpdateOptions provides additional parameters to control update behavior.

func (*Client) Validate

func (c *Client) Validate(namespace string, reader io.Reader) error

Validate reads Kubernetes manifests and validates the content.

This function does not actually do schema validation of manifests. Adding validation now breaks existing clients of helm: https://github.com/helm/helm/issues/5750

func (*Client) WaitAndGetCompletedPodPhase

func (c *Client) WaitAndGetCompletedPodPhase(namespace string, reader io.Reader, timeout time.Duration) (v1.PodPhase, error)

WaitAndGetCompletedPodPhase waits up to a timeout until a pod enters a completed phase and returns said phase (PodSucceeded or PodFailed qualify).

func (*Client) WaitUntilCRDEstablished

func (c *Client) WaitUntilCRDEstablished(reader io.Reader, timeout time.Duration) error

WaitUntilCRDEstablished polls the given CRD until it reaches the established state. A CRD needs to reach the established state before CRs can be created.

If a naming conflict condition is found, this function will return an error.

func (*Client) WatchUntilReady

func (c *Client) WatchUntilReady(namespace string, reader io.Reader, timeout int64, shouldWait bool) error

WatchUntilReady watches the resource given in the reader, and waits until it is ready.

This function is mainly for hook implementations. It watches for a resource to hit a particular milestone. The milestone depends on the Kind.

For most kinds, it checks to see if the resource is marked as Added or Modified by the Kubernetes event stream. For some kinds, it does more:

  • Jobs: A job is marked "Ready" when it has successfully completed. This is ascertained by watching the Status fields in a job's output.

Handling for other kinds will be added as necessary.

type ResourceActorFunc

type ResourceActorFunc func(*resource.Info) error

ResourceActorFunc performs an action on a single resource.

type Result

type Result []*resource.Info

Result provides convenience methods for comparing collections of Infos.

func (*Result) Append

func (r *Result) Append(val *resource.Info)

Append adds an Info to the Result.

func (Result) Contains

func (r Result) Contains(info *resource.Info) bool

Contains checks to see if an object exists.

func (Result) Difference

func (r Result) Difference(rs Result) Result

Difference will return a new Result with objects not contained in rs.

func (Result) Filter

func (r Result) Filter(fn func(*resource.Info) bool) Result

Filter returns a new Result with Infos that satisfy the predicate fn.

func (Result) Get

func (r Result) Get(info *resource.Info) *resource.Info

Get returns the Info from the result that matches the name and kind.

func (Result) Intersect

func (r Result) Intersect(rs Result) Result

Intersect will return a new Result with objects contained in both Results.

func (Result) Visit

func (r Result) Visit(fn resource.VisitorFunc) error

Visit implements resource.Visitor.

type Tunnel

type Tunnel struct {
	Local     int
	Remote    int
	Namespace string
	PodName   string
	Out       io.Writer
	// contains filtered or unexported fields
}

Tunnel describes a ssh-like tunnel to a kubernetes pod

func NewTunnel

func NewTunnel(client rest.Interface, config *rest.Config, namespace, podName string, remote int) *Tunnel

NewTunnel creates a new tunnel

func (*Tunnel) Close

func (t *Tunnel) Close()

Close disconnects a tunnel connection

func (*Tunnel) ForwardPort

func (t *Tunnel) ForwardPort() error

ForwardPort opens a tunnel to a kubernetes pod

type UpdateOptions

type UpdateOptions struct {
	Force      bool
	Recreate   bool
	Timeout    int64
	ShouldWait bool
	// Allow deletion of new resources created in this update when update failed
	CleanupOnFail bool
}

UpdateOptions provides options to control update behavior

Jump to

Keyboard shortcuts

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