-
Notifications
You must be signed in to change notification settings - Fork 54
warcli cluster refactors
#419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8ee9ab1
refactor cluster commands and justfile
willcl-ark af20ca0
update api docs
willcl-ark cf6e039
update docs using new commands
willcl-ark e57519b
fix rootless docker using qemu
willcl-ark 1343069
avoid verbosity and debugging clutter
mplsgrant 8f49bd0
remove unused rpc checks
mplsgrant 3318334
add color
mplsgrant 6423c2f
add ERROR_CODE
mplsgrant 0435d57
add docker checks
mplsgrant 58195b8
add minikube check
mplsgrant b0e5023
on docker desktop build docker image
m3dwards File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,44 +1,66 @@ | ||
| # Quick run | ||
|
|
||
| Warnet runs a server which can be used to manage multiple networks. On docker | ||
| this runs locally, but on Kubernetes this runs as a `statefulSet` in the | ||
| cluster. | ||
| ## Installation | ||
|
|
||
| If the `$XDG_STATE_HOME` environment variable is set, the server will log to | ||
| a file `$XDG_STATE_HOME/warnet/warnet.log`, otherwise it will use `$HOME/.warnet/warnet.log`. | ||
| Either install warnet via pip, or clone the source and install: | ||
|
|
||
| ## Quick start via pip | ||
| ### via pip | ||
|
|
||
| You can install warnet via `pip` into your virtual environment with | ||
| You can install warnet via `pip` into a virtual environment with | ||
|
|
||
| ```bash | ||
| python3 -m venv .venv | ||
| source .venv/bin/activate | ||
| pip install warnet | ||
| ``` | ||
|
|
||
| Following installation `warcli` commands will operate natively on the Kubernetes cluster currently configured with `kubectl`. | ||
| ### via cloned source | ||
|
|
||
| Starting the Warnet server is as easy as: | ||
| You can install warnet from source into a virtual environment with | ||
|
|
||
| ```bash | ||
| # (optional) if using a local minikube cluster check that we have all required programs installed | ||
| warcli setup | ||
| git clone https://github.com/bitcoin-dev-project/warnet.git | ||
| cd warnet | ||
| python3 -m venv .venv | ||
| source .venv/bin/activate | ||
| pip install -e . | ||
| ``` | ||
|
|
||
| ## Running | ||
|
|
||
| > [!TIP] | ||
| > When developing locally add the `--dev` flag to `warcli cluster deploy` to enable dev mode with hot-reloading server. | ||
|
|
||
| ### Using minikube | ||
|
|
||
| To run a local cluster using minikube: | ||
|
|
||
| ```bash | ||
| warcli cluster setup-minikube | ||
|
|
||
| # (optional) if using a local minikube cluster, set it up | ||
| warcli cluster minikube-setup | ||
| warcli cluster deploy | ||
| ``` | ||
|
|
||
| ### Other cluster types | ||
|
|
||
| If not using minikube (e.g. using Docker Desktop or a managed cluster), `warcli` commands will operate natively on the current Kubernetes context, so you can simply run: | ||
|
|
||
| ```bash | ||
| warcli cluster deploy | ||
| ``` | ||
|
|
||
| This also automatically configures port forwarding to the Server in the cluster. | ||
| ...to deploy warnet to your cluster. | ||
|
|
||
| `warcli deploy` also automatically configures port forwarding to the Server in the cluster. | ||
|
|
||
| ## Stopping | ||
|
|
||
| To tear down the cluster: | ||
|
|
||
| ```bash | ||
| warcli cluster teardown | ||
| ``` | ||
|
|
||
| # (optional) if using a local minikube cluster, remove the image | ||
| warcli cluster minikube-clean | ||
|
|
||
| ## Log location | ||
|
|
||
| If the `$XDG_STATE_HOME` environment variable is set, the server will log to a file `$XDG_STATE_HOME/warnet/warnet.log`, otherwise it will use `$HOME/.warnet/warnet.log`. |
This file contains hidden or 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 hidden or 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 hidden or 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,50 @@ | ||
| #!/usr/bin/env bash | ||
| set -euxo pipefail | ||
|
|
||
|
|
||
| if [ -z "${WAR_MANIFESTS+x}" ]; then | ||
| echo "WAR_MANIFESTS is unset. Please provide a path to warnet manifests." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Function to check if warnet-rpc container is already running | ||
| check_warnet_rpc() { | ||
| if kubectl get pods --all-namespaces | grep -q "bitcoindevproject/warnet-rpc"; then | ||
| echo "warnet-rpc pod found" | ||
| exit 1 | ||
| fi | ||
| } | ||
|
|
||
| # Deploy base configurations | ||
| kubectl apply -f "$WAR_MANIFESTS/namespace.yaml" | ||
| kubectl apply -f "$WAR_MANIFESTS/rbac-config.yaml" | ||
| kubectl apply -f "$WAR_MANIFESTS/warnet-rpc-service.yaml" | ||
|
|
||
| # Deploy rpc server | ||
| if [ -n "${WAR_DEV+x}" ]; then # Dev mode selector | ||
| # Build image in local registry | ||
| docker build -t warnet/dev -f "$WAR_RPC/Dockerfile_dev" "$WAR_RPC" --load | ||
| if [ "$(kubectl config current-context)" = "docker-desktop" ]; then | ||
| sed "s?/mnt/src?$(pwd)?g" "$WAR_MANIFESTS/warnet-rpc-statefulset-dev.yaml" | kubectl apply -f - | ||
| else # assuming minikube | ||
| minikube image load warnet/dev | ||
| kubectl apply -f "$WAR_MANIFESTS/warnet-rpc-statefulset-dev.yaml" | ||
| fi | ||
| else | ||
| kubectl apply -f "$WAR_MANIFESTS/warnet-rpc-statefulset.yaml" | ||
| fi | ||
|
|
||
| kubectl config set-context --current --namespace=warnet | ||
|
|
||
| # Check for warnet-rpc container | ||
| check_warnet_rpc | ||
|
|
||
| until kubectl get pod rpc-0 --namespace=warnet; do | ||
| echo "Waiting for server to find pod rpc-0..." | ||
| sleep 4 | ||
| done | ||
|
|
||
| echo "⏲️ This could take a minute or so." | ||
| kubectl wait --for=condition=Ready --timeout=2m pod rpc-0 | ||
|
|
||
| echo Done... | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we build the dev container on this line?