mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
Support set user with --ssh-user
flag when running remote node e2e.
This commit is contained in:
parent
db867c0c9d
commit
10f72be5af
@ -41,9 +41,9 @@ TIMEOUT=${TIMEOUT:-"45m"}
|
|||||||
|
|
||||||
mkdir -p ${ARTIFACTS}
|
mkdir -p ${ARTIFACTS}
|
||||||
|
|
||||||
go run test/e2e_node/runner/remote/run_remote.go --logtostderr --vmodule=*=4 --ssh-env="gce" \
|
go run test/e2e_node/runner/remote/run_remote.go --logtostderr --vmodule=*=4 \
|
||||||
--zone="$GCE_ZONE" --project="$GCE_PROJECT" --hosts="$GCE_HOSTS" \
|
--ssh-env="gce" --ssh-user="$GCE_USER" --zone="$GCE_ZONE" --project="$GCE_PROJECT" \
|
||||||
--images="$GCE_IMAGES" --image-project="$GCE_IMAGE_PROJECT" \
|
--hosts="$GCE_HOSTS" --images="$GCE_IMAGES" --image-project="$GCE_IMAGE_PROJECT" \
|
||||||
--image-config-file="$GCE_IMAGE_CONFIG_PATH" --cleanup="$CLEANUP" \
|
--image-config-file="$GCE_IMAGE_CONFIG_PATH" --cleanup="$CLEANUP" \
|
||||||
--results-dir="$ARTIFACTS" --ginkgo-flags="--nodes=$PARALLELISM $GINKGO_FLAGS" \
|
--results-dir="$ARTIFACTS" --ginkgo-flags="--nodes=$PARALLELISM $GINKGO_FLAGS" \
|
||||||
--test-timeout="$TIMEOUT" --test_args="$TEST_ARGS --kubelet-flags=\"$KUBELET_ARGS\"" \
|
--test-timeout="$TIMEOUT" --test_args="$TEST_ARGS --kubelet-flags=\"$KUBELET_ARGS\"" \
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
# Copy this file to your home directory and modify
|
# Copy this file to your home directory and modify
|
||||||
|
# User used on the gce instances to run the test.
|
||||||
|
GCE_USER=
|
||||||
# Path to a yaml or json file describing images to run or empty
|
# Path to a yaml or json file describing images to run or empty
|
||||||
GCE_IMAGE_CONFIG_PATH=
|
GCE_IMAGE_CONFIG_PATH=
|
||||||
# Names of gce hosts to test against (must be resolvable) or empty
|
# Names of gce hosts to test against (must be resolvable) or empty
|
||||||
|
@ -29,6 +29,7 @@ import (
|
|||||||
|
|
||||||
var sshOptions = flag.String("ssh-options", "", "Commandline options passed to ssh.")
|
var sshOptions = flag.String("ssh-options", "", "Commandline options passed to ssh.")
|
||||||
var sshEnv = flag.String("ssh-env", "", "Use predefined ssh options for environment. Options: gce")
|
var sshEnv = flag.String("ssh-env", "", "Use predefined ssh options for environment. Options: gce")
|
||||||
|
var sshUser = flag.String("ssh-user", "", "Use predefined user for ssh.")
|
||||||
|
|
||||||
var sshOptionsMap map[string]string
|
var sshOptionsMap map[string]string
|
||||||
|
|
||||||
@ -53,13 +54,18 @@ func AddHostnameIp(hostname, ip string) {
|
|||||||
hostnameIpOverrides.m[hostname] = ip
|
hostnameIpOverrides.m[hostname] = ip
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetHostnameOrIp converts hostname into ip and apply user if necessary.
|
||||||
func GetHostnameOrIp(hostname string) string {
|
func GetHostnameOrIp(hostname string) string {
|
||||||
hostnameIpOverrides.RLock()
|
hostnameIpOverrides.RLock()
|
||||||
defer hostnameIpOverrides.RUnlock()
|
defer hostnameIpOverrides.RUnlock()
|
||||||
|
host := hostname
|
||||||
if ip, found := hostnameIpOverrides.m[hostname]; found {
|
if ip, found := hostnameIpOverrides.m[hostname]; found {
|
||||||
return ip
|
host = ip
|
||||||
}
|
}
|
||||||
return hostname
|
if *sshUser != "" {
|
||||||
|
host = fmt.Sprintf("%s@%s", *sshUser, host)
|
||||||
|
}
|
||||||
|
return host
|
||||||
}
|
}
|
||||||
|
|
||||||
// getSSHCommand handles proper quoting so that multiple commands are executed in the same shell over ssh
|
// getSSHCommand handles proper quoting so that multiple commands are executed in the same shell over ssh
|
||||||
|
Loading…
Reference in New Issue
Block a user