Skip to content

Commit

Permalink
updating the kube-setup-indexd job to apply single table driver setti…
Browse files Browse the repository at this point in the history
…ngs.py for specific environments.
  • Loading branch information
EliseCastle23 committed Dec 10, 2024
1 parent 05aecc0 commit 8d59a7b
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 2 deletions.
79 changes: 79 additions & 0 deletions apis_configs/indexd_multi_table/indexd_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
from indexd.index.drivers.alchemy import SQLAlchemyIndexDriver
from indexd.alias.drivers.alchemy import SQLAlchemyAliasDriver
from indexd.auth.drivers.alchemy import SQLAlchemyAuthDriver
from indexd.index.drivers.single_table_alchemy import SingleTableSQLAlchemyIndexDriver
import config_helper
from os import environ
import json

APP_NAME = "indexd"


def load_json(file_name):
return config_helper.load_json(file_name, APP_NAME)


conf_data = load_json("creds.json")

usr = conf_data.get("db_username", "{{db_username}}")
db = conf_data.get("db_database", "{{db_database}}")
psw = conf_data.get("db_password", "{{db_password}}")
pghost = conf_data.get("db_host", "{{db_host}}")
pgport = 5432
index_config = conf_data.get("index_config")
CONFIG = {}

CONFIG["JSONIFY_PRETTYPRINT_REGULAR"] = False

dist = environ.get("DIST", None)
if dist:
CONFIG["DIST"] = json.loads(dist)

arborist = environ.get("ARBORIST", "false").lower() == "true"

USE_SINGLE_TABLE = True

if USE_SINGLE_TABLE is True:


CONFIG["INDEX"] = {
"driver": SingleTableSQLAlchemyIndexDriver(
"postgresql+psycopg2://{usr}:{psw}@{pghost}:{pgport}/{db}".format(
usr=usr, psw=psw, pghost=pghost, pgport=pgport, db=db
),
index_config=index_config,
)
}
else:
CONFIG["INDEX"] = {
"driver": SQLAlchemyIndexDriver(
"postgresql+psycopg2://{usr}:{psw}@{pghost}:{pgport}/{db}".format(
usr=usr, psw=psw, pghost=pghost, pgport=pgport, db=db
),
index_config=index_config,
)
}

CONFIG["ALIAS"] = {
"driver": SQLAlchemyAliasDriver(
"postgresql+psycopg2://{usr}:{psw}@{pghost}:{pgport}/{db}".format(
usr=usr, psw=psw, pghost=pghost, pgport=pgport, db=db
)
)
}

if arborist:
AUTH = SQLAlchemyAuthDriver(
"postgresql+psycopg2://{usr}:{psw}@{pghost}:{pgport}/{db}".format(
usr=usr, psw=psw, pghost=pghost, pgport=pgport, db=db
),
arborist="http://arborist-service/",
)
else:
AUTH = SQLAlchemyAuthDriver(
"postgresql+psycopg2://{usr}:{psw}@{pghost}:{pgport}/{db}".format(
usr=usr, psw=psw, pghost=pghost, pgport=pgport, db=db
)
)

settings = {"config": CONFIG, "auth": AUTH}
11 changes: 9 additions & 2 deletions gen3/bin/kube-setup-indexd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
source "${GEN3_HOME}/gen3/lib/utils.sh"
gen3_load "gen3/lib/kube-setup-init"

manifestPath=$(g3k_manifest_path)
singleTable="$(jq -r ".[\"global\"][\"indexd_single_table\"]" < "$manifestPath" | tr '[:upper:]' '[:lower:]')"

[[ -z "$GEN3_ROLL_ALL" ]] && gen3 kube-setup-secrets

if [[ ! -f "$(gen3_secrets_folder)/.rendered_indexd_userdb" ]]; then
Expand All @@ -19,8 +22,12 @@ if [[ ! -f "$(gen3_secrets_folder)/.rendered_indexd_userdb" ]]; then
fi

g3kubectl delete secrets/indexd-secret > /dev/null 2>&1 || true;
g3kubectl create secret generic indexd-secret --from-file=local_settings.py="${GEN3_HOME}/apis_configs/indexd_settings.py" "--from-file=${GEN3_HOME}/apis_configs/config_helper.py"

if "$singleTable" = true; then
g3kubectl create secret generic indexd-secret --from-file=local_settings.py="${GEN3_HOME}/apis_configs/indexd_multi_table/indexd_settings.py" "--from-file=${GEN3_HOME}/apis_configs/config_helper.py"
else
g3kubectl create secret generic indexd-secret --from-file=local_settings.py="${GEN3_HOME}/apis_configs/indexd_settings.py" "--from-file=${GEN3_HOME}/apis_configs/config_helper.py"
fi

gen3 roll indexd
g3kubectl apply -f "${GEN3_HOME}/kube/services/indexd/indexd-service.yaml"
gen3 roll indexd-canary || true
Expand Down

0 comments on commit 8d59a7b

Please sign in to comment.