mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	feat(test-e2e): support custom network and subnet on remote e2e mode
This commit is contained in:
		@@ -110,6 +110,8 @@ if [ "${remote}" = true ] && [ "${remote_mode}" = gce ] ; then
 | 
				
			|||||||
  gubernator=${GUBERNATOR:-"false"}
 | 
					  gubernator=${GUBERNATOR:-"false"}
 | 
				
			||||||
  instance_type=${INSTANCE_TYPE:-""}
 | 
					  instance_type=${INSTANCE_TYPE:-""}
 | 
				
			||||||
  node_env="${NODE_ENV:-""}"
 | 
					  node_env="${NODE_ENV:-""}"
 | 
				
			||||||
 | 
					  network="${NETWORK:-""}"
 | 
				
			||||||
 | 
					  subnet="${SUBNET:-""}"
 | 
				
			||||||
  image_config_file=${IMAGE_CONFIG_FILE:-""}
 | 
					  image_config_file=${IMAGE_CONFIG_FILE:-""}
 | 
				
			||||||
  image_config_dir=${IMAGE_CONFIG_DIR:-""}
 | 
					  image_config_dir=${IMAGE_CONFIG_DIR:-""}
 | 
				
			||||||
  use_dockerized_build=${USE_DOCKERIZED_BUILD:-"false"}
 | 
					  use_dockerized_build=${USE_DOCKERIZED_BUILD:-"false"}
 | 
				
			||||||
@@ -196,6 +198,12 @@ if [ "${remote}" = true ] && [ "${remote_mode}" = gce ] ; then
 | 
				
			|||||||
  if [[ -n ${instance_type} ]]; then
 | 
					  if [[ -n ${instance_type} ]]; then
 | 
				
			||||||
    echo "Instance Type: ${instance_type}"
 | 
					    echo "Instance Type: ${instance_type}"
 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
 | 
					  if [[ -n ${network} ]]; then
 | 
				
			||||||
 | 
					    echo "Network: ${network}"
 | 
				
			||||||
 | 
					  fi
 | 
				
			||||||
 | 
					  if [[ -n ${subnet} ]]; then
 | 
				
			||||||
 | 
					    echo "Subnet: ${subnet}"
 | 
				
			||||||
 | 
					  fi
 | 
				
			||||||
  echo "Kubelet Config File: ${kubelet_config_file}"
 | 
					  echo "Kubelet Config File: ${kubelet_config_file}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  # Invoke the runner
 | 
					  # Invoke the runner
 | 
				
			||||||
@@ -206,6 +214,7 @@ if [ "${remote}" = true ] && [ "${remote_mode}" = gce ] ; then
 | 
				
			|||||||
    --image-project="${image_project}" --instance-name-prefix="${instance_prefix}" \
 | 
					    --image-project="${image_project}" --instance-name-prefix="${instance_prefix}" \
 | 
				
			||||||
    --delete-instances="${delete_instances}" --test_args="${test_args}" --instance-metadata="${metadata}" \
 | 
					    --delete-instances="${delete_instances}" --test_args="${test_args}" --instance-metadata="${metadata}" \
 | 
				
			||||||
    --image-config-file="${image_config_file}" --system-spec-name="${system_spec_name}" \
 | 
					    --image-config-file="${image_config_file}" --system-spec-name="${system_spec_name}" \
 | 
				
			||||||
 | 
					    --network="${network}" --subnet="${subnet}" \
 | 
				
			||||||
    --runtime-config="${runtime_config}" --preemptible-instances="${preemptible_instances}" \
 | 
					    --runtime-config="${runtime_config}" --preemptible-instances="${preemptible_instances}" \
 | 
				
			||||||
    --ssh-user="${ssh_user}" --ssh-key="${ssh_key}" --ssh-options="${ssh_options}" \
 | 
					    --ssh-user="${ssh_user}" --ssh-key="${ssh_key}" --ssh-options="${ssh_options}" \
 | 
				
			||||||
    --image-config-dir="${image_config_dir}" --node-env="${node_env}" \
 | 
					    --image-config-dir="${image_config_dir}" --node-env="${node_env}" \
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -75,6 +75,8 @@ var instanceMetadata = flag.String("instance-metadata", "", "key/value metadata
 | 
				
			|||||||
var imageProject = flag.String("image-project", "", "gce project the hosts live in  (gce)")
 | 
					var imageProject = flag.String("image-project", "", "gce project the hosts live in  (gce)")
 | 
				
			||||||
var instanceType = flag.String("instance-type", "e2-medium", "GCP Machine type to use for test")
 | 
					var instanceType = flag.String("instance-type", "e2-medium", "GCP Machine type to use for test")
 | 
				
			||||||
var preemptibleInstances = flag.Bool("preemptible-instances", false, "If true, gce instances will be configured to be preemptible  (gce)")
 | 
					var preemptibleInstances = flag.Bool("preemptible-instances", false, "If true, gce instances will be configured to be preemptible  (gce)")
 | 
				
			||||||
 | 
					var network = flag.String("network", "", "Specifies the network that the VM instance are a part of")
 | 
				
			||||||
 | 
					var subnet = flag.String("subnet", "", "Specifies the subnet that the VM instance are a part of")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func init() {
 | 
					func init() {
 | 
				
			||||||
	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'.")
 | 
						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
 | 
				
			|||||||
	createArgs = append(createArgs, "--machine-type="+g.machineType(imageConfig.machine))
 | 
						createArgs = append(createArgs, "--machine-type="+g.machineType(imageConfig.machine))
 | 
				
			||||||
	createArgs = append(createArgs, "--create-disk="+strings.Join(diskArgs, ","))
 | 
						createArgs = append(createArgs, "--create-disk="+strings.Join(diskArgs, ","))
 | 
				
			||||||
	createArgs = append(createArgs, "--service-account="+serviceAccount)
 | 
						createArgs = append(createArgs, "--service-account="+serviceAccount)
 | 
				
			||||||
 | 
						if len(*network) > 0 {
 | 
				
			||||||
 | 
							createArgs = append(createArgs, "--network="+*network)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if len(*subnet) > 0 {
 | 
				
			||||||
 | 
							createArgs = append(createArgs, "--subnet="+*subnet)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	if *preemptibleInstances {
 | 
						if *preemptibleInstances {
 | 
				
			||||||
		createArgs = append(createArgs, "--preemptible")
 | 
							createArgs = append(createArgs, "--preemptible")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user