Allow a single SSH key to be used in all providers

Support KUBE_SSH_KEY_PATH as a single environment variable that if
specified ignores the provider specific settinsg and loads the
SSH private key from the provided path. Makes it much easier to
specify a consistent signer across providers.
This commit is contained in:
Clayton Coleman 2018-12-21 16:10:22 -05:00
parent c6ae7ae3b2
commit d09a655c4c
No known key found for this signature in database
GPG Key ID: 3D16906B4F1C5CB3

View File

@ -31,6 +31,11 @@ import (
// GetSigner returns an ssh.Signer for the provider ("gce", etc.) that can be
// used to SSH to their nodes.
func GetSigner(provider string) (ssh.Signer, error) {
// honor a consistent SSH key across all providers
if path := os.Getenv("KUBE_SSH_KEY_PATH"); len(path) > 0 {
return sshutil.MakePrivateKeySignerFromFile(path)
}
// Select the key itself to use. When implementing more providers here,
// please also add them to any SSH tests that are disabled because of signer
// support.