Documentation ¶
Overview ¶
Package clustersetup implements bootstrap functionality for e2e testing.
Index ¶
Constants ¶
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.24.6" )
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 CreateKindClusterAndLoadImages ¶
func CreateKindClusterAndLoadImages(ctx context.Context, input CreateKindClusterAndLoadImagesInput) ClusterProvider
CreateKindBootstrapClusterAndLoadImages returns a new Kubernetes cluster with pre-loaded images.
type CreateKindClusterAndLoadImagesInput ¶
type CreateKindClusterAndLoadImagesInput 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 []string // IPFamily is either ipv4 or ipv6. Default is ipv4. IPFamily string }
CreateKindClusterAndLoadImagesInput is the input for CreateKindClusterAndLoadImages.
type KindClusterOption ¶
type KindClusterOption interface {
// contains filtered or unexported methods
}
KindClusterOption is a NewKindClusterProvider option.
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 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 []string }
LoadImagesToKindClusterInput is the input for LoadImagesToKindCluster.