Skip to content

Commit

Permalink
Remove 'your' from docs; make cluster name mandatory for setup
Browse files Browse the repository at this point in the history
  • Loading branch information
KaloyanTanev committed Dec 6, 2024
1 parent 45f3730 commit 19fadd4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,24 @@ The way this is achieved is by separating the EL, CL and Grafana from the Charon
If you already have running validator node in Docker, the Docker containers will be moved to the new multi cluster setup.

```bash
./multi_cluster/setup.sh -c {YOUR_CLUSTER_NAME}
./multi_cluster/setup.sh {CLUSTER_NAME}
```

You can inspect what you have in the `./clusters/` directory. Each subfolder is a cluster with the following structure:

```directory
clusters
└───{YOUR_CLUSTER_NAME} # cluster name
└───{CLUSTER_NAME} # cluster name
│ │ .charon # folder including secret material used by charon
│ │ data # data from the validator client and prometheus
│ │ lodestar # scripts used by lodestar
│ │ prometheus # scripts and configs used by prometheus
│ │ .env # environment variables used by the cluster
│ │ docker-compose.yml # docker compose used by the cluster
│ # N.B.: only services with profile "cluster" are ran
└───{YOUR_CLUSTER_NAME_2}
└───{YOUR_CLUSTER_NAME_...}
└───{YOUR_CLUSTER_NAME_N}
└───{CLUSTER_NAME_2}
└───{CLUSTER_NAME_...}
└───{CLUSTER_NAME_N}
```

Note that those folders and files are copied from the root directory. Meaning all configurations and setup you have already done, will be copied to this first cluster of the multi cluster setup.
Expand All @@ -85,29 +85,29 @@ Manage the Charon + Validator Client + Prometheus containers of each cluster fou
### Add cluster

```bash
./multi_cluster/cluster.sh add {YOUR_CLUSTER_NAME}
./multi_cluster/cluster.sh add {CLUSTER_NAME}
```

Note that only the `.env`, `lodestar/`, `prometheus/` and `docker-compose.yml` files and directories are coiped from the root directory to the new cluster. `.charon/` and `data/` folders are expected to be from a brand new cluster that you will setup in the `./clusters/{YOUR_CLUSTER_NAME}` directory.
Note that only the `.env`, `lodestar/`, `prometheus/` and `docker-compose.yml` files and directories are coiped from the root directory to the new cluster. `.charon/` and `data/` folders are expected to be from a brand new cluster that you will setup in the `./clusters/{CLUSTER_NAME}` directory.

### Start cluster

It is expected that you have already done the regular procedure from cluster setup and you have `./clusters/{YOUR_CLUSTER_NAME}/.charon/` folder.
It is expected that you have already done the regular procedure from cluster setup and you have `./clusters/{CLUSTER_NAME}/.charon/` folder.

```bash
./multi_cluster/cluster.sh start {YOUR_CLUSTER_NAME}
./multi_cluster/cluster.sh start {CLUSTER_NAME}
```

### Stop cluster

```bash
./multi_cluster/cluster.sh stop {YOUR_CLUSTER_NAME}
./multi_cluster/cluster.sh stop {CLUSTER_NAME}
```

### Delete cluster

```bash
./multi_cluster/cluster.sh delete {YOUR_CLUSTER_NAME}
./multi_cluster/cluster.sh delete {CLUSTER_NAME}
```

## Manage base node
Expand Down
24 changes: 13 additions & 11 deletions multi_cluster/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,42 @@

# shellcheck disable=SC1090,SC1091,SC2012

current_cluster_name=default
cluster_already_set=

usage() {
echo "Usage: $0 [OPTIONS]"
echo "Usage: $0 [OPTIONS] NAME"
echo ""
echo " Create a multi cluster setup from a traditional single cluster setup."
echo " Create a multi cluster setup from a traditional single cluster setup. Name of the first cluster should be specified."
echo ""
echo "Options:"
echo " -h Display this help message."
echo " -c string Name of the current cluster. (default: \"default\")"
echo ""
echo "Example:"
echo " $0 initial-cluster"
}

while getopts "hc:" opt; do
while getopts "h:" opt; do
case $opt in
h)
usage
exit 0
;;
c)
current_cluster_name=${OPTARG}
;;
\?)
usage
exit 1
;;
esac
done
shift "$((OPTIND - 1))"
cluster_name=$1

if [ "$current_cluster_name" = "default" ]; then
echo "WARN: -c flag not specified. Using default cluster name 'default'."
if [ -z "$cluster_name" ]; then
echo 'Missing cluster name argument.' >&2
usage
exit 1
fi

cluster_dir=./clusters/${current_cluster_name}
cluster_dir=./clusters/${cluster_name}

# Check if clusters directory already exists.
if test -d ./clusters; then
Expand Down

0 comments on commit 19fadd4

Please sign in to comment.