mirror of
https://github.com/kemko/nomad.git
synced 2026-01-07 19:05:42 +03:00
tr: expose envoy sidecar admin port as environment variable
This commit is contained in:
@@ -13,12 +13,16 @@ import (
|
||||
"github.com/hashicorp/nomad/client/allocdir"
|
||||
"github.com/hashicorp/nomad/client/allocrunner/interfaces"
|
||||
agentconsul "github.com/hashicorp/nomad/command/agent/consul"
|
||||
"github.com/hashicorp/nomad/helper"
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
)
|
||||
|
||||
var _ interfaces.TaskPrestartHook = &envoyBootstrapHook{}
|
||||
|
||||
const envoyBaseAdminPort = 19000
|
||||
const (
|
||||
envoyBaseAdminPort = 19000
|
||||
envoyAdminBindEnvPrefix = "NOMAD_ENVOY_ADMIN_ADDR_"
|
||||
)
|
||||
|
||||
// envoyBootstrapHook writes the bootstrap config for the Connect Envoy proxy
|
||||
// sidecar.
|
||||
@@ -82,6 +86,7 @@ func (h *envoyBootstrapHook) Prestart(ctx context.Context, req *interfaces.TaskP
|
||||
// are running, the bind addresses need to have unique ports.
|
||||
// TODO: support running in host netns, using freeport to find available port
|
||||
envoyAdminBind := buildEnvoyAdminBind(h.alloc, req.Task.Name)
|
||||
resp.Env[helper.CleanEnvVar(envoyAdminBindEnvPrefix+serviceName, '_')] = envoyAdminBind
|
||||
|
||||
// Envoy bootstrap configuration may contain a Consul token, so write
|
||||
// it to the secrets directory like Vault tokens.
|
||||
|
||||
@@ -161,4 +161,11 @@
|
||||
Consul Connect <a href="/docs/job-specification/upstreams.html">upstream</a>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>NOMAD_ENVOY_ADMIN_ADDR_<service></tt></td>
|
||||
<td>
|
||||
Local address <tt>localhost:Port</tt> for the admin port of the envoy sidecar for the
|
||||
given <tt>service</tt> when defined as a Consul Connect enabled service.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
Reference in New Issue
Block a user