mirror of https://github.com/kubernetes/kops.git
Use keys specified in env vars for GCP and AWS
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
This commit is contained in:
parent
d5c56dcf98
commit
ef76bf9164
|
@ -51,6 +51,12 @@ func (d *deployer) initialize() error {
|
||||||
|
|
||||||
switch d.CloudProvider {
|
switch d.CloudProvider {
|
||||||
case "aws":
|
case "aws":
|
||||||
|
if d.SSHPrivateKeyPath == "" {
|
||||||
|
d.SSHPrivateKeyPath = os.Getenv("AWS_SSH_PRIVATE_KEY_FILE")
|
||||||
|
}
|
||||||
|
if d.SSHPublicKeyPath == "" {
|
||||||
|
d.SSHPublicKeyPath = os.Getenv("AWS_SSH_PUBLIC_KEY_FILE")
|
||||||
|
}
|
||||||
if d.SSHPrivateKeyPath == "" || d.SSHPublicKeyPath == "" {
|
if d.SSHPrivateKeyPath == "" || d.SSHPublicKeyPath == "" {
|
||||||
publicKeyPath, privateKeyPath, err := util.CreateSSHKeyPair(d.ClusterName)
|
publicKeyPath, privateKeyPath, err := util.CreateSSHKeyPair(d.ClusterName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -90,6 +96,12 @@ func (d *deployer) initialize() error {
|
||||||
d.GCPProject = resource.Name
|
d.GCPProject = resource.Name
|
||||||
klog.V(1).Infof("Got project %s from boskos", d.GCPProject)
|
klog.V(1).Infof("Got project %s from boskos", d.GCPProject)
|
||||||
|
|
||||||
|
if d.SSHPrivateKeyPath == "" {
|
||||||
|
d.SSHPrivateKeyPath = os.Getenv("GCE_SSH_PRIVATE_KEY_FILE")
|
||||||
|
}
|
||||||
|
if d.SSHPublicKeyPath == "" {
|
||||||
|
d.SSHPublicKeyPath = os.Getenv("GCE_SSH_PUBLIC_KEY_FILE")
|
||||||
|
}
|
||||||
if d.SSHPrivateKeyPath == "" && d.SSHPublicKeyPath == "" {
|
if d.SSHPrivateKeyPath == "" && d.SSHPublicKeyPath == "" {
|
||||||
privateKey, publicKey, err := gce.SetupSSH(d.GCPProject)
|
privateKey, publicKey, err := gce.SetupSSH(d.GCPProject)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -98,12 +110,15 @@ func (d *deployer) initialize() error {
|
||||||
d.SSHPrivateKeyPath = privateKey
|
d.SSHPrivateKeyPath = privateKey
|
||||||
d.SSHPublicKeyPath = publicKey
|
d.SSHPublicKeyPath = publicKey
|
||||||
}
|
}
|
||||||
|
|
||||||
d.createBucket = true
|
d.createBucket = true
|
||||||
} else if d.SSHPrivateKeyPath == "" && os.Getenv("KUBE_SSH_KEY_PATH") != "" {
|
} else if d.SSHPrivateKeyPath == "" && os.Getenv("KUBE_SSH_KEY_PATH") != "" {
|
||||||
d.SSHPrivateKeyPath = os.Getenv("KUBE_SSH_KEY_PATH")
|
d.SSHPrivateKeyPath = os.Getenv("KUBE_SSH_KEY_PATH")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
klog.V(1).Infof("Using SSH keypair: [%s,%s]", d.SSHPrivateKeyPath, d.SSHPublicKeyPath)
|
||||||
|
|
||||||
if d.commonOptions.ShouldBuild() {
|
if d.commonOptions.ShouldBuild() {
|
||||||
if err := d.verifyBuildFlags(); err != nil {
|
if err := d.verifyBuildFlags(); err != nil {
|
||||||
return fmt.Errorf("init failed to check build flags: %v", err)
|
return fmt.Errorf("init failed to check build flags: %v", err)
|
||||||
|
@ -113,6 +128,8 @@ func (d *deployer) initialize() error {
|
||||||
if d.SSHUser == "" {
|
if d.SSHUser == "" {
|
||||||
d.SSHUser = os.Getenv("KUBE_SSH_USER")
|
d.SSHUser = os.Getenv("KUBE_SSH_USER")
|
||||||
}
|
}
|
||||||
|
klog.V(1).Infof("Using SSH user: [%s]", d.SSHUser)
|
||||||
|
|
||||||
if d.TerraformVersion != "" {
|
if d.TerraformVersion != "" {
|
||||||
t, err := target.NewTerraform(d.TerraformVersion)
|
t, err := target.NewTerraform(d.TerraformVersion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue