Provision Instance and Database Separately
In the guide Provision and Binding Cloud Resources and Provision a Database and Import a SQL File for initialization, We create an RDS instance and a database together. However, you can create an RDS instance and more than one database on it. This pattern is useful when you want to save costs of creating multiple instances.
This guide will take Alibaba Cloud RDS as an example to show how to create an RDS instance more than one database separately.
terraformaddon has been enabledterraform-alibabaaddon has been enabled, version >= 1.0.3- Credentials have been configured using
vela provider add terraform-alibabaIf you have problems, you can follow to this instruction to setup.
Using the following Application to create an RDS instance.
apiVersion: core.oam.dev/v1beta1kind: Applicationmetadata:name: app-rds-instancespec:components:- name: rds-instancetype: alibaba-rds-instanceproperties:instance_name: test_single_instance
Now you can get the RDS instance ID by running the following command:
kubectl get configuration -n default rds-instance -ojson | jq -r .status.apply.outputs.instance_id.value
The result will be like
rm-bp1du0wif7kXXXXX
Using the following Application to create an RDS database. Remember to replace <your-region> and <your-instance-id> with the real values.
apiVersion: core.oam.dev/v1beta1kind: Applicationmetadata:name: app-db-1spec:components:- name: demo-database-1type: alibaba-rds-databaseproperties:region: <your-region>existing_instance_id: <your-instance-id>database_name: first_databasepassword: fake_passwordaccount_name: first_db_account
About 2 minutes later, you can check the app status by running vela status:
vela status app-db-1 -n default
You have learnt how to create an RDS instance and a database with different applications. As a platform engineer, you can use this pattern to provide database sharing the same instance to your users. When the business is growing, you can migrate database to an exclusive instance.
Last updated on Feb 9, 2023 by dependabot[bot]