cluster

package
v0.0.0-...-e3addb7 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	K3sVersion1_26 = "v1.26.2-k3s1"
	K3sVersion1_28 = "v1.28.2-k3s1"
)

k3s versions warning: k3s versions are tagged with a `+` separator before `k3s1`, but k3s images use `-`.

View Source
const DefaultNamespace = "default"

Variables

View Source
var TestableRetryFunc = func(err error) bool {
	var testableRetrierError *TestableRetrierError
	ok := errors.As(err, &testableRetrierError)
	return ok
}

TestableRetryFunc returns true if the returned error is a TestableRetrierError and indicates that an action should be tried until the retrier hits its limit.

Functions

func NewCommandExecutor

func NewCommandExecutor(clientSet kubernetes.Interface, coreV1RestClient rest.Interface) *defaultCommandExecutor

NewCommandExecutor creates a new instance of NewCommandExecutor

Types

type Cluster

type Cluster interface {
	Terminate(ctx context.Context) error
}

type K3dCluster

type K3dCluster struct {
	ClusterName         string
	AdminServiceAccount string
	// contains filtered or unexported fields
}

func CreateK3dCluster

func CreateK3dCluster(ctx context.Context, clusterNamePrefix string) (*K3dCluster, error)

CreateK3dCluster creates a completely new K8s cluster with an optional clusterNamePrefix.

func NewK3dCluster

func NewK3dCluster(t *testing.T) *K3dCluster

NewK3dCluster creates a completely new cluster within the provided container engine. This method is the usual entry point of a test with testclusters-go.

func (*K3dCluster) ClientSet

func (c *K3dCluster) ClientSet() (*kubernetes.Clientset, error)

ClientSet returns a K8s clientset which allows to interoperate with the cluster K8s API.

func (*K3dCluster) CtlKube

func (c *K3dCluster) CtlKube(fieldManager string) (*YamlApplier, error)

func (*K3dCluster) Lookout

func (c *K3dCluster) Lookout(t *testing.T) *Lookout

func (*K3dCluster) Terminate

func (c *K3dCluster) Terminate(ctx context.Context) error

Terminate shuts down the configured cluster.

type Lookout

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

func (*Lookout) Pod

func (l *Lookout) Pod(namespace, name string) *PodSelector

func (*Lookout) Pods

func (l *Lookout) Pods(namespace string) *PodListSelector

type PodList

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

func (*PodList) Len

func (pl *PodList) Len(ctx context.Context, expected int) error

func (*PodList) Raw

func (pl *PodList) Raw(ctx context.Context) (*v1.PodList, error)

Raw queries the kubernetes API and returns the pod list as plain kubernetes API objects.

type PodListSelector

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

func (*PodListSelector) ByFieldSelector

func (pls *PodListSelector) ByFieldSelector(fieldSelector string) *PodListSelector

func (*PodListSelector) ByLabels

func (pls *PodListSelector) ByLabels(labels string) *PodListSelector

func (*PodListSelector) List

func (pls *PodListSelector) List() *PodList

type PodSelector

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

func (*PodSelector) Events

func (ps *PodSelector) Events(ctx context.Context, fieldSelectors ...string) (*corev1.EventList, error)

func (*PodSelector) Logs

func (ps *PodSelector) Logs(ctx context.Context) ([]byte, error)

func (*PodSelector) Raw

func (ps *PodSelector) Raw(ctx context.Context) (*corev1.Pod, error)

type ShellCommand

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

ShellCommand represents all necessary arguments to execute a command inside a container.

func NewShellCommand

func NewShellCommand(command string, args ...string) ShellCommand

NewShellCommand creates a new ShellCommand. While the command is mandatory, there can be zero to n command arguments.

func (*ShellCommand) CommandWithArgs

func (sc *ShellCommand) CommandWithArgs() []string

func (*ShellCommand) String

func (sc *ShellCommand) String() string

type TestableRetrierError

type TestableRetrierError struct {
	Err error
}

TestableRetrierError marks errors that indicate that a previously executed action should be retried with again. It must wrap an existing error.

func (*TestableRetrierError) Error

func (tre *TestableRetrierError) Error() string

Error returns the error's string representation.

type YamlApplier

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

YamlApplier provides a pod with kubectl access to the cluster.

func NewYamlApplier

func NewYamlApplier(restConfig *rest.Config, fieldManager, defaultNamespace string) (*YamlApplier, error)

func (*YamlApplier) ApplyWithFile

func (ya *YamlApplier) ApplyWithFile(ctx context.Context, yamlBytes []byte) error

ApplyWithFile copies the yaml bytes into a file and calls `kubectl apply -f`.

Jump to

Keyboard shortcuts

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