Skip to content

Commit d900efa

Browse files
feat(test-e2e): support custom network and subnet on remote e2e mode
1 parent 851cf43 commit d900efa

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

hack/make-rules/test-e2e-node.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ if [ "${remote}" = true ] && [ "${remote_mode}" = gce ] ; then
110110
gubernator=${GUBERNATOR:-"false"}
111111
instance_type=${INSTANCE_TYPE:-""}
112112
node_env="${NODE_ENV:-""}"
113+
network="${NETWORK:-""}"
114+
subnet="${SUBNET:-""}"
113115
image_config_file=${IMAGE_CONFIG_FILE:-""}
114116
image_config_dir=${IMAGE_CONFIG_DIR:-""}
115117
use_dockerized_build=${USE_DOCKERIZED_BUILD:-"false"}
@@ -196,6 +198,12 @@ if [ "${remote}" = true ] && [ "${remote_mode}" = gce ] ; then
196198
if [[ -n ${instance_type} ]]; then
197199
echo "Instance Type: ${instance_type}"
198200
fi
201+
if [[ -n ${network} ]]; then
202+
echo "Network: ${network}"
203+
fi
204+
if [[ -n ${subnet} ]]; then
205+
echo "Subnet: ${subnet}"
206+
fi
199207
echo "Kubelet Config File: ${kubelet_config_file}"
200208

201209
# Invoke the runner
@@ -206,6 +214,7 @@ if [ "${remote}" = true ] && [ "${remote_mode}" = gce ] ; then
206214
--image-project="${image_project}" --instance-name-prefix="${instance_prefix}" \
207215
--delete-instances="${delete_instances}" --test_args="${test_args}" --instance-metadata="${metadata}" \
208216
--image-config-file="${image_config_file}" --system-spec-name="${system_spec_name}" \
217+
--network="${network}" --subnet="${subnet}" \
209218
--runtime-config="${runtime_config}" --preemptible-instances="${preemptible_instances}" \
210219
--ssh-user="${ssh_user}" --ssh-key="${ssh_key}" --ssh-options="${ssh_options}" \
211220
--image-config-dir="${image_config_dir}" --node-env="${node_env}" \

test/e2e_node/remote/gce/gce_runner.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ var instanceMetadata = flag.String("instance-metadata", "", "key/value metadata
7575
var imageProject = flag.String("image-project", "", "gce project the hosts live in (gce)")
7676
var instanceType = flag.String("instance-type", "e2-medium", "GCP Machine type to use for test")
7777
var preemptibleInstances = flag.Bool("preemptible-instances", false, "If true, gce instances will be configured to be preemptible (gce)")
78+
var network = flag.String("network", "", "Specifies the network that the VM instance are a part of")
79+
var subnet = flag.String("subnet", "", "Specifies the subnet that the VM instance are a part of")
7880

7981
func init() {
8082
flag.Var(&nodeEnvs, "node-env", "An environment variable passed to instance as metadata, e.g. when '--node-env=PATH=/usr/bin' is specified, there will be an extra instance metadata 'PATH=/usr/bin'.")
@@ -512,6 +514,12 @@ func (g *GCERunner) createGCEInstance(imageConfig *internalGCEImage) (string, er
512514
createArgs = append(createArgs, "--machine-type="+g.machineType(imageConfig.machine))
513515
createArgs = append(createArgs, "--create-disk="+strings.Join(diskArgs, ","))
514516
createArgs = append(createArgs, "--service-account="+serviceAccount)
517+
if len(*network) > 0 {
518+
createArgs = append(createArgs, "--network="+*network)
519+
}
520+
if len(*subnet) > 0 {
521+
createArgs = append(createArgs, "--subnet="+*subnet)
522+
}
515523
if *preemptibleInstances {
516524
createArgs = append(createArgs, "--preemptible")
517525
}

0 commit comments

Comments
 (0)