Skip to content

Commit

Permalink
Updating docs to describe multi-AZ capabilities of the script
Browse files Browse the repository at this point in the history
  • Loading branch information
ahus1 committed Oct 31, 2023
1 parent 4d00a5c commit ab3bbf4
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 16 deletions.
2 changes: 1 addition & 1 deletion doc/kubernetes/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
|✅
|✅

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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]
====
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion provision/aws/rds/aurora_create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions provision/aws/rds/aurora_delete.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,20 @@ 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 \
--db-cluster-identifier ${AURORA_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
Expand Down

0 comments on commit ab3bbf4

Please sign in to comment.