Deploying EDB Postgres with a custom resource

After the EDB Postgres service is installed on IBM Cloud Pak® for Data, if you have access to the cluster, you can use a custom resource file to deploy one or more instances of the EDB Postgres database. Using a custom resource provides more flexibility than using the web console.

Before you begin

If you want to create a custom user name and password for your EDB Postgres instance, see Creating a custom EDB Postgres user name and password before you deploy.
Best practice: You can run the commands in this task exactly as written if you set up environment variables. For instructions, see Setting up installation environment variables.

Ensure that you source the environment variables before you run the commands in this task.

Procedure

  1. Set the following environment variables:
    1. Set the EDB_INSTANCE_NAME environment variable to the name that you want to use for this database instance.
      export EDB_INSTANCE_NAME=<name>
    2. Set the EDB_VERSION environment variable to the version of the database to deploy.
      export EDB_VERSION=<version>

      Use the following table to determine the appropriate value:

      Cloud Pak for Data version Service instance versions
      (Pick one)
      4.8.7 12.20, 13.16, 14.13, 15.8, 16.4
      4.8.6 12.19, 13.15, 14.12, 15.7, 16.3
      4.8.5 12.18, 13.14, 14.11, 15.6, 16.2
      4.8.4 12.18, 13.14, 14.11, 15.6, 16.2
      4.8.3 12.17, 13.13, 14.10, 15.5
      4.8.2 12.17, 13.13, 14.10, 15.5
      4.8.1 12.16, 13.12, 14.9, 15.4
      4.8.0 12.16, 13.12, 14.9, 15.4
    3. Set the EDB_INSTANCE_TYPE environment variable to the type of EDB Postgres instance you want to create. Valid values are Enterprise or Standard.
      export EDB_INSTANCE_TYPE=<EDBInstanceType>
    4. Set the STG_CLASS_BLOCK environment variable to the block storage class you want to use for this database instance.
      export STG_CLASS_BLOCK=<storage>
  2. Run the following command to deploy your database:
    cat <<EOF | oc apply -n ${PROJECT_CPD_INST_OPERANDS} -f -
    apiVersion: edb.cpd.ibm.com/v1
    kind: CPDEdbInstance
    metadata:
      name: ${EDB_INSTANCE_NAME}
    spec:
      type: ${EDB_INSTANCE_TYPE}
      members: 1
      version: "${EDB_VERSION}"
      storageClass: ${STG_CLASS_BLOCK}
      shutdown: false
      storageSize: 100Gi
      resources:
        requests:
          cpu: 1
          memory: 4Gi
        limits:
          cpu: 1
          memory: 4Gi
    EOF

    It might take up to five minutes for the instance to be ready.

    An EDB Postgres Enterprise license is required to enable Oracle compatibility. Complete the following steps to add the feature:
    1. Under spec, add oracleCompatibility: true.
    2. Set type to Enterprise.
  3. Use the following command to check the status of the instance:
    oc describe CPDEdbInstance ${EDB_INSTANCE_NAME}

    The output of the command will look similar to the following example that shows details of an EDB instance named cpdedbinstance-cr-compability-demo:

    Status:
    Conditions:
    Ansible Result:
    Changed:               5
    Completion:            2021-06-23T20:29:03.857898
    Failures:              0
    Ok:                    27
    Skipped:               5
    Last Transition Time:  2021-06-23T20:28:08Z
    Message:               Awaiting next reconciliation
    Reason:                Successful
    Status:                True
    Type:                  Running
    Edb Status:            In Progress
    Edb URL:               jdbc:edb://cpdedbinstance-cr-compability-demo-edb-db.zen:5432/edb

    The instance is ready for use when Edb Status changes from In Progress to Completed.

What to do next

EDB Postgres is ready to use. To get started with EDB Postgres, see Administering the EDB Postgres service and Working with EDB Postgres databases.