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

Introduce SQLClaim that can handle any RDS database engine #88

Merged
merged 2 commits into from
Nov 16, 2022

Conversation

ytsarev
Copy link
Member

@ytsarev ytsarev commented Nov 14, 2022

Description of your changes

Instead of hardcoded PostgreSQL, make generic SQL XRD/Composition that can handle arbitrary RDS instance engine configuration

  • PostgrSQLInstance -> SQLInstance
  • expose engine and engineVersion in XRD
  • Add 3306 SecurityGroupRule
  • Provide mariadb example

Signed-off-by: Yury Tsarev yury@upbound.io

I have:

  • Read and followed Upbound's contribution process.
  • Run make reviewable to ensure this PR is ready for review.
  • Added backport release-x.y labels to auto-backport this PR, as appropriate.

How has this code been tested

k apply -f examples/cluster-claim.yaml,examples/postgres-claim.yaml,examples/mariadb-claim.yaml

PostgreSQL connectivity test from within instantiated EKS cluster

cat psql.yaml
apiVersion: v1
kind: Pod
metadata:
  name: see-db
  namespace: default
spec:
  containers:
  - name: see-db
    image: postgres:12
    command: ['psql']
    args: ['-c', 'SELECT current_database();']
    env:
    - name: PGDATABASE
      value: postgres
    - name: PGHOST
      value: platform-ref-aws-db-postgres-t5jnc-hgktq.cxal1lomznba.us-west-2.rds.amazonaws.com
    - name: PGUSER
      value: masteruser
    - name: PGPASSWORD
      value: <password>

k logs -f see-db
 current_database
------------------
 postgres
(1 row)

mariadb connectivity test from within instantiated EKS cluster

kubectl run -i --tty --rm debug --image=mysql --restart=Never -- sh
sh-4.4# mysql -h platform-ref-aws-db-mariadb-grpz9-92kzs.cxal1lomznba.us-west-2.rds.amazonaws.com -u masteruser -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 79
Server version: 5.5.5-10.6.10-MariaDB managed by https://aws.amazon.com/rds/

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases
    -> ;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| innodb             |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.00 sec)

* PostgrSQLInstance -> SQLInstance
* expose `engine` and `engineVersion` in XRD
* Add 3306 SecurityGroupRule
* Provide mariadb example

Signed-off-by: Yury Tsarev <yury@upbound.io>
Copy link
Member

@stevendborrelli stevendborrelli left a comment

Choose a reason for hiding this comment

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

Approved with a few minor comments.

kubectl get -f postgres-claim.yaml 
NAME                                                                  SYNCED   READY   CONNECTION-SECRET                   AGE
sqlinstance.aws.platformref.upbound.io/platform-ref-aws-db-postgres   True     True    platform-ref-aws-db-conn-postgres   31m

NAME                TYPE     DATA   AGE
secret/psqlsecret   Opaque   1      31m

kubectl get -f mariadb-claim.yaml
NAME                                                                 SYNCED   READY   CONNECTION-SECRET                  AGE
sqlinstance.aws.platformref.upbound.io/platform-ref-aws-db-mariadb   True     True    platform-ref-aws-db-conn-mariadb   4m10s
  • directory database/postgres be something like database/sql
  • The readme should indicate that the cluster is required to provision the DBs. In the graph in the readme they look like independent paths.

password: dXBiMHVuZHIwY2s1ITMxMzM3
kind: Secret
metadata:
name: psqlsecret
Copy link
Member

Choose a reason for hiding this comment

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

should this be mariadbsecret?

storageGB: 5
passwordSecretRef:
namespace: default
name: psqlsecret
Copy link
Member

Choose a reason for hiding this comment

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

mariadbsecret?

@@ -29,6 +29,12 @@ spec:
parameters:
type: object
properties:
engine:
Copy link
Member

Choose a reason for hiding this comment

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

Should this be an enum of supported db types?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was thinking about it but do not want to immediately maintain everything that is described in https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CreateDBInstance.html

Copy link
Member

Choose a reason for hiding this comment

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

I'd just support mariadb and postgres in the enum.

Copy link
Member Author

Choose a reason for hiding this comment

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

that make sense, I will amend the PR

* Add enum for engine type validation
* Rename mariadb claim secret
* Rename db abstraction directory
* Use `dbName` to create custome database within the instance
  by default so it can be consumed by aribtrary app

Signed-off-by: Yury Tsarev <yury@upbound.io>
@ytsarev
Copy link
Member Author

ytsarev commented Nov 15, 2022

@stevendborrelli PR amended, could you please take another brief look?

Copy link
Member

@stevendborrelli stevendborrelli left a comment

Choose a reason for hiding this comment

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

LGTM, cluster + mariadb provisioned successfully.

@ytsarev ytsarev merged commit bebcc95 into main Nov 16, 2022
@ytsarev ytsarev deleted the add-mariadb branch November 16, 2022 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants