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

Setup exporter-2 for mainnet on prod #1505

Merged
merged 1 commit into from
Jul 25, 2024
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
9 changes: 7 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ Deploy exporter to prod:
- export SSV_EXPORTER_MEM_LIMIT=$PROD_SSV_EXPORTER_MEM_LIMIT
- export SSV_EXPORTER_MAINNET_CPU_LIMIT=$PROD_SSV_EXPORTER_MAINNET_CPU_LIMIT
- export SSV_EXPORTER_MAINNET_MEM_LIMIT=$PROD_SSV_EXPORTER_MAINNET_MEM_LIMIT
- export SSV_EXPORTER_2_MAINNET_CPU_LIMIT=$PROD_SSV_EXPORTER_2_MAINNET_CPU_LIMIT
- export SSV_EXPORTER_2_MAINNET_MEM_LIMIT=$PROD_SSV_EXPORTER_2_MAINNET_MEM_LIMIT
- export SSV_NODES_CPU_LIMIT_V3=$PROD_SSV_NODES_CPU_LIMIT_V3
- export SSV_NODES_MEM_LIMIT_V3=$PROD_SSV_NODES_MEM_LIMIT_V3
- curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.18.0/bin/linux/amd64/kubectl
Expand All @@ -187,7 +189,10 @@ Deploy exporter to prod:
# │ 🔴 Deploy Mainnet exporter |
# +------------------------------+
# - .k8/production/mainnet/scripts/deploy-exporters.sh $DOCKER_REPO_INFRA_PROD $CI_COMMIT_SHA ssv $APP_REPLICAS_INFRA_PROD blox-infra-prod kubernetes-admin@blox-infra-prod ssv.network $K8S_API_VERSION $SSV_EXPORTER_MAINNET_CPU_LIMIT $SSV_EXPORTER_MAINNET_MEM_LIMIT

#
# +------------------------------+
# │ 🔴 Deploy Mainnet exporter 2|
# +------------------------------+
- .k8/production/mainnet/scripts/deploy-exporters-2.sh $DOCKER_REPO_INFRA_PROD $CI_COMMIT_SHA ssv $APP_REPLICAS_INFRA_PROD blox-infra-prod kubernetes-admin@blox-infra-prod ssv.network $K8S_API_VERSION $SSV_EXPORTER_2_MAINNET_CPU_LIMIT $SSV_EXPORTER_2_MAINNET_MEM_LIMIT
only:
- main

118 changes: 118 additions & 0 deletions .k8/production/mainnet/scripts/deploy-exporters-2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#!/bin/bash

set -x

if [[ -z $1 ]]; then
echo "Please provide DOCKERREPO"
exit 1
fi

if [[ -z $2 ]]; then
echo "Please provide IMAGETAG"
exit 1
fi

if [[ -z $3 ]]; then
echo "Please provide NAMESPACE"
exit 1
fi

if [[ -z $4 ]]; then
echo "Please provide number of replicas"
exit 1
fi

if [[ -z $5 ]]; then
echo "Please provide deployment type: blox-infra-stage|blox-infra-prod"
exit 1
fi

if [[ -z $6 ]]; then
echo "Please provide k8s context"
exit 1
fi

if [[ -z $7 ]]; then
echo "Pleae provide domain suffix"
exit 1
fi

if [[ -z ${8} ]]; then
echo "Please provide k8s app version"
exit 1
fi

if [[ -z ${9} ]]; then
echo "Please provide exporter cpu limit"
exit 1
fi

if [[ -z ${10} ]]; then
echo "Please provide exporter cpu limit"
exit 1
fi

DOCKERREPO=$1
IMAGETAG=$2
NAMESPACE=$3
REPLICAS=$4
DEPL_TYPE=$5
K8S_CONTEXT=$6
DOMAIN_SUFFIX=$7
K8S_API_VERSION=$8
EXPORTER_CPU_LIMIT=$9
EXPORTER_MEM_LIMIT=${10}

