-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
In case cluster operators work with more than 1 Nomad cluster, setting env variables can become a bit cumbersome. I assume most people would have written some sort of shell script wrappers to switch "context" to different cluster.
Proposal
We could make switching contexts easy if Nomad can support reading this information not just from command line flag/env variables but a "config" file. Similar to kubeconfig file, which has a proper spec to define cluster endpoint, namespace, token (RBAC) details.
We could come up with a spec similar to that of kubeconfig for Nomad. context.hcl, probably? Then Nomad could parse this file for each nomad CLI command. The increasing order of precedence in which the variables would be read:
- Config file
- Env Vars
- Command Line flags
I think we could even come up with small utils that can in-place modify the config file to switch the current context (cluster/namespace) like:
nomad switch-context dc1
nomad switch-namespace team-hashi
Use-cases
This would be helpful to eliminate any kind of shell scipts to populate ENV Vars for operators working on multiple Nomad clusters.
Attempted Solutions
I am attempting this as a standalone utility, but wanted to put it out here if there's an interest to see this merged upstream. If yes, then I can send a PR :)