Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup an Aurora PostgreSQL database #431

Merged
merged 2 commits into from
Jul 24, 2023
Merged

Conversation

ryanemerson
Copy link
Contributor

@ryanemerson ryanemerson commented Jul 18, 2023

This PR allows for an AWS Aurora DB cluster to be created in a specified region and Keycloak can then be deployed to connect to that. I have made it so that Aurora DB can be deployed in a different region to the Keycloak instance, as this will be required for xsite deployments eventually.

My implementation is based upon this blog so that the DB is not exposed publicly and is limited to ROSA VPC -> Aurora VPC communication.

GH Action Workflow:

  1. Aurora Create - Creates an Aurora DB cluster with a single instance in the specified region
  2. Keycloak - Create deployment - Updated so that a peering connection is established between the Rosa Cluster VPC -> Aurora VPC, as well as updating the Keycloak deployment to use the Aurora endpoint for DB connections via an External K8s Service.
  3. Keycloak - Delete deployment - Updated to remove the peering connection
  4. ROSA Cluster - Delete - Also updated to remove peering connections

Unfortunately with 2. I was hitting the max number of input fields allowed for a GH action (10), so I had to hack around this by providing multiple Aurora fields as JSON. Suggestions on better ways to approach this are very welcome 🙂

Couple of things missing still:

  • Ability to reset Aurora DB
  • Add Aurora delete to Reaper action
  • Documentation

Closes #420

@ryanemerson ryanemerson marked this pull request as ready for review July 19, 2023 09:34
@ryanemerson ryanemerson requested a review from ahus1 July 19, 2023 09:34
@tkyjovsk tkyjovsk assigned tkyjovsk and unassigned tkyjovsk Jul 19, 2023
@tkyjovsk tkyjovsk self-requested a review July 19, 2023 12:22
@ryanemerson
Copy link
Contributor Author

Working as expected when an Aurora cluster is created in the same region as the Keycloak ROSA cluster, however there is an issue if these differ. Investigating..

aws rds create-db-instance \
--db-cluster-identifier ${AURORA_CLUSTER} \
--db-instance-identifier ${AURORA_INSTANCE} \
--db-instance-class db.t4g.large \
Copy link
Contributor

@tkyjovsk tkyjovsk Jul 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we may need the instance class to be customizable, as it affects performance, network throughput, etc.

Additionally, we may need to customize the storage type here, as the default "standard" magnetic storage has limited IOPS. I think we should use the gp2 general-purpose SSD storage at the minimum.

See options --allocated-storage, --storage-type, --iops, and: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Storage.html

Copy link
Contributor

@tkyjovsk tkyjovsk Jul 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might also be useful to have the --engine-version (the PostgreSQL version) under direct control. @ahus1 @kami619 WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right we would need the PostgreSQL version configurable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add the --engine-version to the Aurora cluster no problem, as well as making the --db-instance-class configurable. However it's not possible to configure --allocated-storage, --storage-type, --iops as these are not applicable to Aurora DB instances.

https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/Aurora.Overview.StorageReliability.html

@mhajas mhajas self-requested a review July 21, 2023 07:46
@ahus1 ahus1 changed the title Setup an Aurora PostgreSQL database. Resolves #420 Setup an Aurora PostgreSQL database Jul 21, 2023
@ryanemerson
Copy link
Contributor Author

@mhajas Inter-region VPC is working as expected now.

Copy link
Contributor

@mhajas mhajas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ryanemerson, works for me except for one small issue in Taskfile. See my comment in the code.

provision/openshift/Taskfile.yaml Outdated Show resolved Hide resolved
@ahus1
Copy link
Contributor

ahus1 commented Jul 24, 2023

@ryanemerson / @mhajas - can this PR be merged with the change that Michal suggested?

@mhajas
Copy link
Contributor

mhajas commented Jul 24, 2023

@ahus1 I am ok with merging after my suggestion is addressed.

Maybe a nice to have would be adding more logging into the scripts to have more insight into what is happening. However, I would say we can add this later if we encounter some problems.

@ryanemerson
Copy link
Contributor Author

I've accepted the commit. I'm happy for it to be merged as is and we can improve logging etc as required.

Copy link
Contributor

@mhajas mhajas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @ryanemerson!!

@mhajas mhajas merged commit 534f2c0 into keycloak:main Jul 24, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setup an Aurora PostgreSQL database
5 participants