feat: add script to convert SA token to kubeconfig for vals
This commit is contained in:
parent
338c0cbb3e
commit
d004dc43e8
@ -35,6 +35,9 @@ RUN curl -fsSL https://github.com/helmfile/vals/releases/download/v${VALS_VERSIO
|
|||||||
|
|
||||||
RUN ln -sf "$(helm env HELM_PLUGINS)/helm-secrets/scripts/wrapper/helm.sh" /usr/local/sbin/helm
|
RUN ln -sf "$(helm env HELM_PLUGINS)/helm-secrets/scripts/wrapper/helm.sh" /usr/local/sbin/helm
|
||||||
|
|
||||||
|
# Add init script to convert SA token into kubeconfig for vals
|
||||||
|
ADD sa2kubeconfig.sh /usr/local/bin/sa2kubeconfig.sh
|
||||||
|
|
||||||
USER ${ARGOCD_USER_ID}
|
USER ${ARGOCD_USER_ID}
|
||||||
|
|
||||||
RUN helm plugin install --version ${HELM_SECRETS_VERSION} https://github.com/jkroepke/helm-secrets
|
RUN helm plugin install --version ${HELM_SECRETS_VERSION} https://github.com/jkroepke/helm-secrets
|
||||||
|
28
sa2kubeconfig.sh
Executable file
28
sa2kubeconfig.sh
Executable file
@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
SA_NAME=argocd-repo-server
|
||||||
|
|
||||||
|
CA64=$(cat /run/secrets/kubernetes.io/serviceaccount/ca.crt | base64 -w0)
|
||||||
|
TOKEN=$(cat /run/secrets/kubernetes.io/serviceaccount/token)
|
||||||
|
|
||||||
|
mkdir -p $HOME/.kube
|
||||||
|
|
||||||
|
cat > $HOME/.kube/config << 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
|
Loading…
Reference in New Issue
Block a user