File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,6 +25,10 @@ ports:
2525# Dev Theia
2626 - port : 13444
2727tasks :
28+ - name : Add Harvester kubeconfig
29+ command : |
30+ ./dev/preview/download-and-merge-harvester-kubeconfig.sh
31+ exit 0
2832 - name : Java
2933 init : |
3034 leeway exec --package components/supervisor-api/java:lib --package components/gitpod-protocol/java:lib -- ./gradlew build
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ set -euo pipefail
4+
5+ function log {
6+ echo " [$( date) ] $* "
7+ }
8+
9+ function has-dev-access {
10+ kubectl --context=dev auth can-i get secrets > /dev/null 2>&1 || false
11+ }
12+
13+ if ! has-dev-access; then
14+ log " The workspace isn't configured to have core-dev access. Exiting."
15+ exit 0
16+ fi
17+
18+ KUBECONFIG_PATH=" /home/gitpod/.kube/config"
19+ HARVESTER_KUBECONFIG_PATH=" $( mktemp) "
20+ MERGED_KUBECONFIG_PATH=" $( mktemp) "
21+
22+ log " Downloading and preparing Harvester kubeconfig"
23+ kubectl -n werft get secret harvester-kubeconfig -o jsonpath=' {.data}' \
24+ | jq -r ' .["harvester-kubeconfig.yml"]' \
25+ | base64 -d \
26+ | sed ' s/default/harvester/g' \
27+ > " ${HARVESTER_KUBECONFIG_PATH} "
28+
29+ # Order of files is important, we have the original config first so we preserve
30+ # the value of current-context
31+ log " Merging kubeconfig files ${KUBECONFIG_PATH} ${HARVESTER_KUBECONFIG_PATH} into ${MERGED_KUBECONFIG_PATH} "
32+ KUBECONFIG=" ${KUBECONFIG_PATH} :${HARVESTER_KUBECONFIG_PATH} " \
33+ kubectl config view --flatten --merge > " ${MERGED_KUBECONFIG_PATH} "
34+
35+ log " Overwriting ${KUBECONFIG_PATH} "
36+ mv " ${MERGED_KUBECONFIG_PATH} " " ${KUBECONFIG_PATH} "
37+
38+ log " Cleaning up temporay Harveter kubeconfig"
39+ rm " ${HARVESTER_KUBECONFIG_PATH} "
40+
41+ log " Done"
You can’t perform that action at this time.
0 commit comments