hashicorp / hashicorp/nomad

Port selection for Connect envoy when network.port.to is used

Open
#9,824 3 comments 0 reactions 0 assignees View on GitHub
theme/consul/connect
Dominant language
Go
Stars
17k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
105

Description

### Nomad version
Nomad v1.0.2 (4c1d4fc6a5823ebc8c3e748daec7b4fda3f11037)

### Operating system and Environment details
- Ubuntu 20.04.1 LTS
- Running with docker driver, docker version: 19.03.8

### Issue

Given a job that looks like this:

```hcl
job "takeout" {
type = "service"
datacenters = ["dc1"]

group "pizzeria" {
network {
mode = "bridge"

port "http" {
to = 5000
}
}

service {
name = "pizza"
port = "http"

connect {
sidecar_service {}
}
}

task "server" { ... }
}
}
```

The envoy sidecar will get configured to connect to `127.0.0.1:12345` where 12345 is the dynamic port allocated for `http`. That may not connect! (In my setup that port is on the host's interface instead.) It should be the `to` port.

Current workaround is to specify:

```hcl
sidecar_service {
proxy {
local_service_port = 5000
}
}
```

This may possibly be related to #9730?

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the supplied Nomad v1.0.2 job with bridge networking and the Docker driver. Trace Connect sidecar port selection when network.port.to is set, then add coverage showing Envoy uses the configured destination port rather than the dynamically allocated host port; the workaround should no longer be needed.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend, networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.