k3t

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Package k3t provides a simple wrapper around the k3d client to operate a cluster for integration tests.

Index

Constants

This section is empty.

Variables

View Source
var DebugKubeconfigPath = "/tmp/k3t/kubeconfig"

Functions

func ConfigureLogger

func ConfigureLogger(t *testing.T)

ConfigureLogger configures k3d logger to use testing.T's Log method instead of stdout. This funciton is called from NewCluster, unless disabled by an option. Note that this configures a global config, so it's not safe to configure from tests running in parallel. Note that testing.T automatically logs the name of this file, hence the short but still descriptive filename.

Types

type Cluster

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

func NewCluster

func NewCluster(ctx context.Context, t *testing.T, opts ...Option) Cluster

func (Cluster) API

func (c Cluster) API() *kubernetes.Clientset

func (Cluster) LBPort

func (c Cluster) LBPort() string

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option configures a cluster creation. It intentionally contains unexported methods to make sure that the contract of Option can be changed without breaking changes. We're using an interface with specific types for each option because it's easier to debug these kind of options later, compared to a list of anonymous functions.

func WithAPIPort

func WithAPIPort(port string) Option

WithAPIPort overrides the Kubernetes API port exposed on the host machine, instead of using a random free one.

func WithImages

func WithImages(images ...string) Option

WithImages returns an option that preloads the specified images into the cluster. It expects those images to be already present on the host. Can be specified multiple times.

func WithLoadBalancerPort

func WithLoadBalancerPort(port string) Option

WithLoadBalancerPort overrides the load balancer port exposed on the host machine, instead of using a random free one.

func WithName

func WithName(name string) Option

WithName returns an option that sets a defined cluster name on creation.

func WithNoLoggerOverride

func WithNoLoggerOverride() Option

WithNoLoggerOverride disables the k3d logger override to the testing.T.Logf(). This is useful if multiple tests are ran in parallel, as k3d logger is one global one.

Jump to

Keyboard shortcuts

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