bootstrap

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: Apache-2.0 Imports: 18 Imported by: 5

Documentation

Overview

Package bootstrap implements bootstrap functionality for e2e testing.

Index

Constants

View Source
const (
	// DefaultNodeImageRepository is the default node image repository to be used for testing.
	DefaultNodeImageRepository = "kindest/node"

	// DefaultNodeImageVersion is the default Kubernetes version to be used for creating a kind cluster.
	DefaultNodeImageVersion = "v1.31.0@sha256:53df588e04085fd41ae12de0c3fe4c72f7013bba32a20e7325357a1ac94ba865"
)

Variables

This section is empty.

Functions

func LoadImagesToKindCluster

func LoadImagesToKindCluster(ctx context.Context, input LoadImagesToKindClusterInput) error

LoadImagesToKindCluster provides a utility for loading images into a kind cluster.

Types

type ClusterProvider

type ClusterProvider interface {
	// Create a Kubernetes cluster.
	// Generally to be used in the BeforeSuite function to create a Kubernetes cluster to be shared between tests.
	Create(context.Context)

	// GetKubeconfigPath returns the path to the kubeconfig file to be used to access the Kubernetes cluster.
	GetKubeconfigPath() string

	// Dispose will completely clean up the provisioned cluster.
	// This should be implemented as a synchronous function.
	// Generally to be used in the AfterSuite function if a Kubernetes cluster is shared between tests.
	// Should try to clean everything up and report any dangling artifacts that needs manual intervention.
	Dispose(context.Context)
}

ClusterProvider defines the behavior of a type that is responsible for provisioning and managing a Kubernetes cluster.

func CreateKindBootstrapClusterAndLoadImages

func CreateKindBootstrapClusterAndLoadImages(ctx context.Context, input CreateKindBootstrapClusterAndLoadImagesInput) ClusterProvider

CreateKindBootstrapClusterAndLoadImages returns a new Kubernetes cluster with pre-loaded images.

type CreateKindBootstrapClusterAndLoadImagesInput

type CreateKindBootstrapClusterAndLoadImagesInput struct {
	// Name of the cluster.
	Name string

	// KubernetesVersion of the cluster.
	KubernetesVersion string

	// RequiresDockerSock defines if the cluster requires the docker sock.
	RequiresDockerSock bool

	// Images to be loaded in the cluster.
	Images []clusterctl.ContainerImage

	// IPFamily is either ipv4 or ipv6. Default is ipv4.
	IPFamily string

	// LogFolder where to dump logs in case of errors
	LogFolder string

	// ExtraPortMappings specifies the port forward configuration of the kind node.
	ExtraPortMappings []kindv1.PortMapping
}

CreateKindBootstrapClusterAndLoadImagesInput is the input for CreateKindBootstrapClusterAndLoadImages.

type KindClusterOption

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

KindClusterOption is a NewKindClusterProvider option.

func LogFolder added in v1.1.0

func LogFolder(path string) KindClusterOption

LogFolder implements a New Option that instruct the kindClusterProvider to dump bootstrap logs in a folder in case of errors.

func WithDockerSockMount

func WithDockerSockMount() KindClusterOption

WithDockerSockMount implements a New Option that instruct the kindClusterProvider to mount /var/run/docker.sock into the new kind cluster.

func WithDualStackFamily added in v1.5.0

func WithDualStackFamily() KindClusterOption

WithDualStackFamily implements a New Option that instruct the kindClusterProvider to set the IPFamily to dual in the new kind cluster.

func WithExtraPortMappings added in v1.7.0

func WithExtraPortMappings(mappings []kindv1.PortMapping) KindClusterOption

WithExtraPortMappings implements a New Option that instruct the kindClusterProvider to set extra port forward mappings.

func WithIPv6Family

func WithIPv6Family() KindClusterOption

WithIPv6Family implements a New Option that instruct the kindClusterProvider to set the IPFamily to IPv6 in the new kind cluster.

func WithNodeImage

func WithNodeImage(image string) KindClusterOption

WithNodeImage implements a New Option that instruct the kindClusterProvider to use a specific node image / Kubernetes version.

type KindClusterProvider

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

KindClusterProvider implements a ClusterProvider that can create a kind cluster.

func NewKindClusterProvider

func NewKindClusterProvider(name string, options ...KindClusterOption) *KindClusterProvider

NewKindClusterProvider returns a ClusterProvider that can create a kind cluster.

func (*KindClusterProvider) Create

func (k *KindClusterProvider) Create(ctx context.Context)

Create a Kubernetes cluster using kind.

func (*KindClusterProvider) Dispose

func (k *KindClusterProvider) Dispose(ctx context.Context)

Dispose the kind cluster and its kubeconfig file.

func (*KindClusterProvider) GetKubeconfigPath

func (k *KindClusterProvider) GetKubeconfigPath() string

GetKubeconfigPath returns the path to the kubeconfig file for the cluster.

type LoadImagesToKindClusterInput

type LoadImagesToKindClusterInput struct {
	// Name of the cluster
	Name string

	// Images to be loaded in the cluster (this is kind specific)
	Images []clusterctl.ContainerImage
}

LoadImagesToKindClusterInput is the input for LoadImagesToKindCluster.

Jump to

Keyboard shortcuts

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