This commit is contained in:
ducoterra
2021-05-20 12:58:44 -04:00
commit e67d6804b3
8 changed files with 330 additions and 0 deletions

29
scripts/vault_unseal.py Executable file
View File

@@ -0,0 +1,29 @@
#!/usr/bin/python3
import json
import os
import subprocess
import threading
vaults = ["vault-0"]
home = os.getenv("HOME")
with open(os.path.join(home, ".vault-keys/cluster-keys.json")) as f:
vault_secrets = json.load(f)
procs = []
for vault in vaults:
procs += [
threading.Thread(
target = subprocess.run,
args = (
["kubectl", "exec", "-ti", vault, "--", "vault", "operator", "unseal", vault_secrets.get("unseal_keys_b64")[key]],))
for key in range(int(vault_secrets.get("unseal_threshold")))
]
for thread in procs:
thread.start()
for thread in procs:
thread.join()