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

Revert the default port forwarder to SSH #2864

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions pkg/hostagent/hostagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -654,8 +654,18 @@ func (a *HostAgent) processGuestAgentEvents(ctx context.Context, client *guestag
for _, f := range ev.Errors {
logrus.Warnf("received error from the guest: %q", f)
}
env, _ := strconv.ParseBool(os.Getenv("LIMA_SSH_PORT_FORWARDER"))
if env {
// useSSHFwd was false by default in v1.0, but reverted to true by default in v1.0.1
// due to stability issues
useSSHFwd := true
if envVar := os.Getenv("LIMA_SSH_PORT_FORWARDER"); envVar != "" {
b, err := strconv.ParseBool(os.Getenv("LIMA_SSH_PORT_FORWARDER"))
if err != nil {
logrus.WithError(err).Warnf("invalid LIMA_SSH_PORT_FORWARDER value %q", envVar)
} else {
useSSHFwd = b
}
}
if useSSHFwd {
a.portForwarder.OnEvent(ctx, ev)
} else {
a.grpcPortForwarder.OnEvent(ctx, client, ev)
Expand Down
17 changes: 12 additions & 5 deletions website/content/en/docs/config/Port/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@ Lima supports automatic port-forwarding of localhost ports from guest to host.

## Port forwarding types

Lima supports two port forwarders: SSH and GRPC.

The default port forwarder is SSH.

The default was once changed to GRPC in Lima v1.0, but it was reverted to SSH in v1.0.1 due to stability reasons.
In future, it is expected that GRPC will take over the default position again.

### Using SSH

SSH based port forwarding is the default and current model that is supported in Lima prior to v1.0.
SSH based port forwarding is the default and current model that is supported in Lima.

To use SSH forwarding use the below command
To explicitly use SSH forwarding use the below command

```bash
LIMA_SSH_PORT_FORWARDER=true limactl start
Expand All @@ -22,18 +29,18 @@ LIMA_SSH_PORT_FORWARDER=true limactl start
- Doesn't support UDP based port forwarding
- Spans child process on host for running SSH master.

### Using GRPC (Default since Lima v1.0)
### Using GRPC

| ⚡ Requirement | Lima >= 1.0 |
|---------------|-------------|

In this model, lima uses existing GRPC communication (Host <-> Guest) to tunnel port forwarding requests.
For each port forwarding request, a GRPC tunnel is created and this will be used for transmitting data

To disable this feature and use SSH forwarding use the following environment variable
To enable this feature, set `LIMA_SSH_PORT_FORWARDER` to `false`:

```bash
LIMA_SSH_PORT_FORWARDER=true limactl start
LIMA_SSH_PORT_FORWARDER=false limactl start
```

#### Advantages
Expand Down
Loading