generated from kyma-project/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from kyma-project/add/genkubeconfig-script
add scripts to generate serviceaccount based kubeconfig
- Loading branch information
Showing
2 changed files
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
$PWD = (Get-Item .).FullName | ||
$SCRIPTDIR = $PSScriptRoot | ||
|
||
kubectl apply -f $SCRIPTDIR/serviceaccount.yaml | ||
kubectl wait --for=jsonpath='{.data.token}' secret/admin-serviceaccount | ||
$SA_TOKEN=$(kubectl get secret admin-serviceaccount -o=go-template='{{.data.token | base64decode}}') | ||
cp ~/.kube/config kubeconfig-sa.yaml | ||
docker run -v ${PWD}:/workdir -ti mikefarah/yq -i ".users |= [{\`"name\`":\`"admin-serviceaccount\`", \`"user\`": {\`"token\`":\`"${SA_TOKEN}\`"}}]" kubeconfig-sa.yaml | ||
docker run -v ${PWD}:/workdir -ti mikefarah/yq -i ".contexts[0].context.user |= \`"admin-serviceaccount\`"" kubeconfig-sa.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
set -eo pipefail | ||
set -o xtrace | ||
|
||
SCRIPTDIR=$(dirname "$0") | ||
|
||
kubectl apply -f $SCRIPTDIR/serviceaccount.yaml | ||
kubectl wait --for=jsonpath='{.data.token}' secret/admin-serviceaccount | ||
$SA_TOKEN=$(kubectl get secret admin-serviceaccount -o=go-template='{{.data.token | base64decode}}') | ||
cp ~/.kube/config kubeconfig-sa.yaml | ||
docker run -v ${PWD}:/workdir -ti mikefarah/yq -i ".users |= [{\"name\":\"admin-serviceaccount\", \"user\": {\"token\":\"${SA_TOKEN}\"}}]" kubeconfig-sa.yaml | ||
docker run -v ${PWD}:/workdir -ti mikefarah/yq -i ".contexts[0].context.user |= \"admin-serviceaccount\"" kubeconfig-sa.yaml |