feat(auth): add infra-auth-retriever script for retrieving service authentication

Signed-off-by: zhenyus <zhenyus@mathmast.com>
This commit is contained in:
zhenyus 2025-03-04 00:31:44 +08:00
parent 1727906647
commit 8d149418fc

47
cluster/bin/infra-auth-retriver Executable file
View File

@ -0,0 +1,47 @@
#!/bin/sh
set -eu
VERSION="0.0.1-20250115"
help() {
echo "Freeleaps Cluster Auth Retriever (Version: ${VERSION})"
echo ""
echo "FYI: This script is used to retrieve the auth of the infra services, just for internal and temporary use."
echo ""
echo "Usage: infra-auth-retriver <sub-commands>"
echo ""
echo "Sub Commands:"
echo " help,-h,--help Show help"
echo " grafana Retrieve Grafana Auth"
echo " argocd Retrieve ArgoCD Auth"
}
main() {
if [ "$#" -ne 1 ]; then
echo "[ERROR] No sub-commands provided."
echo "[TIP] Use 'infra-auth-retriver help' to get more information."
exit 1
fi
sub_command="$1"
case "${sub_command}" in
help|-h|--help)
help
;;
grafana)
echo "Grafana User: $(kubectl get secret kube-prometheus-stack-grafana -n freeleaps-monitoring-system -o jsonpath='{.data.admin-user}' | base64 -d)"
echo "Grafana Password: $(kubectl get secret kube-prometheus-stack-grafana -n freeleaps-monitoring-system -o jsonpath='{.data.admin-password}' | base64 -d)"
;;
argocd)
echo "ArgoCD User: admin"
echo "ArgoCD Auth: $(kubectl get secret argocd-initial-admin-secret -n freeleaps-devops-system -o jsonpath='{.data.password}' | base64 -d)"
;;
*)
help
;;
esac
}
main "$@"