Skip to content

Commit

Permalink
Use sharded mongo everywhere
Browse files Browse the repository at this point in the history
Issue: ZENKO-4856
  • Loading branch information
francoisferrand committed Aug 13, 2024
1 parent d3b176d commit 0aea64a
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 63 deletions.
1 change: 0 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
},
"containerEnv": {
"ZENKO_MONGODB_DATABASE": "zenko-database",
"ZENKO_MONGODB_SHARDED": "true"
},
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "bash .devcontainer/setup.sh"
Expand Down
2 changes: 2 additions & 0 deletions .github/scripts/end2end/configs/zenko.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ kind: Zenko
metadata:
name: ${ZENKO_NAME}
${ZENKO_ANNOTATIONS}
zenko.io/x-backbeat-oneshard-replicaset: data-db-mongodb-sharded-shard-0
zenko.io/x-backbeat-oneshard-replicaset-hosts: data-db-mongodb-sharded-shard0-data-0.data-db-mongodb-sharded-headless.default.svc.cluster.local:27017
spec:
version: ${ZENKO_VERSION_NAME}
replicas: 1
Expand Down
15 changes: 4 additions & 11 deletions .github/scripts/end2end/deploy-zenko.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,14 @@ else
fi

# TODO: use kustomize
ZENKO_MONGODB_SHARDED=${ZENKO_MONGODB_SHARDED:-'false'}
if [ "${ZENKO_MONGODB_SHARDED}" = 'true' ]; then
export ZENKO_ANNOTATIONS="annotations:
zenko.io/x-backbeat-oneshard-replicaset: data-db-mongodb-sharded-shard-0
zenko.io/x-backbeat-oneshard-replicaset-hosts: data-db-mongodb-sharded-shard0-data-0.data-db-mongodb-sharded-headless.default.svc.cluster.local:27017"
export ZENKO_MONGODB_ENDPOINT="data-db-mongodb-sharded.default.svc.cluster.local:27017"
export ZENKO_MONGODB_CONFIG="writeConcern: 'majority'
export ZENKO_ANNOTATIONS="annotations:"
export ZENKO_MONGODB_ENDPOINT="data-db-mongodb-sharded.default.svc.cluster.local:27017"
export ZENKO_MONGODB_CONFIG="writeConcern: 'majority'
enableSharding: true"
else
export ZENKO_MONGODB_ENDPOINT="dev-db-mongodb-primary-0.dev-db-mongodb-headless.default.svc.cluster.local:27017"
fi
export ZENKO_MONGODB_DATABASE="${ZENKO_MONGODB_DATABASE:-'datadb'}"

if [ "${TIME_PROGRESSION_FACTOR}" -gt 1 ]; then
export ZENKO_ANNOTATIONS="${ZENKO_ANNOTATIONS:-annotations:}
export ZENKO_ANNOTATIONS="$ZENKO_ANNOTATIONS
zenko.io/time-progression-factor: \"${TIME_PROGRESSION_FACTOR}\""
fi

Expand Down
47 changes: 1 addition & 46 deletions .github/scripts/end2end/install-kind-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,15 @@ KAFKA_OPERATOR_VERSION=0.20.1
INGRESS_NGINX_VERSION=controller-v1.1.0
PROMETHEUS_VERSION=v0.52.1
KEYCLOAK_VERSION=18.4.4
BITNAMI_MONGODB_VER=7.8.0

MONGODB_ROOT_USERNAME=root
MONGODB_ROOT_PASSWORD=rootpass
MONGODB_APP_USERNAME=data
MONGODB_APP_PASSWORD=datapass
MONGODB_APP_DATABASE="${ZENKO_MONGODB_DATABASE:-'datadb'}"
MONGODB_RS_KEY=0123456789abcdef
# force a 4.0 image as that's what artesca uses
DEPS_FILE="$DIR/../../../solution-base/deps.yaml"
MONGODB_IMAGE_TAG=$(yq eval ".mongodb.tag" $DEPS_FILE)
MONGODB_INIT_IMAGE_NAME=$(yq eval ".mongodb-shell.image" $DEPS_FILE)
MONGODB_INIT_IMAGE_TAG=$(yq eval ".mongodb-shell.tag" $DEPS_FILE)
MONGODB_EXPORTER_IMAGE_TAG=$(yq eval ".mongodb-exporter.tag" $DEPS_FILE)

