Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 4 additions & 12 deletions examples/telescope-authz/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ HELM_NAME = telescope-starship
HELM_FILE = configs/starship.yaml
HELM_REPO = starship
HELM_CHART = devnet
HELM_VERSION = v0.1.38
HELM_VERSION = v0.1.47

###############################################################################
### All commands ###
###############################################################################

.PHONY: setup
setup: check setup-helm
setup: check

.PHONY: test
test:
Expand All @@ -25,21 +25,13 @@ clean: stop clean-kind
### Helm commands ###
###############################################################################

.PHONY: setup-helm
setup-helm:
helm repo add $(HELM_REPO) https://cosmology-tech.github.io/starship/
helm repo update
helm search repo $(HELM_REPO)/$(HELM_CHART) --version $(HELM_VERSION)

.PHONY: install
install:
@echo "Installing the helm chart. This is going to take a while....."
@echo "You can check the status with \"kubectl get pods\", run in another terminal please"
helm install -f $(HELM_FILE) $(HELM_NAME) $(HELM_REPO)/$(HELM_CHART) --version $(HELM_VERSION)
bash $(CURDIR)/scripts/install.sh --config $(HELM_FILE) --version $(HELM_VERSION) --name $(HELM_NAME)

.PHONY: debug
debug:
helm install --dry-run --debug -f $(HELM_FILE) $(HELM_NAME) $(HELM_REPO)/$(HELM_CHART)
bash $(CURDIR)/scripts/install.sh --config $(HELM_FILE) --version $(HELM_VERSION) --name $(HELM_NAME) --dry-run

.PHONY: delete
delete:
Expand Down
4 changes: 2 additions & 2 deletions examples/telescope-authz/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"locks": "npm run locks:remove && npm run locks:create",
"codegen": "node scripts/codegen.js",
"e2e": "npm run e2e:test",
"e2e:deps": "make setup",
"e2e:deps": "make setup-deps",
"e2e:kind": "make setup-kind",
"e2e:start": "make install",
"e2e:port": "make port-forward",
Expand Down Expand Up @@ -89,4 +89,4 @@
"ts-jest": "^29.1.0",
"typescript": "4.9.3"
}
}
}
6 changes: 5 additions & 1 deletion examples/telescope-authz/scripts/dev-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function color() {
# Define a function to install a binary on macOS
install_macos() {
case $1 in
docker) color red "Please install docker. Follow: https://docs.docker.com/desktop/install/mac-install/" ;;
kubectl) brew install kubectl ;;
helm) brew install helm ;;
yq) brew install yq ;;
Expand All @@ -25,10 +26,11 @@ install_linux() {
color green "Installing $1 at ~/.local/bin, please add it to PATH"
mkdir -p ~/.local/bin
case $1 in
docker) color red "Please install docker. Follow: https://docs.docker.com/engine/install/ubuntu/" ;;
kubectl) curl -Lks "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" > ~/.local/bin/kubectl && chmod +x ~/.local/bin/kubectl ;;
helm) curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash ;;
yq) curl -Lks "https://github.com/mikefarah/yq/releases/download/v4.33.3/yq_linux_amd64" > ~/.local/bin/yq && chmod +x ~/.local/bin/yq ;;
kind) curl -Lks https://kind.sigs.k8s.io/dl/v0.18.0/kind-linux-amd64 > ~/.local/bin/kind && chmod +x ~/.local/bin/kind ;;
kind) curl -Lks https://kind.sigs.k8s.io/dl/v0.18.1/kind-linux-amd64 > ~/.local/bin/kind && chmod +x ~/.local/bin/kind ;;
esac
}

Expand Down Expand Up @@ -61,5 +63,7 @@ check_binary kubectl
check_binary helm
check_binary yq
check_binary kind
check_binary docker

color green "All binaries are installed"

125 changes: 125 additions & 0 deletions examples/telescope-authz/scripts/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
#!/bin/bash

## Script used to install the helm chart for the devnet from a config file
## Usage:
## ./scripts/install.sh --coinfig <config_file>
## Options:
## -c|--config: config file to use (default: config.yaml)
## -v|--version: helm chart version (default: 0.1.43)

set -euo pipefail

# read config file from args into variable
CONFIGFILE="config.yaml"

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
echo "Script dir: ${SCRIPT_DIR}"

# default values
DRY_RUN=""
TIMEOUT=""
NAMESPACE=""
HELM_REPO="starship"
HELM_CHART="starship/devnet"
HELM_REPO_URL="https://cosmology-tech.github.io/starship/"
HELM_CHART_VERSION="0.1.43"

# check_helm function verifies the helm binary is installed
function check_helm() {
if ! command -v helm &> /dev/null
then
echo "helm could not be found; please install it first!!!"
exit
fi
}

# setup_helm function adds the helm repo and updates it
function setup_helm() {
if [ -d "$HELM_CHART" ]; then
echo "using local helm chart"
return
fi
helm repo add ${HELM_REPO} ${HELM_REPO_URL}
helm repo update
helm search repo ${HELM_CHART} --version ${HELM_CHART_VERSION}
}

function set_helm_args() {
if [[ $TIMEOUT ]]; then
args="$args --timeout $TIMEOUT --wait --debug"
fi
if [[ $NAMESPACE ]]; then
args="$args --namespace $NAMESPACE --create-namespace"
fi
if [[ $DRY_RUN ]]; then
args="$args --dry-run --debug"
fi
num_chains=$(yq -r ".chains | length - 1" ${CONFIGFILE})
if [[ $num_chains -lt 0 ]]; then
echo "No chains to parse: num: $num_chains"
return 0
fi
for i in $(seq 0 $num_chains); do
chain=$(yq -r ".chains[$i].name" ${CONFIGFILE})
scripts=$(yq -r ".chains[$i].scripts" ${CONFIGFILE})
if [[ "$scripts" == "null" ]]; then
return 0
fi
datadir="$(cd "$(dirname -- "${CONFIGFILE}")" >/dev/null; pwd -P)"
for script in $(yq -r ".chains[$i].scripts | keys | .[]" ${CONFIGFILE}); do
args="$args --set-file chains[$i].scripts.$script.data=$datadir/$(yq -r ".chains[$i].scripts.$script.file" ${CONFIGFILE})"
done
done
}

function install_chart() {
args=""
set_helm_args
echo "name: ${HELM_NAME}, args: $args, chart: ${HELM_CHART}, version: ${HELM_CHART_VERSION}"
helm install ${HELM_NAME} ${HELM_CHART} --version ${HELM_CHART_VERSION} -f ${CONFIGFILE} $args
}

while [ $# -gt 0 ]; do
case "$1" in
-c|--config)
CONFIGFILE="$2"
shift 2 # past argument=value
;;
-v|--version)
HELM_CHART_VERSION="$2"
shift 2 # past argument
;;
-t|--timeout)
TIMEOUT="$2"
shift 2 # past argument
;;
-n|--name)
HELM_NAME="$2"
shift 2 # past argument
;;
--namespace)
NAMESPACE="$2"
shift 2 # past argument
;;
--chart)
HELM_CHART="$2"
shift 2 # past argument
;;
--dry-run)
DRY_RUN=1
shift # past argument
;;
-*|--*)
echo "Unknown option $1"
exit 1
;;
*)
;;
esac
done

check_helm
setup_helm
install_chart


