Use Vault API to create a user and allow that user to write/read kv pairs from a give path.
This file contains 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
import argparse | |
import simplecrypt | |
import nacl.secret | |
import nacl.utils | |
import nacl.pwhash | |
import base64 | |
import random | |
import uuid | |
import sys |
Create a random base64 hash
$ curl -s -H "X-Vault-Token: ${VAULT_TOKEN}" -XPOST --data '{"format": "base64", "bytes": 32}' http://127.0.0.1:8200/v1/sys/tools/random/64 | jq
{
"request_id": "d32a5281-35ec-1e8d-1d24-373daaaa6718",
"lease_id": "",
"renewable": false,
"lease_duration": 0,
"data": {
Create the directory structure:
touch docker-compose.yml
mkdir -p volumes/{config,file,logs}
Populate the vault config vault.json
:
This file contains 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
import ( | |
"encoding/json" | |
"fmt" | |
"log" | |
"net/http" | |
"github.com/gorilla/mux" | |
"github.com/rs/xid" | |
) |
This file contains 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
package main | |
import ( | |
"fmt" | |
"os" | |
"strings" | |
) | |
func main() { | |
for _, envs := range os.Environ() { |
Runtime environment on alpine:
$ docker run -it alpine sh
apk add --no-cache bash
bash
Build environment:
docker run -it golang:alpine sh
mkdir src/github.com/ruanbekker/myfirstexporter -p
cd src/github.com/ruanbekker/myfirstexporter/
vi main.go
vi collector.go
<source>
@type forward
</source>
<match app.**>
type stdout
</match>
<filter app2.**>