1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00
Files
openshift-docs/modules/developer-cli-odo-creating-a-database-with-odo.adoc

64 lines
1.6 KiB
Plaintext

// Module included in the following assemblies:
:_content-type: PROCEDURE
[id="creating-a-database-with-odo_{context}"]
= Creating a database with `odo`
To create a database, you must have an access to the database Operator. For this example, Dev4Devs PostgreSQL Operator is used.
.Procedure
. View the list of the services in your project:
+
[source,terminal]
----
$ odo catalog list services
----
+
.Example output
----
Operators available in the cluster
NAME CRDs
postgresql-operator.v0.1.1 Backup, Database
----
. Store the YAML of the service in a file:
+
[source,terminal]
----
$ odo service create postgresql-operator.v0.1.1/Database --dry-run > db.yaml
----
. Add the following values under the `metadata:` section in the `db.yaml` file:
+
[source,yaml]
----
name: sampledatabase
annotations:
service.binding/db.name: 'path={.spec.databaseName}'
service.binding/db.password: 'path={.spec.databasePassword}'
service.binding/db.user: 'path={.spec.databaseUser}'
----
+
This configuration ensures that when a database service is started, appropriate annotations are added to it. Annotations help the Service Binding Operator in injecting the values for `databaseName`, `databasePassword`, and `databaseUser` into the application.
. Change the following values under the `spec:` section of the YAML file:
+
[source,yaml]
----
databaseName: "sampledb"
databasePassword: "samplepwd"
databaseUser: "sampleuser"
----
. Create a database from the YAML file:
+
[source,terminal]
----
$ odo service create --from-file db.yaml
----
+
A database instance is now present in your project.