kubectl

package
v1.1.50 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2024 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Container added in v1.0.55

type Container struct {
	Pod       string
	Namespace string
	Name      string
}

type Kubectl

type Kubectl interface {
	// ShutDown downscales all statefulsets and deployments in the environment to 0 replicas
	ShutDown(env terra.Environment) error
	// DeletePVCs will delete all persistent volume claims in the environment
	DeletePVCs(env terra.Environment) error
	// DeleteNamespace will delete the environment's namespace
	DeleteNamespace(env terra.Environment) error
	// CreateNamespace will create the environment's namespace
	CreateNamespace(env terra.Environment) error
	// Logs runs `kubectl logs` against the given Kubectx with given parameters
	Logs(ktx kubecfg.Kubectx, podSelector map[string]string, option ...LogsOption) error
	// Exec runs `kubectl exec` for the given Kubectx and pod with given parameters
	Exec(ktx kubecfg.Kubectx, container Container, command []string, opts ...shell.RunOption) error
	// ExecInteractive runs `kubectl exec` with stdin/stdout/stderr connected to local OS stdout/stdin/stderr
	ExecInteractive(ktx kubecfg.Kubectx, container Container, command []string) error
	// PortForward runs `kubectl port-forward` and returns the forwarding local port, a callback to stop forwarding, and
	// a possible error if the command failed.
	// The targetResource should be of the form `[pods|deployment|replicaset|service]/<name>`, like `service/sam-postgres-service`.
	PortForward(targetRelease terra.Release, targetResource string, targetPort int) (int, func() error, error)
}

Kubectl is a golang interface for executing `kubectl` commands

func New

func New(shellRunner shell.Runner, kubeconfig kubecfg.Kubeconfig) Kubectl

type LogsOption

type LogsOption func(options *LogsOptions)

type LogsOptions

type LogsOptions struct {
	// Writer optional callback that should return a writer where a given container's logs should be streamed
	// If nil, logs are streamed to stdout
	Writer io.Writer
	// ContainerName optional container name to specify with -c
	ContainerName string
	// MaxLines maximum number of log lines to retrieve
	MaxLines int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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