k8s/scripts/vault-setup.sh
2023-04-03 23:05:14 +00:00

14 lines
400 B
Bash
Executable file

#!/bin/bash
# vault login path
VAULT_LOGIN_NS=k8s-teapot
# local ip
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
vault write auth/${VAULT_LOGIN_NS}/config \
kubernetes_host=https://${HOST_IP}:6443 \
kubernetes_ca_cert=@ca.crt
rm ca.crt