k8s

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2019 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

k8s implements Kubernetes-specific code.

SPDX-License-Identifier: MIT Copyright (c) 2019 Hadrien Chauvin

SPDX-License-Identifier: MIT Copyright (c) 2019 Hadrien Chauvin

SPDX-License-Identifier: MIT Copyright (c) 2019 Hadrien Chauvin

Index

Constants

View Source
const (
	// StackLabel is a label put on all the Kubernetes resources a stack.  This label
	// indicates ownership, and can be used for resource pruning (kubectl --prune)
	// and deletion, when the stack is removed.
	StackLabel = "warp.stack"

	// ServiceLabel is a label put on a Service resource to identify it.  Typically,
	// the service name (coming from metadata.name) contains some stack-specific
	// prefix, which makes it difficult to refer to a service by its name.
	ServiceLabel = "warp.service"

	// NameLabel is a label put on any resource to identify it.  Typically,
	// the resource name (coming from metadata.name) contains some stack-specific
	// prefix, which makes it difficult to refer to a resource by its name.
	NameLabel = "warp.name"
)

Variables

This section is empty.

Functions

func NewClient

func NewClient(cfg *config.Config) (*kubernetes.Clientset, error)

Types

type K8s

type K8s struct {
	Ports *Ports
	// contains filtered or unexported fields
}

func New

func New(cfg *config.Config) (*K8s, error)

func (*K8s) Apply

func (k8s *K8s) Apply(ctx context.Context, resourcesPath string, labelSelector string) error

func (*K8s) DeleteAll

func (k8s *K8s) DeleteAll(ctx context.Context, labelSelector string) error

func (*K8s) Gc

func (k8s *K8s) Gc(ctx context.Context, cfg *config.Config, name names.Name) error

func (*K8s) KubectlCommandContext

func (k8s *K8s) KubectlCommandContext(ctx context.Context, args ...string) (*exec.Cmd, error)

func (*K8s) KubectlLikeCommandContext

func (k8s *K8s) KubectlLikeCommandContext(ctx context.Context, command string, args ...string) (*exec.Cmd, error)

func (*K8s) Tail

func (k8s *K8s) Tail(ctx context.Context, cfg *config.Config, name names.Name) error

Tail pipes the stdout/stderr outputs of all the services of a stack.

func (*K8s) WaitForEndpoints

func (k8s *K8s) WaitForEndpoints(ctx context.Context, k8sNamespace string, name names.Name) error

WaitForEndpoints waits for all the services to have at least one ready endpoint.

func (*K8s) WaitForPods

func (k8s *K8s) WaitForPods(ctx context.Context, k8sNamespace string, name names.Name) error

WaitForPods waits for all the pods to be ready

type Labels

type Labels map[string]string

Labels maps labels to values. Combining Labels with the String function gives a convenient way to specify a Kubernetes selector.

func (Labels) String

func (lbls Labels) String() string

String converts a Labels map to a Kubernetes selector.

type Ports

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

Ports is a "singleton" to pass around port forwarding information. This singleton keeps track of all the port forwarding to 1) avoid forwarding ports in duplicate, 2) provide a single function to cancel all the port forwarding.

func (*Ports) CancelForwarding

func (ports *Ports) CancelForwarding()

CancelForwarding cancels all the port forwarding.

func (*Ports) PodPortForward

func (ports *Ports) PodPortForward(service ServiceSpec, localPort, exposedTCPPort int) error

PodPortForward forward a remote port to a fixed local port. The remote port comes from the first pod that matches a service spec.

func (*Ports) Port

func (ports *Ports) Port(service ServiceSpec, exposedTcpPort int) (int, error)

Port gives a random local port to which a remote port is forwarded. The remote port comes from the first pod that matches a service spec.

PodPortForward can be used instead to fix the local port.

type ServiceSpec

type ServiceSpec struct {
	// Namespace is the Kubernetes namespace to which the service belongs.
	Namespace string

	// Labels is a Kubernetes selector.
	Labels string
}

ServiceSpec specifies a Kubernetes service to forward from.

func (ServiceSpec) String

func (s ServiceSpec) String() string

Jump to

Keyboard shortcuts

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