Skip to content

Provide default SSH access to machines #416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

akutz
Copy link
Contributor

@akutz akutz commented Jul 7, 2019

What this PR does / why we need it:
This patch introduces a new field to the ClusterProviderSpec: SSHKeyPair. This field will automatically be populated with a public and private key that may be used to access machines deployed to the cluster.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #413

Special notes for your reviewer:

Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

Release note:

* Provide default SSH access to machines

@akutz akutz added this to the 0.3.1 milestone Jul 7, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: akutz

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 7, 2019
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 7, 2019
@akutz
Copy link
Contributor Author

akutz commented Jul 7, 2019

/assign @figo

@akutz akutz force-pushed the feature/generate-default-ssh-key-pair branch from 5be4cf5 to babf94b Compare July 7, 2019 16:30
@moshloop
Copy link

moshloop commented Jul 8, 2019

Why is this needed? Accessing a machine via SSH would be an anti-pattern in most cases?

@akutz
Copy link
Contributor Author

akutz commented Jul 8, 2019

Why is this needed? Accessing a machine via SSH would be an anti-pattern in most cases?

Hi @moshloop,

I disagree that this is anti-pattern. The CAPA provider uses AWS's native ability to inject SSH keys into machines to do the same. This is to enhance CAPV to support a default key pair for remote access.

In another location you asked how this differs from SSHAuthorizedKeys. I attempted to explain that in the GoDocs:

SSHKeyPair is the SSH key pair for accessing provisioned machines. This field is set at runtime and should not be assigned by an operator. Providing access to existing SSH keys is handled by SSHAuthorizedKeys. Please see SSHAuthorizedKeys for information on accessing the machines.

In other words, SSHKeyPair is always generated to guarantee there is a means to remotely access a provisioned machine. The field SSHAuthorizedKeys is for operators to provide additional public keys that should be granted access.

@akutz
Copy link
Contributor Author

akutz commented Jul 8, 2019

Hi @frapposelli / @ncdc ,

I'd love your opinions on this. Thanks!

@akutz akutz force-pushed the feature/generate-default-ssh-key-pair branch from babf94b to e23ef9f Compare July 8, 2019 15:46
@moshloop
Copy link

moshloop commented Jul 8, 2019

The CAPA provider uses AWS's native ability to inject SSH keys into machines to do the same.

Unless I am mistaken, CAPA specifies the SSH Key Name for AWS to inject, however, that Key refers to a public key only, the private key needs to be saved externally to AWS

@akutz
Copy link
Contributor Author

akutz commented Jul 8, 2019

Hi @moshloop,

That's correct, but the point is that it guarantees there's always SSH access if desired. This change doesn't inject a private key. It just generates a key pair to ensure there's always SSH access, even if someone neglected to add something to SSHAuthorizedKeys.

@ncdc
Copy link
Contributor

ncdc commented Jul 8, 2019

I'm torn on this one. SSH access may be nice, and if you forget to set the authorized keys, this is a nice fallback. On the other hand, we want to be moving away from storing secret data in resources other than secrets (although this is adding "just one more" to a set of secrets in the spec).

How would you feel about generating a secret instead and storing a ref to it in the spec?

I'm also curious for @detiber's take since he predates me on the project.

@akutz
Copy link
Contributor Author

akutz commented Jul 8, 2019

Hi @ncdc,

I totally agree. I even brought this up in another conversation. The issue that I raised there is that cluserctl doesn't really support a first-class notion of a secrets.yaml or some manner to inject secret data into the bootstrap cluster. Else I would do this that way. That would also require secrets created pre-pivot be automatically moved to the initial target/management cluster a la kubernetes-sigs/cluster-api#1112.

How would you feel about generating a secret instead and storing a ref to it in the spec?

Again, I'd love to do this. I wouldn't even use a ref, just a well-known name (much like the kubeconfig secret). The issue is how that gets injected pre-pivot as well as how it is transferred as part of the pivot.

Copy link
Contributor

@figo figo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me, a nit below

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 8, 2019
@akutz akutz force-pushed the feature/generate-default-ssh-key-pair branch from e23ef9f to 6eeb7e7 Compare July 11, 2019 22:35
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 11, 2019
This patch introduces a new field to the ClusterProviderSpec:
"SSHKeyPair". This field will automatically be populated with a public
and private key that may be used to access machines deployed to the
cluster.
@akutz akutz force-pushed the feature/generate-default-ssh-key-pair branch from 6eeb7e7 to 97796d4 Compare July 11, 2019 22:39
@moshloop
Copy link

@randomvariable do you have any comments on this from a CIS perspective?

@randomvariable
Copy link
Member

The CIS benchmark for Kubernetes doesn't have anything to say on SSH access as it's a not related to Kubernetes itself.

FWIW, if we haven't already for CAPA, we were definitely going to make SSH access optional in case people wanted to use other things like SSH certificates, LDAP or AWS SSM Session Manager.

@frapposelli
Copy link
Member

Should the generation of the key pair (if not provided) be delegated to clusterctl?

@ncdc
Copy link
Contributor

ncdc commented Jul 15, 2019

clusterctl is somewhat "frozen" pending the outcome of kubernetes-sigs/cluster-api#1065 and kubernetes-sigs/cluster-api#1085

@frapposelli
Copy link
Member

@ncdc clusterctl or whatever tool triggers the creation of a cluster, in other words, not letting the provider create those keys.

@k8s-ci-robot
Copy link
Contributor

@akutz: The following tests failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-cluster-api-provider-vsphere-e2e 97796d4 link /test pull-cluster-api-provider-vsphere-e2e
pull-cluster-api-provider-vsphere-verify-lint 97796d4 link /test pull-cluster-api-provider-vsphere-verify-lint
pull-cluster-api-provider-vsphere-verify-crds 97796d4 link /test pull-cluster-api-provider-vsphere-verify-crds
pull-cluster-api-provider-vsphere-test 97796d4 link /test pull-cluster-api-provider-vsphere-test
pull-cluster-api-provider-vsphere-verify-vet 97796d4 link /test pull-cluster-api-provider-vsphere-verify-vet
pull-cluster-api-provider-vsphere-verify-fmt 97796d4 link /test pull-cluster-api-provider-vsphere-verify-fmt

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot
Copy link
Contributor

@akutz: PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 17, 2019
@akutz akutz modified the milestones: 0.4.0, Next Jul 17, 2019
@akutz
Copy link
Contributor Author

akutz commented Aug 28, 2019

/close

@k8s-ci-robot
Copy link
Contributor

@akutz: Closed this PR.

In response to this:

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

generate ssh key pair for VM if user does not set sshAuthorizedKeys
7 participants