mirror of https://github.com/kubernetes/kops.git
Don't provision SSH key by default on AWS
This commit is contained in:
parent
67cfa9d4d4
commit
e6ede8f4a9
|
@ -241,7 +241,7 @@ func NewCmdCreateCluster(f *util.Factory, out io.Writer) *cobra.Command {
|
||||||
return []string{"containerd", "docker"}, cobra.ShellCompDirectiveNoFileComp
|
return []string{"containerd", "docker"}, cobra.ShellCompDirectiveNoFileComp
|
||||||
})
|
})
|
||||||
|
|
||||||
cmd.Flags().StringVar(&sshPublicKey, "ssh-public-key", sshPublicKey, "SSH public key to use (defaults to ~/.ssh/id_rsa.pub on AWS)")
|
cmd.Flags().StringVar(&sshPublicKey, "ssh-public-key", sshPublicKey, "SSH public key to use")
|
||||||
cmd.RegisterFlagCompletionFunc("ssh-public-key", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
cmd.RegisterFlagCompletionFunc("ssh-public-key", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||||
return []string{"pub"}, cobra.ShellCompDirectiveFilterFileExt
|
return []string{"pub"}, cobra.ShellCompDirectiveFilterFileExt
|
||||||
})
|
})
|
||||||
|
@ -700,8 +700,7 @@ func RunCreateCluster(ctx context.Context, f *util.Factory, out io.Writer, c *Cr
|
||||||
if len(c.SSHPublicKeys) == 0 {
|
if len(c.SSHPublicKeys) == 0 {
|
||||||
autoloadSSHPublicKeys := true
|
autoloadSSHPublicKeys := true
|
||||||
switch c.CloudProvider {
|
switch c.CloudProvider {
|
||||||
case "gce":
|
case "gce", "aws":
|
||||||
// We don't normally use SSH keys on GCE
|
|
||||||
autoloadSSHPublicKeys = false
|
autoloadSSHPublicKeys = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ kops create cluster [CLUSTER] [flags]
|
||||||
-o, --output string Output format. One of json or yaml. Used with the --dry-run flag.
|
-o, --output string Output format. One of json or yaml. Used with the --dry-run flag.
|
||||||
--project string Project to use (must be set on GCE)
|
--project string Project to use (must be set on GCE)
|
||||||
--ssh-access strings Restrict SSH access to this CIDR. If not set, uses the value of the admin-access flag.
|
--ssh-access strings Restrict SSH access to this CIDR. If not set, uses the value of the admin-access flag.
|
||||||
--ssh-public-key string SSH public key to use (defaults to ~/.ssh/id_rsa.pub on AWS)
|
--ssh-public-key string SSH public key to use
|
||||||
--subnets strings Shared subnets to use
|
--subnets strings Shared subnets to use
|
||||||
--target string Valid targets: direct, terraform, cloudformation. Set this flag to terraform if you want kOps to generate terraform (default "direct")
|
--target string Valid targets: direct, terraform, cloudformation. Set this flag to terraform if you want kOps to generate terraform (default "direct")
|
||||||
-t, --topology string Network topology for the cluster: public or private (default "public")
|
-t, --topology string Network topology for the cluster: public or private (default "public")
|
||||||
|
|
|
@ -23,6 +23,9 @@ spec:
|
||||||
|
|
||||||
## Other significant changes
|
## Other significant changes
|
||||||
|
|
||||||
|
* New clusters on AWS will no longer provision an SSH public key by default. To provision
|
||||||
|
an SSH public key on a new cluster, use the `--ssh-public-key` flag to `kops create cluster`.
|
||||||
|
|
||||||
* The kOps Terraform support now renders managed files through the Terraform configuration instead
|
* The kOps Terraform support now renders managed files through the Terraform configuration instead
|
||||||
of writing them to S3 directly. This defers changes to these files until the time of `terraform apply`.
|
of writing them to S3 directly. This defers changes to these files until the time of `terraform apply`.
|
||||||
This feature may be temporarily disabled by turning off the `TerraformManagedFiles` feature flag
|
This feature may be temporarily disabled by turning off the `TerraformManagedFiles` feature flag
|
||||||
|
|
|
@ -333,11 +333,14 @@ func (b *KopsModelContext) UseEtcdTLS() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// UseSSHKey returns true if SSHKeyName from the cluster spec is not set to an empty string (""). Setting SSHKeyName
|
// UseSSHKey returns true if SSHKeyName from the cluster spec is set to a nonempty string
|
||||||
// to an empty string indicates that an SSH key should not be set on instances.
|
// or there is an SSH public key provisioned in the key store.
|
||||||
func (b *KopsModelContext) UseSSHKey() bool {
|
func (b *KopsModelContext) UseSSHKey() bool {
|
||||||
sshKeyName := b.Cluster.Spec.SSHKeyName
|
sshKeyName := b.Cluster.Spec.SSHKeyName
|
||||||
return sshKeyName == nil || *sshKeyName != ""
|
if sshKeyName == nil {
|
||||||
|
return len(b.SSHPublicKeys) > 0
|
||||||
|
}
|
||||||
|
return *sshKeyName != ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// KubernetesVersion parses the semver version of kubernetes, from the cluster spec
|
// KubernetesVersion parses the semver version of kubernetes, from the cluster spec
|
||||||
|
|
|
@ -417,10 +417,6 @@ func (c *ApplyClusterCmd) Run(ctx context.Context) error {
|
||||||
modelContext.AWSAccountID = accountID
|
modelContext.AWSAccountID = accountID
|
||||||
modelContext.AWSPartition = partition
|
modelContext.AWSPartition = partition
|
||||||
|
|
||||||
if len(sshPublicKeys) == 0 && c.Cluster.Spec.SSHKeyName == nil {
|
|
||||||
return fmt.Errorf("SSH public key must be specified when running with AWS (create with `kops create secret --name %s sshpublickey admin -i ~/.ssh/id_rsa.pub`)", cluster.ObjectMeta.Name)
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(sshPublicKeys) > 1 {
|
if len(sshPublicKeys) > 1 {
|
||||||
return fmt.Errorf("exactly one 'admin' SSH public key can be specified when running with AWS; please delete a key using `kops delete secret`")
|
return fmt.Errorf("exactly one 'admin' SSH public key can be specified when running with AWS; please delete a key using `kops delete secret`")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue