-
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.
feat: seamless configuration for pulling kubeconfig
- Loading branch information
Showing
3 changed files
with
50 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
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,32 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eou pipefail | ||
|
||
L=$(echo "$LANDSCAPE" | tr '[:upper:]' '[:lower:]') | ||
C=$(echo "$CLUSTER" | tr '[:upper:]' '[:lower:]') | ||
|
||
name="${L}-${C}" | ||
|
||
# wait for virtual cluster to be ready | ||
echo "⌛️ Waiting for cluster '$name' to be ready..." | ||
kubectl --context "${name}" -n pichu wait --for=jsonpath=.status.readyReplicas=1 --timeout=300s deployment "${L}-pichu-iodine" | ||
kubectl --context "${name}" -n pikachu wait --for=jsonpath=.status.readyReplicas=1 --timeout=300s deployment "${L}-pikachu-iodine" | ||
kubectl --context "${name}" -n raichu wait --for=jsonpath=.status.readyReplicas=1 --timeout=300s deployment "${L}-raichu-iodine" | ||
|
||
echo "✅ Virtual clusters are ready!" | ||
|
||
pichu_kube=$(kubectl get secrets --context "${name}" -n pichu "vc-${L}-pichu-iodine" -o jsonpath='{.data.config}' | base64 -d) | ||
pikachu_kube=$(kubectl get secrets --context "${name}" -n pikachu "vc-${L}-pikachu-iodine" -o jsonpath='{.data.config}' | base64 -d) | ||
raichu_kube=$(kubectl get secrets --context "${name}" -n raichu "vc-${L}-raichu-iodine" -o jsonpath='{.data.config}' | base64 -d) | ||
|
||
echo "📝 Writing to '$HOME/.kube/k3dconfigs/pichu-${C}'" | ||
echo "${pichu_kube}" >"$HOME/.kube/k3dconfigs/pichu-${C}" | ||
echo "📝 Writing to '$HOME/.kube/k3dconfigs/pikachu-${C}'" | ||
echo "${pikachu_kube}" >"$HOME/.kube/k3dconfigs/pikachu-${C}" | ||
echo "📝 Writing to '$HOME/.kube/k3dconfigs/raichu-${C}'" | ||
echo "${raichu_kube}" >"$HOME/.kube/k3dconfigs/raichu-${C}" | ||
|
||
echo "🛠️ Attempting to merge kubeconfig cluster '$name'..." | ||
KUBECONFIG=$(cd ~/.kube/configs && find "$(pwd)"/* | awk 'ORS=":"')$(cd ~/.kube/k3dconfigs && find "$(pwd)"/* | awk 'ORS=":"') kubectl config view --flatten >~/.kube/config | ||
chmod 600 ~/.kube/config | ||
echo "✅ Config is merged!" |
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,17 @@ | ||
version: "3" | ||
|
||
tasks: | ||
entei:opal: | ||
desc: Obtain Entei Opal Virtual Cluster KubeConfigs | ||
env: | ||
CLUSTER: opal | ||
LANDSCAPE: entei | ||
cmds: | ||
- ./scripts/local/update-kubectl.sh | ||
entei:ruby: | ||
desc: Obtain Entei Ruby Virtual Cluster KubeConfigs | ||
env: | ||
CLUSTER: ruby | ||
LANDSCAPE: entei | ||
cmds: | ||
- ./scripts/local/update-kubectl.sh |