Skip to content

Instantly share code, notes, and snippets.

@fragaLY
Last active February 3, 2023 12:55
Show Gist options
  • Save fragaLY/d28385538c22c01e7256061d54361e82 to your computer and use it in GitHub Desktop.
Save fragaLY/d28385538c22c01e7256061d54361e82 to your computer and use it in GitHub Desktop.
Vault Setup
1. Pull vault docker image: docker pull vault
2. Running vault docker container:
docker run --cap-add=IPC_LOCK \
-e 'VAULT_DEV_ROOT_TOKEN_ID=00000000-0000-0000-0000-000000000000' \
-p 8200:8200 \
-v tmp/vault \
--name my-vault vault
The IPC_LOCK capability is required for Vault to be able to lock memory and not be swapped to disk, as this behavior is enabled by default. As the instance is run for development, the ID of the initially generated root token is set to the given value.
3. Note the output of vault:
Unseal Key: $KEY
Root Token: $VAULT_DEV_ROOT_TOKEN_ID
4. Attaching to container and exporting token and address as environment variables:
docker exec -it my-vault /bin/sh
/ # export VAULT_TOKEN="00000000-0000-0000-0000-000000000000"
/ # export VAULT_ADDR="http://127.0.0.1:8200"
/ # vault status
Key Value
--- -----
Seal Type shamir
Initialized true
Sealed false
Total Shares 1
Threshold 1
Version 1.12.2
Build Date 2022-11-23T12:53:46Z
Storage Type inmem
Cluster Name vault-cluster-21284a77
Cluster ID 01d4cb34-d380-946d-c249-3031992c5579
HA Enabled false
5. Put the values in storage:
vault kv put secret/{spring.application.name}, {profile} \
spring.r2dbc.url="{url}" \
spring.r2dbc.username="{username}" \
spring.r2dbc.password="{password}"
6. Check that everything stored:
vault kv get secret/{application-name}/{profile}
7. Open the localhost:8200 in browser and use a token authentication with root token '00000000-0000-0000-0000-000000000000'
8. Create
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment