-
Notifications
You must be signed in to change notification settings - Fork 40
Add host.ssh_port option and refactor gateway initialization #1090
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
PTAL |
This probably still needs some way to track clients that are using the gateway, otherwise it will shutdown a gateway that is still used by some other client. #1088 will likely need something from this. |
Files changed: 28. Seems like this grew out of proportion. |
lib/pharos/transport/ssh.rb
Outdated
def bastion | ||
@bastion ||= @opts.delete(:bastion) | ||
def to_s | ||
"SSH #{host.user}@#{host.address}:#{host.ssh_port}#{' using proxy command' if host.ssh_proxy_command}#{" via #{@gateway}->127.0.0.1:#{@port} " if @gateway}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E2e now uses bastion and proxy command |
…ros-cluster into feature/gateway_refactorings
Conflict.. |
…ros-cluster into feature/gateway_refactorings
Unconflict.. |
lib/pharos/configuration/host.rb
Outdated
def short_hostname | ||
return nil unless hostname | ||
|
||
hostname.split('.').first | ||
end | ||
|
||
# @return [Hash] | ||
def ssh_options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO this should be under Transport
(for example Transport::SshHelpers
module)
lib/pharos/configuration/host.rb
Outdated
end | ||
|
||
# @return [Pharos::Transport::Gateway] | ||
def gateway |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not completely happy about the idea that Host
is becoming a "god" object that knows everything. For example gateway
requires host
and Host
requires Gateway
because of kube_client
🤔 /cc @jnummelin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably all ssh specific stuff should be under Transport (somehow).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree. Now Host
, Bastion
, Gateway
all entangle pretty badly and really hard to follow which is used where.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved stuff around.
Now there's Pharos::Kube::Client
that understands Configuration::Host
, so that host can just do @kube_client ||= Pharos::Kube::Client.new(self)
.
The host ssh options are generated in Pharos::Transport::SSH.options_for(host)
.
The Host
now has:
def gateway; @gateway ||= Pharos::Transport::Gateway.new(self); end
def transport; @transport ||= Pharos::Transport.for(self); end
def kube_client; @kube_client ||= Pharos::Kube::Client.new(self); end
def disconnect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternative to having these memoized in Host I guess would be to go back to
Pharos::SshManager.clients[host.address]
/ Pharos::GatewayManager.gateways[host.address]
type of connection collections or maybe have some sort of Pharos::Transport
delegator/decorator and just have host.transport
and all those kube_client / exec / file / gateway
stuff would be contained there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO the latter sounds pretty good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think that gateway
should be masked behind transport
. Transport already gets host (like Gateway) as a parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kke @jnummelin are you fine with gateway
being here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm now WIPping with https://github.com/kontena/net-ssh-proxy-gateway
…eature/gateway_refactorings
Fixes #1062
Fixes #1072
Fixes #1088
Replaces #1071
Adds
ssh_port
option to host options:And bastion options:
Refactored the
Net::SSH::Gateway
fromSSH::Client#gateway
toTransport::Gateway
for better control (should benefit the disconnecting in #1003) and becausebastion.host.ssh.gateway
opened extra SSH connections.Also adds the missing
ssh_proxy_command
attribute to bastion.All k8s-client traffic is now tunneled through ssh.
ConfigureClient
phase is replaced withWarmUpClientCache
phase.