zdt-argocd/create-kubectl-config.sh
Stefan Reimer 4b45b05e8e
All checks were successful
ZeroDownTime/zdt-argocd/pipeline/head This commit looks good
ZeroDownTime/zdt-argocd/pipeline/tag This commit looks good
feat: move kubectl config setup to init-container
2025-06-23 11:16:41 +00:00

32 lines
706 B
Bash
Executable File

#!/bin/sh
KUBECONFIG=/home/argocd/cmp-server/plugins/kubectl.config
SA_NAME=argo-argocd-repo-server
CA64=$(cat /run/secrets/kubernetes.io/serviceaccount/ca.crt | base64 -w0)
TOKEN=$(cat /run/secrets/kubernetes.io/serviceaccount/token)
cat > $KUBECONFIG << 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
chmod 600 $KUBECONFIG
# ARGOCD_BINARY_NAME=argocd-cmp-server /usr/local/bin/argocd $@