Adding minikube start command

This commit is contained in:
Zackarias Montell
2026-04-23 10:20:10 +02:00
parent 0856691343
commit 57737dcfb9
3 changed files with 62 additions and 1 deletions

View File

@@ -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

View File

@@ -9,7 +9,7 @@ local default_prog = {
"& { . ~/.profile.ps1; $host.EnterNestedPrompt() }",
}
default_prog = {"ubuntu"}
--default_prog = {"ubuntu"}
return {
default_prog = default_prog,

55
sync-minikube-port.sh Normal file
View 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"