-
-
Save zmingxie/2930a212d4aa9a71d232a176c7d1e5e1 to your computer and use it in GitHub Desktop.
Nomad + Vault agent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
if [ -f /mnt/ramdisk/token ]; then | |
exec env VAULT_TOKEN=$(vault unwrap -field=token $(jq -r '.token' /mnt/ramdisk/token)) \ | |
/usr/local/bin/nomad agent \ | |
-config=/etc/nomad.d \ | |
-vault-tls-skip-verify=true | |
else | |
echo "Nomad service failed due to missing Vault token" | |
exit 1 | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Nomad Agent | |
Requires=consul-online.target | |
After=consul-online.target | |
[Service] | |
KillMode=process | |
KillSignal=SIGINT | |
Environment=VAULT_ADDR=http://active.vault.service.consul:8200 | |
Environment=VAULT_SKIP_VERIFY=true | |
ExecStartPre=/usr/local/bin/vault agent -config /etc/vault-agent.d/vault-agent.hcl | |
ExecStart=/usr/bin/nomad-vault.sh | |
ExecReload=/bin/kill -HUP $MAINPID | |
Restart=on-failure | |
RestartSec=2 | |
StartLimitBurst=3 | |
StartLimitIntervalSec=10 | |
LimitNOFILE=65536 | |
[Install] | |
WantedBy=multi-user.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exit_after_auth = true | |
auto_auth { | |
method "aws" { | |
mount_path = "auth/aws" | |
config = { | |
type = "iam" | |
role = "nomad" | |
} | |
} | |
sink "file" { | |
wrap_ttl = "5m" | |
config = { | |
path = "/mnt/ramdisk/token" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment