Databases
Learn to connect and manage databases.
MariaDB
Humanitec has integrated support for both hosted PostgreSQL solutions (like Google CloudSQL, Aiven, Amazon RDS, etc), and self-managed deployments.
Google CloudSQL
Google CloudSQL uses a slightly different Humanitec Driver to other MariaDB providers, but this is transparent outside the resource definitions.
Prerequisites
- You must have a CloudSQL instance running
- You must have a Service Account with the Cloud SQL Client role
- You must create a key for this service account in JSON format. See Google’s account keys documentation for more information. The access key must use the GCP Console/gcloud format (i.e., the first example in the linked documentation)
- You must have the CloudSQL Admin API enabled for your project
- You must have a user defined on the instance for Workloads to use when connecting to the database
Add A GCP Account
To integrate a CloudSQL account you need to add a Cloud Account (if you haven’t already).
- From the Cloud Accounts screen, click Google Cloud Platform in the Add accounts section
- In the modal dialog provide a unique name for the account in the Account name field
- In the Service account access key(JSON) field paste the account key for the service account that you wish to use
- Click Authorize
Add The Resource Definition
- From the Resource Management screen, click Add resource definition
- In the modal dialog click MariaDB
- Next, select the mariadb-cloudsql Driver
- Finally, provide the following information, then click Add progress
- In the ID field provide a unique ID for the resource
- In the Credentials field select the Cloud Account you created earlier
- In the Fully qualified CloudSQL instance name provide the instance name in the format
<project-id>:<region>:<id>
- If the maintenance database name is not
mariadb
provide that in the Database name field - In the User / Role and Password fields provide the credentials that Workloads should use when connecting to the database
Resource Matching
Now that the resource is defined you will need to add matching criteria.
- Click on the relevant row in the Resource Definition table
- Then switch to the Matching Criteria tab
- Click Add new Criteria
- Configure the matching rules as needed,
- Click Save
Other MariaDB
Unlike Google CloudSQL, most mariadb implementations use a single shared Driver.
Prerequisites
- You must have a database instance/server running
- If you are using a hosted MariaDB it is recommended provide a management service account with Database CRUD permissions. You will need to add this account via the Cloud Accounts screen
- You must have a user defined on the instance for Workloads to use when connecting to the database
Add The Resource Definition
- From the Resource Management screen, click Add resource definition
- In the modal dialog click MariaDB
- Next, select the mariadb-cloudsql Driver
- Finally, provide the following information, then click Add progress
- In the ID field provide a unique ID for the resource
- (If you are using a management account) in the Credentials field select the Cloud Account you created earlier
- In the Fully qualified CloudSQL instance name provide the instance name in the format
<project-id>:<region>:<id>
- In the User / Role and Password fields provide the credentials that Workloads should use when connecting to the database
- In the Hostname or IP field provide the Hostname or IP address that the Workloads can access the database on
- In the Port field provide the port number that the database is running on
Resource Matching
Now that the resource is defined you will need to add matching criteria.
- Click on the relevant row in the Resource Definition table
- Then switch to the Matching Criteria tab
- Click Add new Criteria
- Configure the matching rules as needed,
- Click Save
MySQL
Humanitec has integrated support for both hosted MySQL solutions (like Google CloudSQL, Aiven, Amazon RDS, etc), and self-managed deployments.
Google CloudSQL
Google CloudSQL uses a slightly different Humanitec Driver to other MySQL providers, but this is transparent outside the resource definitions.
Prerequisites
- You must have a CloudSQL instance running
- You must have a Service Account with the Cloud SQL Client role
- You must create a key for this service account in JSON format. See Google’s account keys documentation for more information. The access key must use the GCP Console/gcloud format (i.e., the first example in the linked documentation)
- You must have the CloudSQL Admin API enabled for your project
- You must have a user defined on the instance for Workloads to use when connecting to the database
Add A GCP Account
To integrate a CloudSQL account you need to add a Cloud Account (if you haven’t already).
- From the Cloud Accounts screen, click Google Cloud Platform in the Add accounts section
- In the modal dialog provide a unique name for the account in the Account name field
- In the Service account access key(JSON) field paste the account key for the service account that you wish to use
- Click Authorize
Add The Resource Definition
- From the Resource Management screen, click Add resource definition
- In the modal dialog click MySQL
- Next, select the mysql-cloudsql Driver
- Finally, provide the following information, then click Add progress
- In the ID field provide a unique ID for the resource
- In the Credentials field select the Cloud Account you created earlier
- In the Fully qualified CloudSQL instance name provide the instance name in the format
<project-id>:<region>:<id>
- If the maintenance database name is not
mysql
provide that in the Database name field - In the User / Role and Password fields provide the credentials that Workloads should use when connecting to the database
Resource Matching
Now that the resource is defined you will need to add matching criteria.
- Click on the relevant row in the Resource Definition table
- Then switch to the Matching Criteria tab
- Click Add new Criteria
- Configure the matching rules as needed,
- Click Save
Other MySQL
Unlike Google CloudSQL, most mysql implementations use a single shared Driver.
Prerequisites
- You must have a database instance/server running
- If you are using a hosted MySQL it is recommended provide a management service account with Database CRUD permissions. You will need to add this account via the Cloud Accounts screen
- You must have a user defined on the instance for Workloads to use when connecting to the database
Add The Resource Definition
- From the Resource Management screen, click Add resource definition
- In the modal dialog click MySQL
- Next, select the mysql-cloudsql Driver
- Finally, provide the following information, then click Add progress
- In the ID field provide a unique ID for the resource
- (If you are using a management account) in the Credentials field select the Cloud Account you created earlier
- In the Fully qualified CloudSQL instance name provide the instance name in the format
<project-id>:<region>:<id>
- In the User / Role and Password fields provide the credentials that Workloads should use when connecting to the database
- In the Hostname or IP field provide the Hostname or IP address that the Workloads can access the database on
- In the Port field provide the port number that the database is running on
Resource Matching
Now that the resource is defined you will need to add matching criteria.
- Click on the relevant row in the Resource Definition table
- Then switch to the Matching Criteria tab
- Click Add new Criteria
- Configure the matching rules as needed,
- Click Save
PostgreSQL
Humanitec has integrated support for both hosted PostgreSQL solutions (like Google CloudSQL, Aiven, Amazon RDS, etc), and self-managed deployments.
Google CloudSQL
Google CloudSQL uses a slightly different Humanitec Driver to other Postgres providers, but this is transparent outside the resource definitions.
Prerequisites
- You must have a CloudSQL instance running
- You must have a Service Account with the Cloud SQL Client role
- You must create a key for this service account in JSON format. See Google’s account keys documentation for more information. The access key must use the GCP Console/gcloud format (i.e., the first example in the linked documentation)
- You must have the CloudSQL Admin API enabled for your project
- You must have a user defined on the instance for Workloads to use when connecting to the database
Add A GCP Account
To integrate a CloudSQL account you need to add a Cloud Account (if you haven’t already).
- From the Cloud Accounts screen, click Google Cloud Platform in the Add accounts section
- In the modal dialog provide a unique name for the account in the Account name field
- In the Service account access key(JSON) field paste the account key for the service account that you wish to use
- Click Authorize
Add The Resource Definition
- From the Resource Management screen, click Add resource definition
- In the modal dialog click Postgres
- Next, select the postgres-cloudsql Driver
- Finally, provide the following information, then click Add progress
- In the ID field provide a unique ID for the resource
- In the Credentials field select the Cloud Account you created earlier
- In the Fully qualified CloudSQL instance name provide the instance name in the format
<project-id>:<region>:<id>
- If the maintenance database name is not
postgres
provide that in the Database name field - In the User / Role and Password fields provide the credentials that Workloads should use when connecting to the database
Resource Matching
Now that the resource is defined you will need to add matching criteria.
- Click on the relevant row in the Resource Definition table
- Then switch to the Matching Criteria tab
- Click Add new Criteria
- Configure the matching rules as needed,
- Click Save
Other Postgres
Unlike Google CloudSQL, most postgres implementations use a single shared Driver.
Prerequisites
- You must have a database instance/server running
- If you are using a hosted Postgres it is recommended provide a management service account with Database CRUD permissions. You will need to add this account via the Cloud Accounts screen
- You must have a user defined on the instance for Workloads to use when connecting to the database
Add The Resource Definition
- From the Resource Management screen, click Add resource definition
- In the modal dialog click Postgres
- Next, select the postgres-cloudsql Driver
- Finally, provide the following information, then click Add progress
- In the ID field provide a unique ID for the resource
- (If you are using a management account) in the Credentials field select the Cloud Account you created earlier
- In the Fully qualified CloudSQL instance name provide the instance name in the format
<project-id>:<region>:<id>
- In the User / Role and Password fields provide the credentials that Workloads should use when connecting to the database
- In the Hostname or IP field provide the Hostname or IP address that the Workloads can access the database on
- In the Port field provide the port number that the database is running on
Resource Matching
Now that the resource is defined you will need to add matching criteria.
- Click on the relevant row in the Resource Definition table
- Then switch to the Matching Criteria tab
- Click Add new Criteria
- Configure the matching rules as needed,
- Click Save
Relational Databases
Humanitec supports a range of Relational Database Management Systems (RDBMS) out of the box. In all of these systems there is a distinction between the database and the RDBMS server or instance.
Access Methods
The access method refers to how Humanitec connects to an RDBMS instance. Currently, 3 access methods are supported out of the box:
Direct
A direct connection is where Humanitec connects directly to the RDBMS instance. The instance must be accessible on the public internet for this to be possible. This is the default configuration when using Aiven managed databases, or public Amazon RDS and Azure Databases.
Over SSH
When connecting over SSH, Humanitec first connects to bastion host or jump server and then makes an onward connection from that server to the instance itself. This is a common way of administering private RDBMS instances, for example a private Amazon RDS instance running inside a private VPC.
Google Cloud SQL Proxy
Google provides their own proxy which can be used to securely connect to private Cloud SQL instances without the need of a dedicated bastion host.
The supported databases along with their access methods are summarized here:
PostgreSQL | MySQL | MariaDB | SQL Server | |
---|---|---|---|---|
Direct | ✓ | ✓ | ✓ | coming soon |
Over SSH | ✓ | ✓ | ✓ | coming soon |
Google Cloud SQL Proxy | ✓ | ✓ | ✓ | coming soon |