From ab3bbf419f653e5d41b5c5d546cecda26c25f16c Mon Sep 17 00:00:00 2001 From: Alexander Schwartz Date: Tue, 31 Oct 2023 18:58:42 +0100 Subject: [PATCH] Updating docs to describe multi-AZ capabilities of the script --- doc/kubernetes/modules/ROOT/nav.adoc | 2 +- .../ROOT/pages/customizing-deployment.adoc | 2 +- .../ROOT/pages/openshift/cross-site-rosa.adoc | 2 +- .../ROOT/pages/storage-configurations.adoc | 3 ++- ...stgres.adoc => aurora-regional-postgres.adoc} | 16 ++++++++++------ provision/aws/rds/aurora_create.sh | 6 +++++- provision/aws/rds/aurora_delete.sh | 11 ++++++----- 7 files changed, 26 insertions(+), 16 deletions(-) rename doc/kubernetes/modules/ROOT/pages/storage/{aurora-postgres.adoc => aurora-regional-postgres.adoc} (83%) diff --git a/doc/kubernetes/modules/ROOT/nav.adoc b/doc/kubernetes/modules/ROOT/nav.adoc index db167557..6835705c 100644 --- a/doc/kubernetes/modules/ROOT/nav.adoc +++ b/doc/kubernetes/modules/ROOT/nav.adoc @@ -26,7 +26,7 @@ * xref:customizing-deployment.adoc[] * xref:storage-configurations.adoc[] ** xref:storage/postgres.adoc[] -** xref:storage/aurora-postgres.adoc[] +** xref:storage/aurora-regional-postgres.adoc[] ** xref:storage/aurora-global-postgres.adoc[] ** xref:storage/cockroach-single.adoc[] ** xref:storage/cockroach-operator.adoc[] diff --git a/doc/kubernetes/modules/ROOT/pages/customizing-deployment.adoc b/doc/kubernetes/modules/ROOT/pages/customizing-deployment.adoc index 9df3ceb6..fa3bedb2 100644 --- a/doc/kubernetes/modules/ROOT/pages/customizing-deployment.adoc +++ b/doc/kubernetes/modules/ROOT/pages/customizing-deployment.adoc @@ -50,7 +50,7 @@ See xref:storage/postgres.adoc[] for more information. `aurora-postgres`:: Connect to an AWS Aurora PostgreSQL cluster. + -See xref:storage/aurora-postgres.adoc[] and xref:storage/aurora-global-postgres.adoc[] for more information. +See xref:storage/aurora-regional-postgres.adoc[] and xref:storage/aurora-global-postgres.adoc[] for more information. `cockroach-single`:: Deploy a single-node CockroachDB instance. + diff --git a/doc/kubernetes/modules/ROOT/pages/openshift/cross-site-rosa.adoc b/doc/kubernetes/modules/ROOT/pages/openshift/cross-site-rosa.adoc index 2354e5d3..c97dd0f3 100644 --- a/doc/kubernetes/modules/ROOT/pages/openshift/cross-site-rosa.adoc +++ b/doc/kubernetes/modules/ROOT/pages/openshift/cross-site-rosa.adoc @@ -62,7 +62,7 @@ Check scripts in directory `link:{github-files}/provision/aws/rds/[provision/aws This installation scripts support most of the variables defined by the original deployment scripts. -For Aurora DB variables, check the xref:storage/aurora-postgres.adoc[Aurora installation] page. +For Aurora DB variables, check the xref:storage/aurora-regional-postgres.adoc[Aurora installation] page. For Infinispan deployment, check xref:openshift/installation-infinispan.adoc#ispn-variables[Infinispan installation] page. diff --git a/doc/kubernetes/modules/ROOT/pages/storage-configurations.adoc b/doc/kubernetes/modules/ROOT/pages/storage-configurations.adoc index ac7bff8e..c7de50ce 100644 --- a/doc/kubernetes/modules/ROOT/pages/storage-configurations.adoc +++ b/doc/kubernetes/modules/ROOT/pages/storage-configurations.adoc @@ -26,7 +26,8 @@ The following table lists the different storages: |✅ |✅ -|xref:storage/aurora-postgres.adoc[Aurora PostgreSQL] +|xref:storage/aurora-regional-postgres.adoc[Aurora Regional PostgreSQL] or + +xref:storage/aurora-global-postgres.adoc[Aurora Global PostgreSQL] |✅ |✅ diff --git a/doc/kubernetes/modules/ROOT/pages/storage/aurora-postgres.adoc b/doc/kubernetes/modules/ROOT/pages/storage/aurora-regional-postgres.adoc similarity index 83% rename from doc/kubernetes/modules/ROOT/pages/storage/aurora-postgres.adoc rename to doc/kubernetes/modules/ROOT/pages/storage/aurora-regional-postgres.adoc index 93e3175f..84724ea7 100644 --- a/doc/kubernetes/modules/ROOT/pages/storage/aurora-postgres.adoc +++ b/doc/kubernetes/modules/ROOT/pages/storage/aurora-regional-postgres.adoc @@ -1,5 +1,6 @@ -= Using Amazon Aurora PostgreSQL storage -:description: An Amazon Aurora PostgreSQL instance can be used as the underlying database for Keycloak in either single, or multi-site configurations. += Using Amazon Regional Aurora PostgreSQL storage +:description: An Amazon Regional Aurora PostgreSQL instance can be used as the underlying database for Keycloak in either single, or multi-site configurations. +:page-aliases: storage/aurora-postgres.adoc {description} Currently, this is only supported with Keycloak deployments on ROSA. @@ -16,9 +17,11 @@ AURORA_REGION= # The AWS region hosting the Aurora cluster AURORA_INSTANCES= # The number of Aurora db instances to create in the AURORA_REGION, defaults to 1 ---- -This creates the necessary VPCs, subnets and routes required by an Aurora cluster as well as `$AURORA_INSTANCES` Aurora instances -for said cluster. The script waits until the cluster and all instance are available. If the cluster already exists, -a message indicating this is displayed and the script will fail with exit code 1. +This creates the necessary VPCs, subnets and routes required by an Aurora cluster as well as `$AURORA_INSTANCES` Aurora instances for said cluster. +To create a multi-AZ database, create two instances +The script currently doesn't support more than two AZs for the instances created, all additional instances are distributed across the two AZs supported by the script. +The script waits until the cluster and all instances are available. +If the cluster already exists, a message indicating this is displayed and the script will fail with exit code 1. [NOTE] ==== @@ -93,7 +96,8 @@ AWS_REGION= # The AWS region hosting the ROSA cluster ---- == Deleting an Aurora Cluster -Before deleting an Aurora cluster it's first necessary for all Peering Connections established with ROSA cluster(s) to + +Before deleting an Aurora cluster, it is first necessary for all Peering Connections established with ROSA cluster(s) to be removed. To remove an Aurora cluster, execute `./provision/aws/rds/aurora_delete.sh` with the following env: diff --git a/provision/aws/rds/aurora_create.sh b/provision/aws/rds/aurora_create.sh index 5deba591..7d21579c 100755 --- a/provision/aws/rds/aurora_create.sh +++ b/provision/aws/rds/aurora_create.sh @@ -88,12 +88,16 @@ aws rds create-db-cluster \ --db-subnet-group-name ${AURORA_SUBNET_GROUP_NAME} \ ${AURORA_GLOBAL_CLUSTER_IDENTIFIER} +# For now only two AZs in each region are supported due to the two subnets created above +readarray -t AZS < <(echo ${AWS_REGION}a; echo ${AWS_REGION}b) + for i in $( seq ${AURORA_INSTANCES} ); do aws rds create-db-instance \ --db-cluster-identifier ${AURORA_CLUSTER} \ --db-instance-identifier "${AURORA_CLUSTER}-instance-${i}" \ --db-instance-class ${AURORA_INSTANCE_CLASS} \ - --engine ${AURORA_ENGINE} + --engine ${AURORA_ENGINE} \ + --availability-zone "${AZS[$(((i - 1) % ${#AZS[@]}))]}" done for i in $( seq ${AURORA_INSTANCES} ); do diff --git a/provision/aws/rds/aurora_delete.sh b/provision/aws/rds/aurora_delete.sh index 01a10e9d..7a79832c 100755 --- a/provision/aws/rds/aurora_delete.sh +++ b/provision/aws/rds/aurora_delete.sh @@ -14,9 +14,9 @@ AURORA_VPC=$(aws ec2 describe-vpcs \ ) # Delete the Aurora DB cluster and instances -for i in $( seq ${AURORA_INSTANCES} ); do - echo "Deleting Aurora DB instance ${AURORA_CLUSTER}-instance-${i}" - aws rds delete-db-instance --db-instance-identifier "${AURORA_CLUSTER}-instance-${i}" || true +for i in $( aws rds describe-db-clusters --output json | jq -r .DBClusters[0].DBClusterMembers[].DBInstanceIdentifier ); do + echo "Deleting Aurora DB instance ${i}" + aws rds delete-db-instance --db-instance-identifier "${i}" --skip-final-snapshot || true done aws rds delete-db-cluster \ @@ -24,9 +24,10 @@ aws rds delete-db-cluster \ --skip-final-snapshot \ || true -for i in $( seq ${AURORA_INSTANCES} ); do - aws rds wait db-instance-deleted --db-instance-identifier "${AURORA_CLUSTER}-instance-${i}" +for i in $( aws rds describe-db-clusters --output json | jq -r .DBClusters[0].DBClusterMembers[].DBInstanceIdentifier ); do + aws rds wait db-instance-deleted --db-instance-identifier "${i}" done + aws rds wait db-cluster-deleted --db-cluster-identifier ${AURORA_CLUSTER} # Delete the Aurora subnet group