From 5fc162de97007b5c63e18a03570475fb0a54e7bd Mon Sep 17 00:00:00 2001 From: Stan Drozd Date: Mon, 2 Aug 2021 19:14:55 +0200 Subject: [PATCH] scripts.nix: VM defaults, tilt port script arg, unique cluster name Change-Id: I26d0a362c28a3374007c33a76c16006a98b78cd7 --- nix/scripts.nix | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/nix/scripts.nix b/nix/scripts.nix index ab01cba8..5e3e65de 100644 --- a/nix/scripts.nix +++ b/nix/scripts.nix @@ -1,12 +1,12 @@ # An overlay for custom scripts final: prev: { - # Run a local docker-based minikube cluster. minikube config controlled with $MINIKUBE_ARGS + # Run a local minikube cluster. minikube config controlled with $MINIKUBE_ARGS # Minimum requirements: # * User can use Docker # * Docker supports BuildKit whcluster = final.writeShellScriptBin "whcluster" '' set -e - default_minikube_args="--cpus=10 --memory=10gb --disk-size=200gb --driver=kvm2" + default_minikube_args="--cpus=10 --memory=10gb --disk-size=200gb --driver=kvm2 -p minikube-$USER" export MINIKUBE_ARGS=''${MINIKUBE_ARGS:-$default_minikube_args} ${final.minikube}/bin/minikube start $MINIKUBE_ARGS ${final.whinotify}/bin/whinotify @@ -18,15 +18,16 @@ final: prev: { # Run tilt on the local cluster. Takes guardian count as argument. whtilt = final.writeShellScriptBin "whtilt" '' - n_guardians=''${1:-5} + tilt_port=''${1:-10350} + n_guardians=''${2:-5} echo "Starting Tilt with $n_guardians guardians" ${final.killall}/bin/killall tilt - ${final.tilt}/bin/tilt up --update-mode exec -- --num=$n_guardians + ${final.tilt}/bin/tilt up --update-mode exec --port $tilt_port -- --num=$n_guardians ''; # increase sysctl value for inotify watch count to sufficient level whinotify = final.writeShellScriptBin "whinotify" '' - ${final.minikube}/bin/minikube ssh 'echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p' + ${final.minikube}/bin/minikube ssh -p minikube-$USER 'echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p' ''; # one-stop-shop for setting up a cluster on a remote machine and @@ -46,6 +47,7 @@ final: prev: { set -x set -e remote_machine=$1 + tilt_port=''${2:-10350} # Use Mutagen to watch local repo and sync it with remote_machine's ~/wormhole ${final.mutagen}/bin/mutagen sync terminate whremote-sync || true @@ -53,7 +55,7 @@ final: prev: { ${final.mutagen}/bin/mutagen sync flush whremote-sync # Use larger cpu-count and memory values on the remote - export MINIKUBE_ARGS=''${MINIKUBE_ARGS:='--cpus=30 --memory=110g --disk-size=500gb --driver=kvm2'} + export MINIKUBE_ARGS=''${MINIKUBE_ARGS:='--cpus=15 --memory=55g --disk-size=250gb --driver=kvm2 -p minikube-$USER'} # Set up/update the remote minikube cluster with whcluster ssh $remote_machine \ @@ -62,9 +64,9 @@ final: prev: { nix-shell --option sandbox false --command ' MINIKUBE_ARGS=\"$MINIKUBE_ARGS\" whcluster'" # Run tilt using whtilt on the remote and forward its default port to localhost - ssh -L 10350:127.0.0.1:10350 $remote_machine \ + ssh -L $tilt_port:127.0.0.1:$tilt_port $remote_machine \ ". ~/.bash_profile; . ~/.zprofile; . ~/.profile; \ cd wormhole && \ - nix-shell --option sandbox false --command 'whtilt $WH_GUARDIAN_COUNT'" + nix-shell --option sandbox false --command 'whtilt $tilt_port $n_guardians'" ''; }