Skip to content

feat(internal/cmd): Add 'instance tunnel' command#248

Draft
craciunoiuc wants to merge 2 commits into
stagingfrom
craciunoiuc/add-instance-tunnel
Draft

feat(internal/cmd): Add 'instance tunnel' command#248
craciunoiuc wants to merge 2 commits into
stagingfrom
craciunoiuc/add-instance-tunnel

Conversation

@craciunoiuc
Copy link
Copy Markdown
Member

@craciunoiuc craciunoiuc commented Apr 7, 2026

Nodes need this option --net-internal-traffic=vm in order to test it.

tunnel-3uhz1 │ [    0.141932] ERR:  [apptunlr] Target remote not in the same subnet.
tunnel-3uhz1 │ [    0.142826] ERR:  [apptunlr] Failed to hook TCP2TCP.

The Tunlr also needs updating to remove the check for inter-vm comms.
Done.

TODO: Update tests when platform is stable.

Blocked on: https://github.com/unikraft-cloud/platform/pull/705
Closes: TOOL-714

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new unikraft instance tunnel subcommand intended to forward a local port to a non-public instance via an intermediate TLS tunnel service, enabling testing scenarios that require internal VM traffic.

Changes:

  • Adds InstancesTunnelCmd to the instances command group.
  • Implements target parsing, instance/IP resolution, tunnel-proxy instance creation, and local-to-remote relaying over TLS.
  • Adds control-channel heartbeats to keep the tunnel service connection alive.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/cmd/instances.go Outdated
Comment thread internal/cmd/instances.go Outdated
Comment thread internal/cmd/instances.go Outdated
Comment thread internal/cmd/instances.go Outdated
Comment thread internal/cmd/instances.go Outdated
Comment thread internal/cmd/instances.go Outdated
Comment thread internal/cmd/instances.go Outdated
Comment thread internal/cmd/instances.go Outdated
@craciunoiuc craciunoiuc force-pushed the craciunoiuc/add-instance-tunnel branch 2 times, most recently from 49d2539 to 8ae136d Compare April 7, 2026 09:26
Comment thread internal/cmd/instances.go Outdated
Comment thread internal/cmd/instances.go
Comment thread internal/cmd/instances.go Outdated
Comment thread internal/cmd/instances.go Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/tunnel/tunnel.go
Comment thread internal/tunnel/tunnel.go Outdated
Comment thread internal/tunnel/tunnel.go Outdated
Comment thread internal/tunnel/tunnel.go Outdated
Comment thread internal/cmd/instances.go Outdated
Comment thread internal/cmd/instances.go
Comment thread internal/cmd/instances.go Outdated
Comment thread internal/cmd/instances.go Outdated
@craciunoiuc
Copy link
Copy Markdown
Member Author

I need to fix these + do one more pass so no rush

@craciunoiuc craciunoiuc force-pushed the craciunoiuc/add-instance-tunnel branch from 5e8f3e5 to b8e8437 Compare April 7, 2026 19:02
@craciunoiuc craciunoiuc requested a review from jedevc April 7, 2026 19:05
@craciunoiuc
Copy link
Copy Markdown
Member Author

Should be as decent as it gets, definitely an upgrade compared to kraftkit

@craciunoiuc craciunoiuc force-pushed the craciunoiuc/add-instance-tunnel branch from b8e8437 to a5b1451 Compare April 9, 2026 14:17
@craciunoiuc
Copy link
Copy Markdown
Member Author

Have to rebase the code and to generate tests on Monday.

@craciunoiuc craciunoiuc force-pushed the craciunoiuc/add-instance-tunnel branch 2 times, most recently from dcaf1a6 to c7622e6 Compare April 20, 2026 09:02
Copy link
Copy Markdown
Member

@jedevc jedevc left a comment

Choose a reason for hiding this comment

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

Needs a rebase, and to get the tests passing 🎉

Comment thread cmd/unikraft/instances_test.go Outdated
Comment thread internal/cmd/instances.go Outdated
Comment thread internal/cmd/instances.go Outdated
Comment thread internal/cmd/instances.go Outdated
Comment thread internal/cmd/instances.go Outdated
Comment thread internal/tunnel/relay.go Outdated
Comment thread internal/tunnel/relay.go Outdated
Comment thread internal/tunnel/tunnel.go Outdated
Comment thread internal/tunnel/tunnel.go Outdated
Comment thread internal/tunnel/tunnel.go Outdated
@craciunoiuc
Copy link
Copy Markdown
Member Author

I'll rebase and fix afterwards

@craciunoiuc craciunoiuc force-pushed the craciunoiuc/add-instance-tunnel branch 3 times, most recently from ccbfb69 to 1aa3b6d Compare May 5, 2026 17:24
@craciunoiuc
Copy link
Copy Markdown
Member Author

once you agree with the changes, I will fixup the fixup, and regenerate the tests once more

I am pretty sure I covered all your requests. It now even has multi-metro support

The API is now: New -> Run -> Start -> Terminate Lemme know if you want me to reword

I tested that the usual + new stuff still works

@craciunoiuc craciunoiuc requested a review from jedevc May 5, 2026 17:25
Signed-off-by: Cezar Craciunoiu <cezar@unikraft.io>
Signed-off-by: Cezar Craciunoiu <cezar@unikraft.io>
@craciunoiuc craciunoiuc force-pushed the craciunoiuc/add-instance-tunnel branch from 1aa3b6d to ad763de Compare May 25, 2026 14:44
@craciunoiuc craciunoiuc marked this pull request as draft May 25, 2026 14:44
@craciunoiuc craciunoiuc requested a review from Copilot May 25, 2026 14:58
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Comment on lines +149 to +167
var c *exec.Cmd
if args[0] == "unikraft" {
c = exec.CommandContext(t.Context(), env.unikraftPath, args[1:]...)
} else {
c = exec.CommandContext(t.Context(), args[0], args[1:]...)
}

c.Env = os.Environ()
c.Env = slices.DeleteFunc(c.Env, func(s string) bool {
return strings.HasPrefix(s, "UNIKRAFT_")
})
c.Env = append(c.Env, "NO_COLOR=1")
c.Env = append(c.Env, "UNIKRAFT_CONFIG="+env.configPath)
c.Env = append(c.Env, "BUILDKIT_PROGRESS=quiet")
c.Env = append(c.Env, resource.UnikraftSandboxEnv+"="+env.sandboxPath)
c.Cancel = func() error {
return c.Process.Signal(os.Interrupt)
}
c.WaitDelay = 30 * time.Second
}
time.Sleep(500 * time.Millisecond)
}
t.Errorf("timed out waiting for %s to become reachable", addr)
Comment thread internal/cmd/instances.go

TunnelProxyPorts []string `short:"p" name:"tunnel-proxy-port" help:"Remote port(s) exposed by the tunnel service. When a single value is given it is used as the starting port for multiple targets." default:"4444" hidden:""`
ProxyControlPort uint `short:"P" name:"tunnel-control-port" help:"Command-and-control port of the tunnel service." default:"4443" hidden:""`
TunnelServiceImage string ` name:"tunnel-image" help:"Image to use for the tunnel service." default:"official/utils/tunnel:1.0" hidden:""`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants