diff --git a/build/root/Makefile b/build/root/Makefile index d0d69ab1602..de60c5edb4b 100644 --- a/build/root/Makefile +++ b/build/root/Makefile @@ -254,6 +254,7 @@ define TEST_E2E_NODE_HELP_INFO # GUBERNATOR: For REMOTE=true only. Produce link to Gubernator to view logs. # Defaults to false. # TEST_SUITE: For REMOTE=true only. Test suite to use. Defaults to "default". +# SSH_KEY: For REMOTE=true only. Path to SSH key to use. # # Example: # make test-e2e-node FOCUS=Kubelet SKIP=container diff --git a/hack/make-rules/test-e2e-node.sh b/hack/make-rules/test-e2e-node.sh index f72ced2a4f0..c6adb8b1b4b 100755 --- a/hack/make-rules/test-e2e-node.sh +++ b/hack/make-rules/test-e2e-node.sh @@ -47,6 +47,8 @@ timeout_arg="" system_spec_name=${SYSTEM_SPEC_NAME:-} extra_envs=${EXTRA_ENVS:-} runtime_config=${RUNTIME_CONFIG:-} +ssh_user=${SSH_USER:-"${USER}"} +ssh_key=${SSH_KEY:-} # Parse the flags to pass to ginkgo ginkgoflags="" @@ -170,6 +172,7 @@ if [ "${remote}" = true ] ; then --delete-instances="${delete_instances}" --test_args="${test_args}" --instance-metadata="${metadata}" \ --image-config-file="${image_config_file}" --system-spec-name="${system_spec_name}" \ --runtime-config="${runtime_config}" --preemptible-instances="${preemptible_instances}" \ + --ssh-user="${ssh_user}" --ssh-key="${ssh_key}" \ --extra-envs="${extra_envs}" --test-suite="${test_suite}" \ "${timeout_arg}" \ 2>&1 | tee -i "${artifacts}/build-log.txt" diff --git a/test/e2e_node/remote/ssh.go b/test/e2e_node/remote/ssh.go index 87a069a871f..eefa1000924 100644 --- a/test/e2e_node/remote/ssh.go +++ b/test/e2e_node/remote/ssh.go @@ -44,8 +44,12 @@ func init() { sshOptionsMap = map[string]string{ "gce": "-o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o CheckHostIP=no -o StrictHostKeyChecking=no -o ServerAliveInterval=30 -o LogLevel=ERROR", } + defaultGceKey := os.Getenv("GCE_SSH_PRIVATE_KEY_FILE") + if defaultGceKey == "" { + defaultGceKey = fmt.Sprintf("%s/.ssh/google_compute_engine", usr.HomeDir) + } sshDefaultKeyMap = map[string]string{ - "gce": fmt.Sprintf("%s/.ssh/google_compute_engine", usr.HomeDir), + "gce": defaultGceKey, } }