ENABLE_KEYCLOAK_HTTPS=${ENABLE_KEYCLOAK_HTTPS:-'false'}
ZENKO_MONGODB_SHARDED=${ZENKO_MONGODB_SHARDED:-'false'}

KAFKA_CHART=banzaicloud-stable/kafka-operator

Expand Down Expand Up @@ -114,39 +106,6 @@ get_image_from_deps() {
yq eval ".$dep_name | (.sourceRegistry // \"docker.io\") + \"/\" + .image + \":\" + .tag" $SOLUTION_BASE_DIR/deps.yaml
}

mongodb_replicaset() {
### TODO: update to use chart in project
kubectl create configmap \
--from-file=${DIR}/../../../solution-base/mongodb/scripts mongodb-init-scripts \
--dry-run=client -o yaml | kubectl apply -f -

helm upgrade --install dev-db bitnami/mongodb \
--version $BITNAMI_MONGODB_VER \
-f "${DIR}/configs/mongodb_options.yaml" \
--set "volumePermissions.enabled=true" \
--set "volumePermissions.image.repository=${MONGODB_INIT_IMAGE_NAME}" \
--set "volumePermissions.image.tag=${MONGODB_INIT_IMAGE_TAG}" \
--set "persistence.storageClass=standard" \
--set "usePassword=true" \
--set "mongodbRootPassword=$MONGODB_ROOT_PASSWORD" \
--set "replicaSet.key=$MONGODB_RS_KEY" \
--set "extraEnvVars[0].name=MONGODB_APP_USERNAME" \
--set "extraEnvVars[0].value=$MONGODB_APP_USERNAME" \
--set "extraEnvVars[1].name=MONGODB_APP_PASSWORD" \
--set "extraEnvVars[1].value=$MONGODB_APP_PASSWORD" \
--set "extraEnvVars[2].name=MONGODB_APP_DATABASE" \
--set "extraEnvVars[2].value=$MONGODB_APP_DATABASE" \
--set "extraEnvVars[3].name=MONGODB_NAMESPACE" \
--set "extraEnvVars[3].value=default" \
--set "replicaSet.pdb.minAvailable.secondary=1" \
--set "replicaSet.pdb.minAvailable.arbiter=0" \
--set "replicaSet.replicas.secondary=0" \
--set "replicaSet.replicas.arbiter=0"

kubectl rollout status statefulset dev-db-mongodb-primary
kubectl rollout status statefulset dev-db-mongodb-secondary
}

retry() {
local count=0
local errMsg=${1:-'reached max retry attempts'}
Expand Down Expand Up @@ -198,9 +157,5 @@ mongodb_sharded() {
}

build_solution_base_manifests
if [ $ZENKO_MONGODB_SHARDED = 'true' ]; then
mongodb_sharded
else
mongodb_replicaset
fi
mongodb_sharded

5 changes: 0 additions & 5 deletions .github/workflows/end2end.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,6 @@ jobs:
registry: ghcr.io
- name: Deploy Zenko
uses: ./.github/actions/deploy
env:
ZENKO_MONGODB_SHARDED: "true"
with:
zkop_tag: 1.6.0-preview.2
extra_components: |
Expand All @@ -492,7 +490,6 @@ jobs:
- name: Deploy second Zenko for PRA
run: bash deploy-zenko.sh end2end-pra default './configs/zenko.yaml'
env:
ZENKO_MONGODB_SHARDED: "true"
ZENKO_MONGODB_DATABASE: "pradb"
EXTRA_COMPONENTS: |
drctl:
Expand Down Expand Up @@ -625,7 +622,6 @@ jobs:
uses: ./.github/actions/deploy
env:
GIT_ACCESS_TOKEN: ${{ secrets.GIT_ACCESS_TOKEN }}
ZENKO_MONGODB_SHARDED: "true"
- name: Run backbeat end to end tests
run: bash run-e2e-test.sh "end2end" ${E2E_IMAGE_NAME}:${E2E_IMAGE_TAG} "backbeat" "default"
working-directory: ./.github/scripts/end2end
Expand Down Expand Up @@ -682,7 +678,6 @@ jobs:
uses: ./.github/actions/deploy
env:
GIT_ACCESS_TOKEN: ${{ secrets.GIT_ACCESS_TOKEN }}
ZENKO_MONGODB_SHARDED: "true"
ZENKO_ENABLE_SOSAPI: true
TIME_PROGRESSION_FACTOR: 86400
TRANSITION_ONE_DAY_EARLIER: false
Expand Down

0 comments on commit 0aea64a

Please sign in to comment.