zdt-argocd/sa2kubeconfig.sh
Stefan Reimer 0fd61d86b8
All checks were successful
ZeroDownTime/zdt-argocd/pipeline/head This commit looks good
fix: write to file
2024-05-20 10:59:11 +00:00

27 lines
555 B
Bash
Executable File

#!/bin/sh -e
SA_NAME=$ARGOCD_REPO_SERVER_NAME
CA64=$(cat /run/secrets/kubernetes.io/serviceaccount/ca.crt | base64 -w0)
TOKEN=$(cat /run/secrets/kubernetes.io/serviceaccount/token)
cat > $1 << EOF
apiVersion: v1
kind: Config
clusters:
- name: local
cluster:
server: https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_SERVICE_PORT_HTTPS
certificate-authority-data: $CA64
users:
- name: $SA_NAME
user:
token: "$TOKEN"
contexts:
- name: ${SA_NAME}_context
context:
cluster: local
user: $SA_NAME
current-context: ${SA_NAME}_context
EOF