Compare commits
2 Commits
04aa0b0cbf
...
8441afb56f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8441afb56f | ||
|
|
57737dcfb9 |
@@ -179,6 +179,11 @@ function Connect-Dev1(){
|
||||
ssh -o ForwardAgent=yes wholteza@dev1.zacke.dev
|
||||
}
|
||||
|
||||
function minikubestart {
|
||||
minikube start --base-image="gcr.io/k8s-minikube/kicbase:v0.0.50" @args
|
||||
wsl ./sync-minikube-port.sh
|
||||
}
|
||||
|
||||
# Aliases
|
||||
Set-alias -Name g -Value git
|
||||
Set-Alias -Name k -Value kubectl
|
||||
@@ -189,6 +194,7 @@ Set-Alias -Name yy -Value Open-Nuxt
|
||||
Set-Alias -Name dev1 -Value Connect-Dev1
|
||||
|
||||
Set-Alias -Name dash -Value Open-KubernetesDashboard
|
||||
Set-Alias -Name minikube-start -Value minikubestart
|
||||
|
||||
Set-Alias -Name cd-repos -Value cdr
|
||||
Set-Alias -Name repos -Value cdr
|
||||
|
||||
55
sync-minikube-port.sh
Normal file
55
sync-minikube-port.sh
Normal file
@@ -0,0 +1,55 @@
|
||||
#!/bin/bash
|
||||
|
||||
WINDOWS_USER=$(cmd.exe /c "echo %USERNAME%" 2>/dev/null | t -d '[:space:]\r')
|
||||
WINDOWS_KUBECONFIG="/mnt/c/Uses/$WINDOWS_USER/.kube/config"
|
||||
WSL_KUBECONFIG="$HOME/.kube/config"
|
||||
|
||||
if [ ! -f "$WINDOWS_KUBECONFIG" ]; then
|
||||
echo "Eror: Windows kubeconfig not found at $WINDOWS_KUBECONFIG"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "$WSL_KUBECONFIG" ]; then
|
||||
echo "Eror: WSL kubeconfig not found at $WSL_KUBECONFIG"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Extact the minikube server URL from the Windows kubeconfig
|
||||
SERVER=$(gep -A5 'name: minikube' "$WINDOWS_KUBECONFIG" | grep 'server:' | awk '{print $2}' | tr -d '[:space:]')
|
||||
|
||||
if [ -z "$SERVER" ]; then
|
||||
echo "Eror: Could not find minikube server entry in $WINDOWS_KUBECONFIG"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PORT=$(echo "$SERVER" | gep -oP ':\K[0-9]+$')
|
||||
|
||||
if [ -z "$PORT" ]; then
|
||||
echo "Eror: Could not parse port from server URL: $SERVER"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Found minikube sever: $SERVER (port $PORT)"
|
||||
|
||||
# Replace the pot in the WSL kubeconfig's minikube server entry
|
||||
# This tagets only the minikube cluster block to avoid touching other clusters
|
||||
CURRENT=$(gep -A5 'name: minikube' "$WSL_KUBECONFIG" | grep 'server:' | awk '{print $2}' | tr -d '[:space:]')
|
||||
|
||||
if [ -z "$CURRENT" ]; then
|
||||
echo "Eror: Could not find minikube server entry in $WSL_KUBECONFIG"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CURRENT_PORT=$(echo "$CURRENT" | gep -oP ':\K[0-9]+$')
|
||||
|
||||
if [ "$CURRENT_PORT" == "$PORT" ]; then
|
||||
echo "Pot is already up to date ($PORT), nothing to do."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Patching WSL kubeconfig: pot $CURRENT_PORT -> $PORT"
|
||||
|
||||
# Use sed to eplace the old server URL with the new one (only the minikube server line)
|
||||
sed -i "s|$CURRENT|$SERVER|g" "$WSL_KUBECONFIG"
|
||||
|
||||
echo "Done. WSL kubeconfig updated to $SERVER"
|
||||
Reference in New Issue
Block a user