uniquejava / blog

My notes regarding the vibrating frontend :boom and the plain old java :rofl.
Creative Commons Zero v1.0 Universal
11 stars 5 forks source link

vault #244

Open uniquejava opened 6 years ago

uniquejava commented 6 years ago

将vault下载下来然后cp vault /usr/local/bin/

Vault is a tool for securely storing and accessing secrets. You can read more about Vault here. Vault comes as a single binary which you can download here.

Now start Vault in dev mode using the following command:

$ vault server -dev

In the console, you can see the information about how to use Vault and Root token. Open a new terminal window and set the VAULT_ADDR environment variable.

$ export VAULT_ADDR='http://127.0.0.1:8200′

NOTE: The Vault dev mode is only for development purpose and is not meant for production usage.

We can write secrets to Vault using vault write secret/somename key1=value1 key2=value2.

We can also put all our secrets in a JSON file and write from the file as well. Let us create a JSON file with MySQL database credentials and write to Vault.

catalog-service-credentials.json

{ 

    "spring.datasource.username": "root", 
    "spring.datasource.password": "admin"

}

$ vault write secret/catalog-service @catalog-service-credentials.json

You can verify the values by running vault read secret/catalog-service.

We can automate this whole process of setting up Vault and initializing with secrets using Docker.

uniquejava commented 6 years ago

碰到了这个错误: stackoverflow Vault error while writing