echo $DOCKERREPO
echo $IMAGETAG
echo $NAMESPACE
echo $REPLICAS
echo $DEPL_TYPE
echo $K8S_CONTEXT
echo $DOMAIN_SUFFIX
echo $K8S_API_VERSION
echo $EXPORTER_CPU_LIMIT
echo $EXPORTER_MEM_LIMIT

# create namespace if not exists
if ! kubectl --context=$K8S_CONTEXT get ns | grep -q $NAMESPACE; then
echo "$NAMESPACE created"
kubectl --context=$K8S_CONTEXT create namespace $NAMESPACE
fi

#config
#if [[ -d .k8/configmaps/ ]]; then
#config
#for file in $(ls -A1 .k8/configmaps/); do
#sed -i -e "s|REPLACE_NAMESPACE|${NAMESPACE}|g" ".k8/configmaps/${file}"
#done
#fi

#if [[ -d .k8/secrets/ ]]; then
#for file in $(ls -A1 .k8/secrets/); do
#sed -i -e "s|REPLACE_NAMESPACE|${NAMESPACE}|g" ".k8/secrets/${file}"
#done
#fi

DIR=".k8/production/mainnet"
DEPLOY_FILES=(
"ssv-exporter-2.yml"
)

if [[ -d $DIR ]]; then
for file in "${DEPLOY_FILES[@]}"; do
sed -i -e "s|REPLACE_NAMESPACE|${NAMESPACE}|g" \
-e "s|REPLACE_DOCKER_REPO|${DOCKERREPO}|g" \
-e "s|REPLACE_REPLICAS|${REPLICAS}|g" \
-e "s|REPLACE_DOMAIN_SUFFIX|${DOMAIN_SUFFIX}|g" \
-e "s|REPLACE_API_VERSION|${K8S_API_VERSION}|g" \
-e "s|REPLACE_EXPORTER_CPU_LIMIT|${EXPORTER_CPU_LIMIT}|g" \
-e "s|REPLACE_EXPORTER_MEM_LIMIT|${EXPORTER_MEM_LIMIT}|g" \
-e "s|REPLACE_IMAGETAG|${IMAGETAG}|g" "${DIR}/${file}" || exit 1
done
fi

#deploy
for file in "${DEPLOY_FILES[@]}"; do
kubectl --context=$K8S_CONTEXT apply -f "${DIR}/${file}" || exit 1
done
6 changes: 1 addition & 5 deletions .k8/production/mainnet/ssv-exporter-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,7 @@ spec:
- key: kubernetes.io/role
operator: In
values:
- ssv-main
- key: beta.kubernetes.io/instance-type
operator: In
values:
- m5a.4xlarge
- ssv-exporter
containers:
- name: ssv-full-node-mainnet-1
image: REPLACE_DOCKER_REPO:REPLACE_IMAGETAG
Expand Down
39 changes: 34 additions & 5 deletions .k8/production/mainnet/ssv-exporter-2.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,39 @@
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: ssv-full-node-mainnet-2-api
namespace: REPLACE_NAMESPACE
spec:
hosts:
- "ssv-full-node-mainnet-2.REPLACE_DOMAIN_SUFFIX"
gateways:
- ssv-full-node-mainnet-2-api
http:
- route:
- destination:
host: ssv-full-node-mainnet-2
port:
number: 16016
---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: ssv-full-node-mainnet-2-api
namespace: REPLACE_NAMESPACE
spec:
selector:
istio: ingressgateway-int
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "-ssv-full-node-mainnet-2.REPLACE_DOMAIN_SUFFIX"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: ssv-full-node-mainnet-2
namespace: REPLACE_NAMESPACE
Expand Down Expand Up @@ -92,11 +125,7 @@ spec:
- key: kubernetes.io/role
operator: In
values:
- ssv-main
- key: beta.kubernetes.io/instance-type
operator: In
values:
- m5a.4xlarge
- ssv-exporter
containers:
- name: ssv-full-node-mainnet-2
image: REPLACE_DOCKER_REPO:REPLACE_IMAGETAG
Expand Down
Loading