-
Notifications
You must be signed in to change notification settings - Fork 7
test(e2e): Use ghcr.io/mesosphere/kind-node for bootstrap #406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
//go:build e2e | ||
|
||
// Copyright 2024 D2iQ, Inc. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package bootstrap | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
"sigs.k8s.io/cluster-api/test/framework/bootstrap" | ||
) | ||
|
||
// CreateKindBootstrapClusterAndLoadImagesInput is the input for CreateKindBootstrapClusterAndLoadImages. | ||
type CreateKindBootstrapClusterAndLoadImagesInput struct { | ||
// NodeImageRepository defines the image repository to use for the bootstrap cluster nodes. | ||
NodeImageRepository string | ||
|
||
bootstrap.CreateKindBootstrapClusterAndLoadImagesInput | ||
} | ||
|
||
// CreateKindBootstrapClusterAndLoadImages returns a new Kubernetes cluster with pre-loaded images. | ||
func CreateKindBootstrapClusterAndLoadImages( | ||
ctx context.Context, | ||
input CreateKindBootstrapClusterAndLoadImagesInput, //nolint:gocritic // Copied from upstream. | ||
) bootstrap.ClusterProvider { | ||
Expect(ctx).NotTo(BeNil(), "ctx is required for CreateKindBootstrapClusterAndLoadImages") | ||
Expect( | ||
input.Name, | ||
).ToNot(BeEmpty(), "Invalid argument. Name can't be empty when calling CreateKindBootstrapClusterAndLoadImages") | ||
|
||
fmt.Fprintf(GinkgoWriter, "INFO: Creating a kind cluster with name %q\n", input.Name) | ||
|
||
options := []bootstrap.KindClusterOption{} | ||
nodeImageRepository := bootstrap.DefaultNodeImageRepository | ||
if input.NodeImageRepository != "" { | ||
nodeImageRepository = input.NodeImageRepository | ||
} | ||
|
||
if input.KubernetesVersion != "" { | ||
options = append( | ||
options, | ||
bootstrap.WithNodeImage( | ||
fmt.Sprintf("%s:%s", nodeImageRepository, input.KubernetesVersion), | ||
), | ||
) | ||
} | ||
if input.RequiresDockerSock { | ||
options = append(options, bootstrap.WithDockerSockMount()) | ||
} | ||
if input.IPFamily == "IPv6" { | ||
options = append(options, bootstrap.WithIPv6Family()) | ||
} | ||
if input.IPFamily == "dual" { | ||
options = append(options, bootstrap.WithDualStackFamily()) | ||
} | ||
if input.LogFolder != "" { | ||
options = append(options, bootstrap.LogFolder(input.LogFolder)) | ||
} | ||
clusterProvider := bootstrap.NewKindClusterProvider(input.Name, options...) | ||
Expect(clusterProvider).ToNot(BeNil(), "Failed to create a kind cluster") | ||
|
||
clusterProvider.Create(ctx) | ||
Expect( | ||
clusterProvider.GetKubeconfigPath(), | ||
).To( | ||
BeAnExistingFile(), | ||
"The kubeconfig file for the kind cluster with name %q does not exists at %q as expected", | ||
input.Name, | ||
clusterProvider.GetKubeconfigPath(), | ||
) | ||
|
||
fmt.Fprintf( | ||
GinkgoWriter, | ||
"INFO: The kubeconfig file for the kind cluster is %s\n", | ||
clusterProvider.GetKubeconfigPath(), | ||
) | ||
|
||
err := bootstrap.LoadImagesToKindCluster(ctx, bootstrap.LoadImagesToKindClusterInput{ | ||
Name: input.Name, | ||
Images: input.Images, | ||
}) | ||
if err != nil { | ||
clusterProvider.Dispose(ctx) | ||
Expect(err).ToNot(HaveOccurred()) // re-surface the error to fail the test | ||
} | ||
|
||
return clusterProvider | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.