Skip to content

Commit

Permalink
e2e framework allows choosing the node image for the bootstrap cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziopandini committed Oct 6, 2020
1 parent f728084 commit 8ae4779
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/framework/bootstrap/kind_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ import (
kind "sigs.k8s.io/kind/pkg/cluster"
)

const (
// DefaultNodeImage is the default node image to be used for for testing.
DefaultNodeImage = "kindest/node:v1.19.1"
)

// KindClusterOption is a NewKindClusterProvider option
type KindClusterOption interface {
apply(*kindClusterProvider)
Expand All @@ -39,6 +44,13 @@ func (adapter kindClusterOptionAdapter) apply(kindClusterProvider *kindClusterPr
adapter(kindClusterProvider)
}

// WithNodeImage implements a New Option that instruct the kindClusterProvider to use a specific node image / Kubernetes version
func WithNodeImage(image string) KindClusterOption {
return kindClusterOptionAdapter(func(k *kindClusterProvider) {
k.nodeImage = image
})
}

// WithDockerSockMount implements a New Option that instruct the kindClusterProvider to mount /var/run/docker.sock into
// the new kind cluster.
func WithDockerSockMount() KindClusterOption {
Expand All @@ -65,6 +77,7 @@ type kindClusterProvider struct {
name string
withDockerSock bool
kubeconfigPath string
nodeImage string
}

// Create a Kubernetes cluster using kind.
Expand Down Expand Up @@ -92,6 +105,12 @@ func (k *kindClusterProvider) createKindCluster() {
kindCreateOptions = append(kindCreateOptions, kind.CreateWithV1Alpha4Config(withDockerSockConfig()))
}

nodeImage := DefaultNodeImage
if k.nodeImage != "" {
nodeImage = k.nodeImage
}
kindCreateOptions = append(kindCreateOptions, kind.CreateWithNodeImage(nodeImage))

err := kind.NewProvider().Create(k.name, kindCreateOptions...)
Expect(err).ToNot(HaveOccurred(), "Failed to create the kind cluster %q")
}
Expand Down

0 comments on commit 8ae4779

Please sign in to comment.