30 lines
600 B
Bash
Executable File
30 lines
600 B
Bash
Executable File
#!/bin/sh -e
|
|
|
|
KUBECONFIG=$1
|
|
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
|