scripts.nix: VM defaults, tilt port script arg, unique cluster name
Change-Id: I26d0a362c28a3374007c33a76c16006a98b78cd7
This commit is contained in:
parent
1da08b5bee
commit
5fc162de97
|
@ -1,12 +1,12 @@
|
||||||
# An overlay for custom scripts
|
# An overlay for custom scripts
|
||||||
final: prev: {
|
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:
|
# Minimum requirements:
|
||||||
# * User can use Docker
|
# * User can use Docker
|
||||||
# * Docker supports BuildKit
|
# * Docker supports BuildKit
|
||||||
whcluster = final.writeShellScriptBin "whcluster" ''
|
whcluster = final.writeShellScriptBin "whcluster" ''
|
||||||
set -e
|
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}
|
export MINIKUBE_ARGS=''${MINIKUBE_ARGS:-$default_minikube_args}
|
||||||
${final.minikube}/bin/minikube start $MINIKUBE_ARGS
|
${final.minikube}/bin/minikube start $MINIKUBE_ARGS
|
||||||
${final.whinotify}/bin/whinotify
|
${final.whinotify}/bin/whinotify
|
||||||
|
@ -18,15 +18,16 @@ final: prev: {
|
||||||
|
|
||||||
# Run tilt on the local cluster. Takes guardian count as argument.
|
# Run tilt on the local cluster. Takes guardian count as argument.
|
||||||
whtilt = final.writeShellScriptBin "whtilt" ''
|
whtilt = final.writeShellScriptBin "whtilt" ''
|
||||||
n_guardians=''${1:-5}
|
tilt_port=''${1:-10350}
|
||||||
|
n_guardians=''${2:-5}
|
||||||
echo "Starting Tilt with $n_guardians guardians"
|
echo "Starting Tilt with $n_guardians guardians"
|
||||||
${final.killall}/bin/killall tilt
|
${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
|
# increase sysctl value for inotify watch count to sufficient level
|
||||||
whinotify = final.writeShellScriptBin "whinotify" ''
|
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
|
# one-stop-shop for setting up a cluster on a remote machine and
|
||||||
|
@ -46,6 +47,7 @@ final: prev: {
|
||||||
set -x
|
set -x
|
||||||
set -e
|
set -e
|
||||||
remote_machine=$1
|
remote_machine=$1
|
||||||
|
tilt_port=''${2:-10350}
|
||||||
|
|
||||||
# Use Mutagen to watch local repo and sync it with remote_machine's ~/wormhole
|
# Use Mutagen to watch local repo and sync it with remote_machine's ~/wormhole
|
||||||
${final.mutagen}/bin/mutagen sync terminate whremote-sync || true
|
${final.mutagen}/bin/mutagen sync terminate whremote-sync || true
|
||||||
|
@ -53,7 +55,7 @@ final: prev: {
|
||||||
${final.mutagen}/bin/mutagen sync flush whremote-sync
|
${final.mutagen}/bin/mutagen sync flush whremote-sync
|
||||||
|
|
||||||
# Use larger cpu-count and memory values on the remote
|
# 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
|
# Set up/update the remote minikube cluster with whcluster
|
||||||
ssh $remote_machine \
|
ssh $remote_machine \
|
||||||
|
@ -62,9 +64,9 @@ final: prev: {
|
||||||
nix-shell --option sandbox false --command ' MINIKUBE_ARGS=\"$MINIKUBE_ARGS\" whcluster'"
|
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
|
# 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; \
|
". ~/.bash_profile; . ~/.zprofile; . ~/.profile; \
|
||||||
cd wormhole && \
|
cd wormhole && \
|
||||||
nix-shell --option sandbox false --command 'whtilt $WH_GUARDIAN_COUNT'"
|
nix-shell --option sandbox false --command 'whtilt $tilt_port $n_guardians'"
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue