Skip to content
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

chore(kurtosis): Clean up Kurtosis and Support for Cloud Deployments #2401

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 10 additions & 18 deletions kurtosis/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,17 @@ start-devnet: install-kurtosis

# Starts a Kurtosis enclave containing a local devnet without building the image
start-devnet-no-build:
kurtosis run ./kurtosis --args-file ./kurtosis/beaconkit-all.yaml \
kurtosis run ./kurtosis --args-file ./kurtosis/beaconkit-local.yaml \
--enclave my-local-devnet --parallelism 200

# Starts a Kurtosis enclave containing a local devnet on GCP.
# --production flag is used to indicate that the enclave is
# running in production mode to allow pod restarts when doing chaos testing.
start-gcp-devnet-no-build:
kurtosis run ./kurtosis --args-file ./kurtosis/beaconkit-base-gcp.yaml \
--enclave my-gcp-devnet2 --parallelism 200 --production --image-download always
# Starts a Kurtosis enclave in the cloud using the latest image tag
start-devnet-cloud: install-kurtosis
kurtosis run ./kurtosis --args-file ./kurtosis/beaconkit-cloud.yaml \
--enclave my-cloud-devnet-$(shell whoami) --parallelism 200 --production

# Stops the running Kurtosis enclave on GCP
stop-gcp-devnet:
kurtosis enclave stop my-gcp-devnet2

# Stops and removes the specified Kurtosis enclave
reset-gcp-devnet:
$(MAKE) stop-gcp-devnet
kurtosis enclave rm my-gcp-devnet2
Comment on lines -50 to -56
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add more commands if they are useful but lets reduce bloat

# Remove the running Kurtosis enclave on GCP
rm-devnet-cloud:
kurtosis enclave rm my-cloud-devnet-$(shell whoami) --force

# Removes the specified Kurtosis enclave
rm-gcp-devnet:
Expand Down Expand Up @@ -88,6 +81,5 @@ star-fix: buildifier-install
find ./kurtosis -name "*.star" -exec buildifier --mode=fix {} +

# Marks targets as not being associated with files
.PHONY: start-devnet stop-devnet reset-devnet rm-devnet buildifier-install \
star-lint star-fix start-gcp-devnet-no-build stop-gcp-devnet \
reset-gcp-devnet rm-gcp-devnet install-kurtosis
.PHONY: start-devnet stop-devnet start-devnet-cloud rm-devnet-cloud reset-devnet rm-devnet buildifier-install \
star-lint star-fix install-kurtosis
93 changes: 60 additions & 33 deletions kurtosis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,56 +39,83 @@ make rm-devnet

And that's it!

### GCP/remote environment
### Deploy Devnet to Kubernetes Networks

#### Requirements: GCP access
## Deploy to a Google Cloud Network

Ask for GCP access in #devops if you need it.
This will allow you to deploy the a network orchestrated in the same was as `make start-devnet` but on a cloud environment. A similar approach can be taken for a local kubernetes environment (alternative commands will be commented with [Docker Desktop K8s].

Set Kurtosis to run with cloud(GCP)/remote:
1. First we must ensure open our Kurtosis config
```sh
kurtosis config path

```bash
kurtosis cluster set minikube
# The command will output a path which you need to open in an editor
/Users/.../kurtosis-config.yml
```

Run the Kurtosis port forward to be able to start your devnet:

```bash
kurtosis gateway
2. Update the Kurtosis config with the following, copy pasting into the whole file
```yaml
config-version: 2
should-send-metrics: true
kurtosis-clusters:
docker:
type: "docker"
docker-desktop:
type: "kubernetes"
config:
kubernetes-cluster-name: "docker-desktop"
storage-class: "hostpath"
cloud:
type: "kubernetes"
config:
kubernetes-cluster-name: "cloud"
storage-class: "premium-rwo"
```

Once you've installed the Kurtosis CLI, you can use it to spin up a Beacon
network with the following command from within the root directory of the
beacon-kit repo:
3. Next we must ensure kurtosis is using the correct config so it deploys to the cloud instead of local Docker Desktop
```sh
kurtosis cluster set cloud

```bash
make start-gcp-devnet-no-build
# [Docker Desktop K8s]: kurtosis config use-context docker-desktop
```

When you want to tear down your network, you can do so
with the following commands:

```bash
make stop-gcp-devnet
4. Now must ensure our Kubernetes config is using the correct context, i.e. the one context we wish to deploy to, e.g.
```sh
kubectl config use-context gke_prj-.....
# [Docker Desktop K8s]: kubectl config use-context docker-desktop
```

## Cheat sheet

When you have killed a pod/component (in that example:
cl-validator-beaconkit-0), restart it with that command:

```bash
kurtosis service start my-local-devnet cl-validator-beaconkit-0
5. Now we run Kurtosis Gateway. This command will start a local "gateway" to connect your local machine to your remote Kubernetes cluster. Run this in a separate shell
```sh
kurtosis gateway
```

Set kurtosis to run with local docker:
6. Cloud based deployments require a docker image as local docker images cannot be pulled from the remote instance. If you want to update the image, edit
```yaml
# Found in beacon-kit/kurtosis/beaconkit-cloud.yaml
images:
beaconkit: ghcr.io/berachain/beacon-kit:main
```

```bash
kurtosis cluster set docker
7. Deploy. Note that re-executing the same command twice will start the network from zero again unless you change the enclave name in the Makefile .
```sh
make start-devnet-cloud
```

Set Kurtosis to run with cloud(GCP)/remote:
8. View your deployment in K9s, navigating to the relevant namespace. It should be named kt-my-cloud-devnet-${whoami}

```bash
kurtosis cluster set minikube
## Helper Commands

If you want to start from a clean state and remove all existing pods
```sh
# Everything is wrecked
kurtosis clean -a
kurtosis engine restart
```

If you manually kill a pod and want to restart it
```sh
# node that for namespace, you should remove the "kt-" prefix
kurtosis service start {namespace} {podname}
```
Original file line number Diff line number Diff line change
Expand Up @@ -23,93 +23,104 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

# This is the base configuration for the BeaconKit service on GCP. It includes the configuration for the BeaconKit service itself, as well as the configuration for the full nodes and validators that the BeaconKit service will interact with.
# Monitoring and alerting are not included in this configuration, as they are handled by the GCP infrastructure.

# This is the configuration is identical to beaconkit-local.yaml with the exception that the image is pulled from a public registry
# As remote environments cannot access the image created locally
network_configuration:
chain_id: 80087
chain_spec: "devnet"
validators:
type: "validator"
nodes:
- el_type: besu
kzg_impl: crate-crypto/go-kzg-4844
replicas: 0
- el_type: nethermind
kzg_impl: crate-crypto/go-kzg-4844
replicas: 0
- el_type: reth
replicas: 32
kzg_impl: crate-crypto/go-kzg-4844
replicas: 2
- el_type: geth
replicas: 32
kzg_impl: crate-crypto/go-kzg-4844
replicas: 2
- el_type: erigon
replicas: 32
- el_type: besu
replicas: 32
- el_type: nethermind
replicas: 32
kzg_impl: crate-crypto/go-kzg-4844
replicas: 1
- el_type: ethereumjs
replicas: 0
full_nodes:
type: "full"
nodes:
- el_type: reth
replicas: 0
kzg_impl: crate-crypto/go-kzg-4844
replicas: 2
- el_type: geth
replicas: 10
- el_type: erigon
kzg_impl: crate-crypto/go-kzg-4844
replicas: 1
- el_type: nethermind
replicas: 0
- el_type: besu
replicas: 0
- el_type: nethermind
replicas: 0
- el_type: erigon
replicas: 1
- el_type: ethereumjs
replicas: 0
seed_nodes:
type: "seed"
nodes:
- el_type: geth
replicas: 6
- el_type: reth
replicas: 1
node_settings:
consensus_settings:
specs:
min_cpu: 8000
max_cpu: 8000
min_memory: 32768
max_memory: 32768
min_cpu: 1000
max_cpu: 2000
min_memory: 1024
max_memory: 2048
images:
beaconkit: northamerica-northeast1-docker.pkg.dev/prj-berachain-common-svc-01/berachain/beacon-kit:main
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in a private image repo

beaconkit: ghcr.io/berachain/beacon-kit:main
config:
timeout_propose: 3s
timeout_prevote: 1s
timeout_precommit: 1s
timeout_commit: 2s
timeout_propose: 2s
timeout_prevote: 2s
timeout_precommit: 2s
timeout_commit: 500ms
max_num_inbound_peers: 40
max_num_outbound_peers: 10
app:
payload_timeout: 2s
payload_timeout: 850ms
enable_optimistic_payload_builds: true
execution_settings:
specs:
min_cpu: 8000
max_cpu: 8000
min_memory: 32768
max_memory: 32768
min_cpu: 1000
max_cpu: 2000
min_memory: 1024
max_memory: 2048
images:
besu: hyperledger/besu:latest
besu: hyperledger/besu:24.5.4
erigon: erigontech/erigon:v2.60.9
ethereumjs: ethpandaops/ethereumjs:stable
geth: ethereum/client-go:latest
nethermind: nethermind/nethermind:latest
reth: ghcr.io/paradigmxyz/reth:latest
eth_json_rpc_endpoints:
# type has to be either blutgang or nginx
- type: blutgang
clients:
- el-full-geth-0
- el-full-geth-1
- el-full-reth-0
- el-full-reth-1
- el-full-geth-2
- el-full-geth-3
- el-full-geth-4
- el-full-geth-5
- el-full-geth-6
- el-full-geth-7
- el-full-geth-8
- el-full-geth-9
# - el-full-nethermind-3
# - el-full-besu-4
# - el-full-erigon-5
# - el-full-ethereumjs-6
additional_services:
- name: "spamoor"
- name: "tx-fuzz"
replicas: 99
replicas: 16
- name: "prometheus"
- name: "grafana"
- name: "spamoor"
- name: "pyroscope"
- name: "blockscout"
client: "el-full-reth-0"
- name: "otterscan" # otterscan supports only erigon nodes
client: "el-full-erigon-3"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how will this run if the erigon node isnt enabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed otterscan as noone is using it afaik

Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ network_configuration:
node_settings:
consensus_settings:
specs:
min_cpu: 0
min_cpu: 1000
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If min is not set, then it defaults to max value on K8s

max_cpu: 2000
min_memory: 0
min_memory: 1024
max_memory: 2048
images:
beaconkit: beacond:kurtosis-local
Expand All @@ -89,9 +89,9 @@ node_settings:
enable_optimistic_payload_builds: true
execution_settings:
specs:
min_cpu: 0
min_cpu: 1000
max_cpu: 2000
min_memory: 0
min_memory: 1024
max_memory: 2048
images:
besu: hyperledger/besu:24.5.4
Expand Down
4 changes: 2 additions & 2 deletions kurtosis/src/services/blutgang/launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ BLUTGANG_CONFIG_MOUNT_DIRPATH_ON_SERVICE = "/config"
IMAGE_NAME = "makemake1337/blutgang:latest"

# The min/max CPU/memory that blutgang can use
MIN_CPU = 0
MIN_CPU = 1000
MAX_CPU = 8000
MIN_MEMORY = 0
MIN_MEMORY = 1024
MAX_MEMORY = 8096

USED_PORTS = {
Expand Down
Loading