k8s/vault-setup.sh

15 lines
400 B
Bash
Raw Normal View History

2022-07-02 18:37:33 +00:00
#!/bin/bash
2022-12-28 23:06:22 +00:00
# vault login path
VAULT_LOGIN_NS=k8s-teapot
2022-07-02 18:37:33 +00:00
2022-12-28 23:06:22 +00:00
# local ip
2022-07-02 18:37:33 +00:00
HOST_IP=$(ip addr show eth0 | grep -Po 'inet \K[\d.]+')
kubectl config view --raw --minify --flatten --output='jsonpath={.clusters[].cluster.certificate-authority-data}' | base64 --decode > ca.crt
2022-12-28 23:06:22 +00:00
vault write auth/${VAULT_LOGIN_NS}/config \
2022-07-02 18:37:33 +00:00
kubernetes_host=https://${HOST_IP}:6443 \
kubernetes_ca_cert=@ca.crt
2022-07-02 18:41:57 +00:00
2022-07-02 18:37:33 +00:00
rm ca.crt