FINT pgerator is an operator that creates a PostgreSQL database, user and PGBouncer connection pool when a PGDatabaseAndUser
CR is created.
Username and password will be generated and stored in secrets.
When a PGDatabaseAndUser
CR is created:
- The operator will create a PostgreSQL database, connection pool and user.
- Username, password and JDBC uri will be generated and stored in secrets.
When a PGDatabaseAndUser
CR is deleted:
- The operator will delete the PostgreSQL user and connection pool.
- The operator will not delete the PostgreSQL database.
- The operator will delete the secrets containing username and password.
apiVersion: "fintlabs.no/v1alpha1"
kind: PGDatabaseAndUser
metadata:
name: <name>
apiVersion: "fintlabs.no/v1alpha1"
kind: PGDatabaseAndUser
metadata:
name: test-user
Below is an introduction on how to set up the project. First for local development in IntelliJ, then to the cluster.
You will need an authentication token from aiven.
- Log in to https://console.azure.aiven.io/
- Go to User Information (Human icon top right of the site)
- Choose "authentication"
- Choose "Generate token"
- Give your token a name, e.g. Development
- Copy and add the token to 1password so you don't loose track of it.
- Clone the repository:
git clone https://github.com/FINTLabs/pgerator.git
- Create Run/Debug configuration
"Run -> Edit Configurations..."
- Add the following three prerequisites (Name - Value):
- fint.aiven.service - pg-alpha
- fint.aiven.token - generated in the steps mentioned in the prerequisites
- fint.data.pool-base-url - jdbc:postgresql://<aiven PgBouncer Host> : <aiven PgBouncer Port>/
- Cd to the project root and build the Gradle project:
./gradlew clean build
- Apply the custom-resource:
kubectl apply -f build/classes/java/main/META-INF/fabric8/pgdatabaseandusers.fintlabs.no-v1.yml
- Run or debug the Application in IntelliJ.
- Check that it worked:
kubectl get secrets
andkubectl get customresourcedefinitions
, you should see the name you specified in the custom .yaml file in the list. - Also check that you find the instances created in aiven.
Services -> pg-alpha -> Users
andServices -> pg-alpha -> Databases