-
Notifications
You must be signed in to change notification settings - Fork 841
[tmpnet] Enable deployment to kube #3615
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
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8cb990a
[tmpnet] Add node runtime for kube
maru-ava 7a80b41
fixup: Catch missing runtime configuration
maru-ava 6602a1a
fixup: Address lint failure
maru-ava c67cb2b
fixup: Address review comment
maru-ava 2fe5efc
Update tests/fixture/tmpnet/kube_runtime.go
maru-ava c0124e2
Update tests/fixture/tmpnet/kube.go
maru-ava 165abc2
fixup: Ensure imports for accepted suggestion
maru-ava aae540c
fixup: Update to replacement for deprecated pointer library
maru-ava 3d8aba1
fixup: Simplify node start as per review comment
maru-ava f2ce132
Update tests/fixture/tmpnet/kube_runtime.go
maru-ava f2cd875
fixup: Add import for accepted suggestion
maru-ava fc9a9f7
fixup: Respond to review comment re: incorrect order in errors.Is
maru-ava c3281ca
fixup: Use errors.Is instead of os.IsNotExist
maru-ava e8c9f86
fixup: Satisfy linter
maru-ava 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
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,35 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| # e.g., | ||
| # ./scripts/build_image.sh # Build local single-arch image | ||
| # AVALANCHEGO_IMAGE=localhost:5001/avalanchego ./scripts/build_xsvm_image.sh # Build and push image to private registry | ||
|
|
||
| if ! [[ "$0" =~ scripts/build_xsvm_image.sh ]]; then | ||
| echo "must be run from repository root" | ||
| exit 255 | ||
| fi | ||
|
|
||
| source ./scripts/image_tag.sh | ||
|
|
||
| AVALANCHEGO_IMAGE="${AVALANCHEGO_IMAGE:-avalanchego}" | ||
| XSVM_IMAGE="${XSVM_IMAGE:-avalanchego-xsvm}" | ||
|
|
||
| # Build the avalanchego base image | ||
| SKIP_BUILD_RACE=1 DOCKER_IMAGE="${AVALANCHEGO_IMAGE}" bash -x ./scripts/build_image.sh | ||
|
|
||
| DOCKER_CMD=("docker" "buildx" "build") | ||
| if [[ "${XSVM_IMAGE}" == *"/"* ]]; then | ||
| # Push to a registry when the image name includes a slash which indicates the | ||
| # use of a registry e.g. | ||
| # | ||
| # - dockerhub: [repo]/[image name]:[tag] | ||
| # - private registry: [private registry hostname]/[image name]:[tag] | ||
| DOCKER_CMD+=("--push") | ||
| fi | ||
|
|
||
| GO_VERSION="$(go list -m -f '{{.GoVersion}}')" | ||
|
|
||
| "${DOCKER_CMD[@]}" --build-arg GO_VERSION="${GO_VERSION}" --build-arg AVALANCHEGO_NODE_IMAGE="${AVALANCHEGO_IMAGE}:${image_tag}" \ | ||
| -t "${XSVM_IMAGE}" -f ./vms/example/xsvm/Dockerfile . |
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,26 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| # Run e2e tests against nodes deployed to a kind cluster. | ||
|
|
||
| # TODO(marun) Support testing against a remote cluster | ||
|
|
||
| if ! [[ "$0" =~ scripts/tests.e2e.kube.sh ]]; then | ||
| echo "must be run from repository root" | ||
| exit 255 | ||
| fi | ||
|
|
||
| # This script will use kubeconfig arguments if supplied | ||
| ./scripts/start_kind_cluster.sh "$@" | ||
|
|
||
| # Use an image that will be pushed to the local registry that the kind cluster is configured to use. | ||
| AVALANCHEGO_IMAGE="localhost:5001/avalanchego" | ||
| XSVM_IMAGE="${AVALANCHEGO_IMAGE}-xsvm" | ||
| if [[ -n "${SKIP_BUILD_IMAGE:-}" ]]; then | ||
| echo "Skipping build of xsvm image due to SKIP_BUILD_IMAGE=${SKIP_BUILD_IMAGE}" | ||
| else | ||
| XSVM_IMAGE="${XSVM_IMAGE}" AVALANCHEGO_IMAGE="${AVALANCHEGO_IMAGE}" bash -x ./scripts/build_xsvm_image.sh | ||
| fi | ||
|
|
||
| bash -x ./scripts/tests.e2e.sh --runtime=kube --kube-image="${XSVM_IMAGE}" "$@" |
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
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 |
|---|---|---|
|
|
@@ -46,7 +46,7 @@ func newGinkgoLogger(cfg zapcore.Encoder) logging.Logger { | |
| return logging.NewLogger( | ||
| "", | ||
| logging.NewWrappedCore( | ||
| logging.Verbo, | ||
| logging.Info, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lowering the level here so that the kube runtime logging is suppressed by default (it's more useful for debugging when implementing than useful for diagnosing a test suite). |
||
| &ginkgoWriteCloser{}, | ||
| cfg, | ||
| ), | ||
|
|
||
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,86 @@ | ||
| // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. | ||
| // See the file LICENSE for licensing terms. | ||
|
|
||
| package flags | ||
|
|
||
| import ( | ||
| "errors" | ||
| "flag" | ||
| "fmt" | ||
|
|
||
| "github.com/spf13/pflag" | ||
|
|
||
| "github.com/ava-labs/avalanchego/tests/fixture/tmpnet" | ||
| ) | ||
|
|
||
| const ( | ||
| kubeRuntime = "kube" | ||
| kubeFlagsPrefix = kubeRuntime + "-" | ||
| kubeDocPrefix = "[kube runtime] " | ||
| ) | ||
|
|
||
| var ( | ||
| errKubeNamespaceRequired = errors.New("--kube-namespace is required") | ||
| errKubeImageRequired = errors.New("--kube-image is required") | ||
| errKubeMinVolumeSizeRequired = fmt.Errorf("--kube-volume-size must be >= %d", tmpnet.MinimumVolumeSizeGB) | ||
| ) | ||
|
|
||
| type kubeRuntimeVars struct { | ||
| namespace string | ||
| image string | ||
| volumeSizeGB uint | ||
| config *KubeconfigVars | ||
| } | ||
|
|
||
| func (v *kubeRuntimeVars) registerWithFlag() { | ||
| v.config = newKubeconfigFlagVars(kubeDocPrefix) | ||
| v.register(flag.StringVar, flag.UintVar) | ||
| } | ||
|
|
||
| func (v *kubeRuntimeVars) registerWithFlagSet(flagSet *pflag.FlagSet) { | ||
| v.config = newKubeconfigFlagSetVars(flagSet, kubeDocPrefix) | ||
| v.register(flagSet.StringVar, flagSet.UintVar) | ||
| } | ||
|
|
||
| func (v *kubeRuntimeVars) register(stringVar varFunc[string], uintVar varFunc[uint]) { | ||
| stringVar( | ||
| &v.namespace, | ||
| "kube-namespace", | ||
| tmpnet.DefaultTmpnetNamespace, | ||
| kubeDocPrefix+"The namespace in the target cluster to create nodes in", | ||
| ) | ||
| stringVar( | ||
| &v.image, | ||
| "kube-image", | ||
| "avaplatform/avalanchego:latest", | ||
| kubeDocPrefix+"The name of the docker image to use for creating nodes", | ||
| ) | ||
| uintVar( | ||
| &v.volumeSizeGB, | ||
| "kube-volume-size", | ||
| tmpnet.MinimumVolumeSizeGB, | ||
| kubeDocPrefix+fmt.Sprintf( | ||
| "The size in gigabytes of the PeristentVolumeClaim to create for the data directory of each node. Value must be >= %d.", | ||
| tmpnet.MinimumVolumeSizeGB, | ||
| ), | ||
| ) | ||
| } | ||
|
|
||
| func (v *kubeRuntimeVars) getKubeRuntimeConfig() (*tmpnet.KubeRuntimeConfig, error) { | ||
| if len(v.namespace) == 0 { | ||
| return nil, errKubeNamespaceRequired | ||
| } | ||
| if len(v.image) == 0 { | ||
| return nil, errKubeImageRequired | ||
| } | ||
| if v.volumeSizeGB < tmpnet.MinimumVolumeSizeGB { | ||
| return nil, errKubeMinVolumeSizeRequired | ||
| } | ||
| return &tmpnet.KubeRuntimeConfig{ | ||
| ConfigPath: v.config.Path, | ||
| ConfigContext: v.config.Context, | ||
| Namespace: v.namespace, | ||
| Image: v.image, | ||
| VolumeSizeGB: v.volumeSizeGB, | ||
| }, nil | ||
| } |
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
Oops, something went wrong.
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.