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

nomad job inject environment variables to containers #7

Open
dyrnq opened this issue Feb 20, 2023 · 3 comments
Open

nomad job inject environment variables to containers #7

dyrnq opened this issue Feb 20, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@dyrnq
Copy link
Owner

dyrnq commented Feb 20, 2023

eg. HOST_IP

@dyrnq dyrnq added the enhancement New feature or request label Feb 20, 2023
@dyrnq
Copy link
Owner Author

dyrnq commented Feb 20, 2023

xref hashicorp/nomad#2429

@dyrnq
Copy link
Owner Author

dyrnq commented Feb 20, 2023

NOMAD_REGION=global
CHARSET=UTF-8
NOMAD_CPU_LIMIT=100
HOSTNAME=netshoot
NOMAD_HOST_PORT_http=24803
NOMAD_JOB_ID=netshoot-2
NOMAD_TASK_NAME=netshoot-task-2
PWD=/root
NOMAD_SECRETS_DIR=/secrets
NOMAD_HOST_ADDR_http=10.0.2.15:24803
DB_USER=web
HOME=/root
LANG=C.UTF-8
NOMAD_NAMESPACE=default
NOMAD_IP_http=10.0.2.15
NOMAD_ALLOC_INDEX=0
NOMAD_ALLOC_DIR=/alloc
NOMAD_PORT_http=8080
NOMAD_JOB_NAME=netshoot-2
NOMAD_ALLOC_PORT_http=8080
DB_HOST=db01.example.com
NOMAD_SHORT_ALLOC_ID=a17c1d0a
NOMAD_ADDR_http=10.0.2.15:24803
NOMAD_DC=dc1
NOMAD_ALLOC_NAME=netshoot-2.netshoot-group[0]
SHLVL=1
NOMAD_GROUP_NAME=netshoot-group
NOMAD_PARENT_CGROUP=/nomad
NOMAD_TASK_DIR=/local
NOMAD_MEMORY_LIMIT=300
LC_COLLATE=C
NOMAD_HOST_IP_http=10.0.2.15
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
NOMAD_ALLOC_ID=a17c1d0a-be3b-0782-b00e-75201680ee86
DB_PASS=loremipsum
HOST_IP=10.0.2.15
_=/usr/bin/env

@dyrnq
Copy link
Owner Author

dyrnq commented Feb 20, 2023

            env {
                DB_HOST = "db01.example.com"
                DB_USER = "web"
                DB_PASS = "loremipsum"
                HOST_IP = "${attr.unique.network.ip-address}"
            }

${attr.unique.network.ip-address} seem can not found the main working iface which enp0s8

ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 02:58:89:fc:8c:39 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic enp0s3
       valid_lft 80970sec preferred_lft 80970sec
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:96:86:62 brd ff:ff:ff:ff:ff:ff
    inet 192.168.33.4/24 brd 192.168.33.255 scope global enp0s8
       valid_lft forever preferred_lft forever
4: flannel.1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue state UNKNOWN group default 
    link/ether f2:31:38:02:2a:57 brd ff:ff:ff:ff:ff:ff
    inet 10.5.27.0/32 scope global flannel.1
       valid_lft forever preferred_lft forever
5: nerdctl0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 82:d7:91:ec:96:67 brd ff:ff:ff:ff:ff:ff
    inet 10.4.0.1/24 brd 10.4.0.255 scope global nerdctl0
       valid_lft forever preferred_lft forever
6: vethb649c486@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master nerdctl0 state UP group default 
    link/ether c2:3e:a0:79:6e:45 brd ff:ff:ff:ff:ff:ff link-netnsid 0
7: veth77292d7f@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master nerdctl0 state UP group default 
    link/ether ba:ef:5a:79:a9:c6 brd ff:ff:ff:ff:ff:ff link-netnsid 1
8: cni0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue state UP group default qlen 1000
    link/ether 0a:ec:e7:db:27:92 brd ff:ff:ff:ff:ff:ff
    inet 10.5.27.1/24 brd 10.5.27.255 scope global cni0
       valid_lft forever preferred_lft forever
25: veth329fc5de@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue master cni0 state UP group default 
    link/ether d2:c2:84:3a:45:e8 brd ff:ff:ff:ff:ff:ff link-netns 7a342afc-3360-e0bf-cf25-e525fdb74a02
26: vethe068f0d9@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue master cni0 state UP group default 
    link/ether aa:4d:91:3f:09:1a brd ff:ff:ff:ff:ff:ff link-netns 75d23223-3f87-5a53-498b-41d53045c480
27: veth8caf3b6d@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue master cni0 state UP group default 
    link/ether 96:35:bf:8a:09:bf brd ff:ff:ff:ff:ff:ff link-netns 0c348ef7-8a6d-3eac-6ed1-fc88324c7cfb
28: veth6c88fa73@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue master cni0 state UP group default 
    link/ether 3a:84:48:74:cd:98 brd ff:ff:ff:ff:ff:ff link-netns 7b02531e-c8af-bf53-cec9-2b802f122523

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant