mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
connect: add nomad env to envoy bootstrap (#12959)
* Add nomad env to envoy bootstrap * Add changelog file
This commit is contained in:
3
.changelog/12959.txt
Normal file
3
.changelog/12959.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
```release-note:improvement
|
||||||
|
connect: add nomad environment variables to envoy bootstrap
|
||||||
|
```
|
||||||
@@ -292,6 +292,8 @@ func (h *envoyBootstrapHook) Prestart(ctx context.Context, req *ifs.TaskPrestart
|
|||||||
|
|
||||||
// Create environment
|
// Create environment
|
||||||
bootstrapEnv := bootstrap.env(os.Environ())
|
bootstrapEnv := bootstrap.env(os.Environ())
|
||||||
|
// append nomad environment variables to the bootstrap environment
|
||||||
|
bootstrapEnv = append(bootstrapEnv, h.groupEnv()...)
|
||||||
|
|
||||||
// Write env to file for debugging
|
// Write env to file for debugging
|
||||||
envFile, err := os.Create(bootstrapEnvPath)
|
envFile, err := os.Create(bootstrapEnvPath)
|
||||||
@@ -377,6 +379,19 @@ func (h *envoyBootstrapHook) Prestart(ctx context.Context, req *ifs.TaskPrestart
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *envoyBootstrapHook) groupEnv() []string {
|
||||||
|
return []string{
|
||||||
|
fmt.Sprintf("%s=%s", taskenv.AllocID, h.alloc.ID),
|
||||||
|
fmt.Sprintf("%s=%s", taskenv.ShortAllocID, h.alloc.ID[:8]),
|
||||||
|
fmt.Sprintf("%s=%s", taskenv.AllocName, h.alloc.Name),
|
||||||
|
fmt.Sprintf("%s=%s", taskenv.GroupName, h.alloc.TaskGroup),
|
||||||
|
fmt.Sprintf("%s=%s", taskenv.JobName, h.alloc.Job.Name),
|
||||||
|
fmt.Sprintf("%s=%s", taskenv.JobID, h.alloc.Job.ID),
|
||||||
|
fmt.Sprintf("%s=%s", taskenv.Namespace, h.alloc.Namespace),
|
||||||
|
fmt.Sprintf("%s=%s", taskenv.Region, h.alloc.Job.Region),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// buildEnvoyAdminBind determines a unique port for use by the envoy admin listener.
|
// buildEnvoyAdminBind determines a unique port for use by the envoy admin listener.
|
||||||
//
|
//
|
||||||
// This listener will be bound to 127.0.0.2.
|
// This listener will be bound to 127.0.0.2.
|
||||||
|
|||||||
Reference in New Issue
Block a user