|
| 1 | +echo "Fetching some infrastructure values..." |
| 2 | + |
| 3 | +# Authenticate with Kubernetes Cluster |
| 4 | +echo "Generating kubeconfig to authenticate with Azure Kubernetes cluster..." |
| 5 | +# To be able to interact with the Kubernetes cluster we deployed earlier, we need to obtain the credentials for it. |
| 6 | +# These credentials are saved in a file called kubeconfig which the cloud provider CLI tool can generate for us and kubectl can use. |
| 7 | +# Ensure we've got a path setup for the kubeconfig file: |
| 8 | +export KUBECONFIG=$(pwd)/kubeconfig |
| 9 | +echo "Kubeconfig path: $KUBECONFIG" |
| 10 | +rm -f $KUBECONFIG |
| 11 | +# Retrieve the credentials for the cluster: |
| 12 | +az aks get-credentials --resource-group "$NAME" --name "$NAME" |
| 13 | + |
| 14 | +# Get the directory where this script is located |
| 15 | +# It also works when sourced from zsh |
| 16 | +if [[ -n "${BASH_SOURCE[0]}" ]]; then |
| 17 | + SOURCE_PATH="${BASH_SOURCE[0]}" |
| 18 | +else |
| 19 | + # For zsh compatibility |
| 20 | + SOURCE_PATH="${(%):-%x}" |
| 21 | +fi |
| 22 | + |
| 23 | +SCRIPT_DIR="$(cd "$(dirname "$SOURCE_PATH")" && pwd)" |
| 24 | +TARGET_DIR_RELATIVE="$SCRIPT_DIR/../deploy/_tf" |
| 25 | +TARGET_DIR_ABSOLUTE=$(realpath "$TARGET_DIR_RELATIVE") |
| 26 | + |
| 27 | +export DB_ROOT_UN=postgres |
| 28 | +export DB_ROOT_PW=$($TF_CMD -chdir=$TARGET_DIR_ABSOLUTE output -raw pg_main_pw) |
| 29 | +export DB_PORT=5432 |
| 30 | +export DB_HOST=$($TF_CMD -chdir=$TARGET_DIR_ABSOLUTE output -raw db_host) |
| 31 | + |
| 32 | +export REDIS_HOST=$($TF_CMD -chdir=$TARGET_DIR_ABSOLUTE output -raw redis_host) |
| 33 | +export REDIS_AUTH=$($TF_CMD -chdir=$TARGET_DIR_ABSOLUTE output -raw redis_pw) |
| 34 | + |
| 35 | +export SERVICE_ACCOUNT_DNS=$($TF_CMD -chdir=$TARGET_DIR_ABSOLUTE output -raw client_id_dns) |
| 36 | +export SERVICE_ACCOUNT_STUDIO=$($TF_CMD -chdir=$TARGET_DIR_ABSOLUTE output -raw client_id_studio) |
| 37 | + |
| 38 | +echo "Infrastructure values fetched successfully:" |
| 39 | +echo "DB_ROOT_UN=$DB_ROOT_UN" |
| 40 | +echo "DB_ROOT_PW=$DB_ROOT_PW" |
| 41 | +echo "DB_PORT=$DB_PORT" |
| 42 | +echo "DB_HOST=$DB_HOST" |
| 43 | +echo "REDIS_HOST=$REDIS_HOST" |
| 44 | +echo "REDIS_AUTH=$REDIS_AUTH" |
| 45 | +echo "SERVICE_ACCOUNT_DNS=$SERVICE_ACCOUNT_DNS" |
| 46 | +echo "SERVICE_ACCOUNT_STUDIO=$SERVICE_ACCOUNT_STUDIO" |
0 commit comments