78 changes: 63 additions & 15 deletions examples/telescope-authz/scripts/port-forward.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,18 @@ function stop_port_forward() {

# Default values
CHAIN_RPC_PORT=26657
CHAIN_COMETMOCK_PORT=22331
CHAIN_GRPC_PORT=9090
CHAIN_LCD_PORT=1317
CHAIN_EXPOSER_PORT=8081
CHAIN_FAUCET_PORT=8000
RELAYER_REST_PORT=3000
RELAYER_EXPOSER_PORT=8081
EXPLORER_LCD_PORT=8080
REGISTRY_LCD_PORT=8080
REGISTRY_GRPC_PORT=9090
MONITORING_PROMETHEUS_PORT=8080
MONITORING_GRAFANA_PORT=8080

for i in "$@"; do
case $i in
Expand All @@ -48,23 +54,54 @@ stop_port_forward
echo "Port forwarding for config ${CONFIGFILE}"
echo "Port forwarding all chains"
num_chains=$(yq -r ".chains | length - 1" ${CONFIGFILE})
if [[ $num_chains -lt 0 ]]; then
if [[ $num_chains -gt -1 ]]; then
for i in $(seq 0 $num_chains); do
# derive chain pod name from chain id
# https://github.com/cosmology-tech/starship/blob/main/charts/devnet/templates/_helpers.tpl#L56
chain=$(yq -r ".chains[$i].name" ${CONFIGFILE} )
chain=${chain/_/"-"}
localrpc=$(yq -r ".chains[$i].ports.rpc" ${CONFIGFILE} )
localgrpc=$(yq -r ".chains[$i].ports.grpc" ${CONFIGFILE} )
locallcd=$(yq -r ".chains[$i].ports.rest" ${CONFIGFILE} )
localexp=$(yq -r ".chains[$i].ports.exposer" ${CONFIGFILE})
localfaucet=$(yq -r ".chains[$i].ports.faucet" ${CONFIGFILE})
color yellow "chains: forwarded $chain"
if [[ $(yq -r ".chains[$i].cometmock.enabled" $CONFIGFILE) == "true" ]];
then
[[ "$localrpc" != "null" ]] && color yellow " cometmock rpc to http://localhost:$localrpc" && kubectl port-forward pods/$chain-cometmock-0 $localrpc:$CHAIN_COMETMOCK_PORT > /dev/null 2>&1 &
else
[[ "$localrpc" != "null" ]] && color yellow " rpc to http://localhost:$localrpc" && kubectl port-forward pods/$chain-genesis-0 $localrpc:$CHAIN_RPC_PORT > /dev/null 2>&1 &
fi
[[ "$localgrpc" != "null" ]] && color yellow " grpc to http://localhost:$localgrpc" && kubectl port-forward pods/$chain-genesis-0 $localgrpc:$CHAIN_GRPC_PORT > /dev/null 2>&1 &
[[ "$locallcd" != "null" ]] && color yellow " lcd to http://localhost:$locallcd" && kubectl port-forward pods/$chain-genesis-0 $locallcd:$CHAIN_LCD_PORT > /dev/null 2>&1 &
[[ "$localexp" != "null" ]] && color yellow " exposer to http://localhost:$localexp" && kubectl port-forward pods/$chain-genesis-0 $localexp:$CHAIN_EXPOSER_PORT > /dev/null 2>&1 &
[[ "$localfaucet" != "null" ]] && color yellow " faucet to http://localhost:$localfaucet" && kubectl port-forward pods/$chain-genesis-0 $localfaucet:$CHAIN_FAUCET_PORT > /dev/null 2>&1 &
sleep 1
done
else
echo "No chains to port-forward: num: $num_chains"
exit 1
fi
for i in $(seq 0 $num_chains); do
chain=$(yq -r ".chains[$i].name" ${CONFIGFILE} )
localrpc=$(yq -r ".chains[$i].ports.rpc" ${CONFIGFILE} )
locallcd=$(yq -r ".chains[$i].ports.rest" ${CONFIGFILE} )
localexp=$(yq -r ".chains[$i].ports.exposer" ${CONFIGFILE})
localfaucet=$(yq -r ".chains[$i].ports.faucet" ${CONFIGFILE})
[[ "$localrpc" != "null" ]] && kubectl port-forward pods/$chain-genesis-0 $localrpc:$CHAIN_RPC_PORT > /dev/null 2>&1 &
[[ "$locallcd" != "null" ]] && kubectl port-forward pods/$chain-genesis-0 $locallcd:$CHAIN_LCD_PORT > /dev/null 2>&1 &
[[ "$localexp" != "null" ]] && kubectl port-forward pods/$chain-genesis-0 $localexp:$CHAIN_EXPOSER_PORT > /dev/null 2>&1 &
[[ "$localfaucet" != "null" ]] && kubectl port-forward pods/$chain-genesis-0 $localfaucet:$CHAIN_FAUCET_PORT > /dev/null 2>&1 &
sleep 1
color yellow "chains: forwarded $chain lcd to http://localhost:$locallcd, rpc to http://localhost:$localrpc, faucet to http://localhost:$localfaucet"
done


echo "Port forward relayers"
num_relayers=$(yq -r ".relayers | length - 1" ${CONFIGFILE})
if [[ $num_relayers -gt -1 ]]; then
for i in $(seq 0 $num_relayers); do
# derive chain pod name from chain id
# https://github.com/cosmology-tech/starship/blob/main/charts/devnet/templates/_helpers.tpl#L56
relayer=$(yq -r ".relayers[$i].name" ${CONFIGFILE} )
relayer=$(yq -r ".relayers[$i].type" ${CONFIGFILE} )-${relayer/_/"-"}
localrest=$(yq -r ".relayers[$i].ports.rest" ${CONFIGFILE} )
localexposer=$(yq -r ".relayers[$i].ports.exposer" ${CONFIGFILE} )
color yellow "relayers: forwarded $relayer"
[[ "$localrest" != "null" ]] && color yellow " rpc to http://localhost:$localrest" && kubectl port-forward pods/$relayer-0 $localrest:$RELAYER_REST_PORT > /dev/null 2>&1 &
[[ "$localexposer" != "null" ]] && color yellow " rpc to http://localhost:$localexposer" && kubectl port-forward pods/$relayer-0 $localexposer:$RELAYER_EXPOSER_PORT > /dev/null 2>&1 &
sleep 1
done
else
echo "No relayer to port-forward: num: $num_relayers"
fi


echo "Port forward services"

Expand All @@ -82,3 +119,14 @@ then
sleep 1
color green "Open the explorer to get started.... http://localhost:8080"
fi

if [[ $(yq -r ".monitoring.enabled" $CONFIGFILE) == "true" ]];
then
color yellow "monitoring port forward:"
localgrafana=$(yq -r ".monitoring.ports.grafana" ${CONFIGFILE})
localprometheus=$(yq -r ".monitoring.ports.prometheus" ${CONFIGFILE})
[[ "$localgrafana" != "null" ]] && color yellow " grafana to http://localhost:$localgrafana" && kubectl port-forward service/grafana $localgrafana:$MONITORING_GRAFANA_PORT > /dev/null 2>&1 &
[[ "$localprometheus" != "null" ]] && color yellow " prometheus to http://localhost:$localprometheus" && kubectl port-forward service/prometheus-service $localprometheus:$MONITORING_PROMETHEUS_PORT > /dev/null 2>&1 &
sleep 1
fi