Skip to content
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

[Feature] Support docker over ssh (#324, @ekristen & @inercia) #324

Merged
merged 8 commits into from
Feb 4, 2021

Conversation

ekristen
Copy link
Contributor

@ekristen ekristen commented Aug 8, 2020

  • switches to using docker/cli @ 19.03
  • introduces helper function for getting the docker client so docker over SSH can be supported
  • also attempt to use remote docker host for API host info for kubeconfig

@iwilltry42 iwilltry42 added the enhancement New feature or request label Aug 12, 2020
@iwilltry42 iwilltry42 added this to the 3.1.0 milestone Aug 12, 2020
@iwilltry42 iwilltry42 self-assigned this Aug 12, 2020
@iwilltry42 iwilltry42 self-requested a review August 12, 2020 10:29
Copy link
Member

@iwilltry42 iwilltry42 left a comment

Choose a reason for hiding this comment

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

Thanks for this PR! :)
It already looks pretty good 👍
I just added two small comments and have yet to try it myself.

@@ -297,7 +297,13 @@ func patchServerSpec(node *k3d.Node) error {
node.Labels[k3d.LabelServerAPIHost] = node.ServerOpts.ExposeAPI.Host
node.Labels[k3d.LabelServerAPIPort] = node.ServerOpts.ExposeAPI.Port

node.Args = append(node.Args, "--tls-san", node.ServerOpts.ExposeAPI.Host) // add TLS SAN for non default host name
// If the runtime is docker, attempt to use the docker host
if runtime.ID() == "docker" && runtime.GetHost() != "" {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if runtime.ID() == "docker" && runtime.GetHost() != "" {
if runtime.GetHost() != "" {

If runtimes which don't support this just return an empty string, we can drop this runtime-specific check here, right?

Comment on lines 297 to 306
node.Labels[k3d.LabelServerAPIHost] = node.ServerOpts.ExposeAPI.Host
node.Labels[k3d.LabelServerAPIPort] = node.ServerOpts.ExposeAPI.Port

node.Args = append(node.Args, "--tls-san", node.ServerOpts.ExposeAPI.Host) // add TLS SAN for non default host name
// If the runtime is docker, attempt to use the docker host
if runtime.ID() == "docker" && runtime.GetHost() != "" {
node.Labels[k3d.LabelServerAPIHostIP] = runtime.GetHost()
node.Labels[k3d.LabelServerAPIHost] = runtime.GetHost()
}

node.Args = append(node.Args, "--tls-san", node.Labels[k3d.LabelServerAPIHost]) // add TLS SAN for non default host name
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we then already error out if a different Host was set for the ExposeAPI.Host?

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 don't believe so, but this is also where things get a bit wonky. From what I could tell the APIHost and APIHostIP almost exclusively assumed local host and 0.0.0.0 was going to be the value.

I originally tried just overriding APIHostIP globally at run-time via a --host parameter but that severely broke things in a number of ways, to include docker port forwarding.

That's when I found the TODO note a few lines up stating maybe this should be the IP of the docker host, that's when I added the runtime.ID() and runtime.GetHost() so that if we are on a remote host we set it on the label.

Copy link
Member

Choose a reason for hiding this comment

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

Yep, what I meant was that we should throw an error or a warning when a user uses a remote docker connection (i.e. has the DOCKER_HOST env var set) but also tries to override the APIHost in the --api-port flag.

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 see, yes that could be a problem.

@iwilltry42 iwilltry42 changed the title Support docker over ssh [Feature] Support docker over ssh Sep 2, 2020
@iwilltry42 iwilltry42 modified the milestones: 3.1.0, 3.2.0 Oct 6, 2020
@iwilltry42
Copy link
Member

Hey @ekristen , are you still working on this? :)

@iwilltry42 iwilltry42 removed this from the 3.2.0 milestone Nov 24, 2020
@ekristen
Copy link
Contributor Author

@iwilltry42 I got it working locally, but didn't have the time to see to the requested changes just yet. Thanks for bringing it back to my attention. I'll see if I can find some time to come back to this.

@inercia
Copy link
Collaborator

inercia commented Jan 12, 2021

Any progress on this?

@inercia
Copy link
Collaborator

inercia commented Jan 22, 2021

I've just rebased this PR on top of main. It seems to be working locally for me. @iwilltry42 could you take a look when you have some time?

go.mod Show resolved Hide resolved
pkg/client/node.go Outdated Show resolved Hide resolved
pkg/runtimes/docker/docker.go Show resolved Hide resolved
pkg/client/node.go Outdated Show resolved Hide resolved
pkg/client/node.go Outdated Show resolved Hide resolved
@iwilltry42 iwilltry42 changed the title [Feature] Support docker over ssh [Feature] Support docker over ssh (#324, @ekristen & @inercia) Feb 4, 2021
@iwilltry42 iwilltry42 merged commit 63d5484 into k3d-io:main Feb 4, 2021
rancherio-gh-m pushed a commit that referenced this pull request Feb 4, 2021
Author: Erik Kristensen <erik@erikkristensen.com>
Date:   Thu Feb 4 08:54:49 2021 -0800

    [Feature] Support docker over ssh (#324, @ekristen & @inercia)
@ekristen
Copy link
Contributor Author

ekristen commented Feb 5, 2021

@iwilltry42 thanks for finishing it up and merging. Apologies for my lack of response. I've been extraordinarily busy and have been playing catch up on email this week.

@iwilltry42
Copy link
Member

All thanks to @inercia here 👍
Good job of the both of you 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants