Deploying and Managing Your Database With Cloud 66
Deploying and Managing Your Database With Cloud 66
Here's a rundown of how you can set up and manage a variety of databases using Cloud 66's tools.
Join the DZone community and get the full member experience.Join For Free
Compliant Database DevOps and the role of DevSecOps DevOps is becoming the new normal in application development, and DevSecOps is now entering the picture. By balancing the desire to release code faster with the need for the same code to be secure, it addresses increasing demands for data privacy. But what about the database? How can databases be included in both DevOps and DevSecOps? What additional measures should be considered to achieve truly compliant database DevOps? This whitepaper provides a valuable insight. Get the whitepaper
Last month, James wrote a blog post offering tips for managing your production database while also putting forward the case for using a managed database service. I'm going to expand on this topic for this week's "how-to" series, talking you through how to setup and deploy your database with Cloud 66.
Deploying Your Database
Cloud 66 gives you the ability to add a database at any time during a stack's life cycle. We currently support the following databases, with no need for additional configuration after deployment:
MySQL (or Percona, if configured via Manifest)
SQLite (only in development environments)
When creating a Docker stack, you can add as many databases as you need in your service configuration during the stack build phase. For Rack-based stacks, Cloud 66 automatically detects whether your application relies on a database during your code analysis. This is based on a combination of your Gemfile and your database.yml or mongoid.yml files.
After you've analyzed your code, ensure your desired database type is displayed in the "About your app" section of the analysis results. If you haven't specified a username and password for your database, Cloud 66 will automatically generate these credentials for you. These will be available as environment variables and your application will be configured to use them.
Database Deployment Types
No Database (External)
This option allows you to deploy your application without a database managed by Cloud 66 and is ideal if it's hosted externally. Please note that if there is no connectivity to your database, or your database host is not configured correctly, the deployment will fail.
This option deploys your chosen database to the same server as your web server. This option is intended primarily for development, as running your database locally in production is not advised. In this scenario, your application database configuration will be amended to target your local database server. If you scale up your web server, these settings will also be automatically amended to reflect your database configuration.
This option will automatically create a new server for your database and configure your application accordingly.
Customizing Your Database Configuration
You can customize the database configuration of your servers using CustomConfig. CustomConfig is available for MySQL, PostgreSQL, Redis, and MongoDB.
Editing and committing your database CustomConfig will perform the following steps on every database server in your stack, one by one, sequentially:
- Check your template for Liquid syntax errors.
- Determine the correct server configuration and prepare general variables.
- Prepare custom variables for your database type (eg. server_state).
- Compile the database configuration based on the information from the server and database type.
- Upload the configuration to the server. Restart your database.
WARNING: A bad database configuration might stop your database from working. Take extra care to make sure the configuration is correct.
Database Customization Variables
There are a number of variables available for use in your database CustomConfig. Some are general for all database types while others are database-specific.
The following variables are available to any database CustomConfig.
The following variables are only available in the MySQL CustomConfig:
The following variables are only available in the PostgreSQL CustomConfig:
The following variables are only available in the Redis CustomConfig:
Managed and Unmanaged Database Backups
Cloud 66 also has an add-on option to backup your database, on a schedule of your choosing. You can specify whether you want managed or unmanaged backups, how often you'd like to backup your database, whether you'd like to Gzip compress your backups, and any tables you want to exclude from your backup.
One thing to note, to successfully create a backup of your database, it must first be created by Cloud 66.
Thanks for reading this far. Answers to all sorts of queries can be found on our Help pages, and there's more content like this on our Community site. And if you haven't already, make sure you join the Cloud 66 Slack community to get involved.
Published at DZone with permission of Siavash Khalvati , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.