Skip to content
This repository has been archived by the owner on Jul 25, 2022. It is now read-only.

gardenctl ssh improvement #195

Closed
wants to merge 0 commits into from
Closed

Conversation

tedteng
Copy link
Contributor

@tedteng tedteng commented Apr 27, 2020

What this PR does / why we need it:

  • fix: check if bastion host exists, avoid multiple bastions create and occupied source in cloud
  • add: waiting instance-status.status,Values=ok then ssh (ssh timeout due to status check initiating)
    image
Warning: Permanently added '<some-public-ip>' (ECDSA) to the list of known hosts.
channel 0: open failed: connect failed: Connection timed out
stdio forwarding failed
kex_exchange_identification: Connection closed by remote host
exit status 255
  • add: use exist global flags -c trigger clear up function gardenctl ssh xxxx -c
  • add: check ssh rule if exist avoid blocked the deletion flow.
(2/3) Close SSH Port on Node.

An error occurred (InvalidPermission.NotFound) when calling the RevokeSecurityGroupIngress operation: The specified rule does not exist in this security group.

Which issue(s) this PR fixes:
Fixes #191
Fixes #192

Special notes for your reviewer:
global flags testing
gardenctl ssh (any hostname) -c
image

gardenctl ssh and exit
image

Release note:

improvement operator handling of external resources relate with bastion instance in was, manual gracefully deleted by global flags enable

@gardener-robot-ci-1 gardener-robot-ci-1 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Apr 27, 2020
@gardener-robot-ci-3 gardener-robot-ci-3 added needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Apr 27, 2020
@gardener-robot-ci-3 gardener-robot-ci-3 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Apr 29, 2020
@gardener-robot-ci-1 gardener-robot-ci-1 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Apr 29, 2020
@vpnachev
Copy link
Contributor

This PR is not fixing #192.

@tedteng
Copy link
Contributor Author

tedteng commented Apr 30, 2020

This PR is not fixing #192.

@vpnachev , the current fix is able to remove bastion resources include (ec2 , sg, 22 rules) manually if there any resource leaking. in #192 do you mean I need to refactor ssh, call CRD create term- pod then get through term- pod to access node instead of current ssh method? Is that idea want to achieve it?

@vpnachev
Copy link
Contributor

My idea is gardenctl to use machine.sapcloud.io/v1alpha1.Machine resource for the bastion host and let the MCM do the real work on creating/deleting these VMs. This approach is applicable for any cloud provider, not only AWS.

The implementation is, of course cloud dependent because on some providers, e.g. Azure, a public IP is directly attached to the VM and a bastion is not used.

@tedteng
Copy link
Contributor Author

tedteng commented Apr 30, 2020

more discuss in #192 if relate with #192
this PR only for #191

@gardener-robot-ci-1 gardener-robot-ci-1 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label May 11, 2020
@gardener-robot-ci-2 gardener-robot-ci-2 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label May 11, 2020
@gardener-robot-ci-1 gardener-robot-ci-1 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels May 12, 2020
@tedteng
Copy link
Contributor Author

tedteng commented May 12, 2020

sign-off

  • no extra resources generated on Cloud Provider when using SSH Pod.

  • able to SSH AWS, AZURE, GCP, ALICLOUD, OPENSTACK now

  • gardenctl ssh xxxxx use Pod as jump box as default way. flag --j will use Bastion VM as a jump box gardenctl ssh --j xxxx

  • global flag -c also able to use for cleanup AWS Bastion VM gardenctl ssh -c xxx

  • bugs fix


Openstack SSH Tesing result
image

Azure SSH Testing result
image

GCP SSH Testing result
image

AWS SSH Testing result
image

@gardener-robot-ci-3 gardener-robot-ci-3 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label May 12, 2020
@gardener-robot-ci-2 gardener-robot-ci-2 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label May 12, 2020
Copy link
Contributor

@DockToFuture DockToFuture left a comment

Choose a reason for hiding this comment

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

Thanks, the PR looks very good. Just a few minor things in the comments. Can you please also rebase the PR?

pkg/cmd/ssh.go Outdated
return nil
},
}

cmd.Flags().BoolVar(&bastionVM, "j", false, "Use Bastion VM as jump box")
Copy link
Contributor

Choose a reason for hiding this comment

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

Please replace by
cmd.Flags().BoolVarP(&bastionVM, "jumpbox", "j", false, "Use Bastion VM as jump box")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am using local flags that seem not to support it.

too many arguments in call to cmd.Flags().BoolVar
	have (*bool, string, string, bool, string)
	want (*bool, string, bool, string)go

@@ -64,15 +64,21 @@ func sshToAWSNode(nodeName, path, user, pathSSKeypair string, sshPublicKey []byt
a.createBastionHostSecurityGroup()
fmt.Println("")

// if global flag -c is specified call cleanupAwsBastionHost
Copy link
Contributor

Choose a reason for hiding this comment

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

I would rather name the flag cleanup to make things more clear. Maybe we can also document it in the readme. We only have this for aws. In my opinion it would also make sense to add this for the other infrastructures, what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure.
due to -c already use by no-cache, I change to -e as erase

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with you, regarding the other infrastructures. I will work on that.

@gardener-robot-ci-2 gardener-robot-ci-2 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label May 25, 2020
@gardener-robot-ci-1 gardener-robot-ci-1 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels May 25, 2020
Copy link
Contributor Author

@tedteng tedteng left a comment

Choose a reason for hiding this comment

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

Readme add

pkg/cmd/ssh.go Outdated
return nil
},
}

cmd.Flags().BoolVar(&bastionVM, "j", false, "Use Bastion VM as jump box")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am using local flags that seem not to support it.

too many arguments in call to cmd.Flags().BoolVar
	have (*bool, string, string, bool, string)
	want (*bool, string, bool, string)go

@gardener-robot-ci-3 gardener-robot-ci-3 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label May 25, 2020
@gardener-robot-ci-2 gardener-robot-ci-2 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label May 26, 2020
@gardener-robot-ci-3 gardener-robot-ci-3 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label May 26, 2020
@gardener-robot-ci-3 gardener-robot-ci-3 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label May 28, 2020
@gardener-robot-ci-1 gardener-robot-ci-1 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label May 28, 2020
@tedteng tedteng closed this May 29, 2020
@gardener-robot-ci-2 gardener-robot-ci-2 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label May 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD) reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve handling of external resources gardenctl ssh does not work
6 participants