Skip to content

Commit

Permalink
Merge pull request #3750 from fabriziopandini/e2e-configurable-nodeim…
Browse files Browse the repository at this point in the history
…ages-for-bootstrap-cluster

🌱 e2e framework allows choosing the node image for the bootstrap cluster
  • Loading branch information
k8s-ci-robot authored Oct 6, 2020
2 parents 9962a01 + 8ae4779 commit a462580
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 a462580

Please sign in to comment.