Provision an RDS instance with more than one database

In the guide Provision and Binding Cloud Resources and Provision a Database and Import a SQL File for initialization, only one database will be created in an RDS instance. This tutorial will show you how to create more than one database in an RDS instance.

In the reference doc for Alibaba Cloud RDS, set database_name if you want to create one database. If you want to create more than one database, set databases to array of databases. Each database is a map, the map contains the following attributes: name, character_set, description.

  1. [
  2. {
  3. "name" : "test",
  4. "character_set" : "utf8",
  5. "description" : "test database"
  6. },
  7. {
  8. "name" : "test2",
  9. "character_set" : "utf8",
  10. "description" : "test database"
  11. }
  12. ]
NameDescriptionTypeRequiredDefault
database_nameDatabase namestringfalse
databasesThe database list, each database is a map, the map contains the following attributes: name, character_set, description, like [{“name”:”test”,”character_set”:”utf8”,”description”:”test database”},]. It conflicts with database_name.list(map(string))false

Applying the following application can create more than one database in an RDS instance.

⚠️ This section requires your platform engineers have already enabled cloud resources addon.

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: alibaba-rds-multiple-databases
  5. spec:
  6. components:
  7. - name: db
  8. type: alibaba-rds
  9. properties:
  10. instance_name: dblinks
  11. account_name: oamtest
  12. password: U34rfwefwefffaked
  13. databases:
  14. - name: dev
  15. character_set: utf8
  16. description: "dev database"
  17. - name: prod
  18. character_set: utf8
  19. description: "prod database"
  20. writeConnectionSecretToRef:
  21. name: db-conn