Deploy a MySQL instance with App Lifecycle Manager
Learn how to deploy a Cloud SQL instance using App Lifecycle Manager.
Before you begin
-
Sign in to your Google Account.
If you don't already have one, sign up for a new account.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
Enable the App Lifecycle Manager, Artifact Registry, Infrastructure Manager, Developer Connect, Cloud Build, and Cloud Storage APIs.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles.-
Create a service account:
-
Ensure that you have the Create Service Accounts IAM role
(
roles/iam.serviceAccountCreator) and the Project IAM Admin role (roles/resourcemanager.projectIamAdmin). Learn how to grant roles. -
In the Google Cloud console, go to the Create service account page.
Go to Create service account - Select your project.
-
In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.
In the Service account description field, enter a description. For example,
Service account for quickstart. - Click Create and continue.
-
Grant the Project > Owner role to the service account.
To grant the role, find the Select a role list, then select Project > Owner.
- Click Continue.
-
Click Done to finish creating the service account.
-
Ensure that you have the Create Service Accounts IAM role
(
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init -
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
Enable the App Lifecycle Manager, Artifact Registry, Infrastructure Manager, Developer Connect, Cloud Build, and Cloud Storage APIs.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles.-
Create a service account:
-
Ensure that you have the Create Service Accounts IAM role
(
roles/iam.serviceAccountCreator) and the Project IAM Admin role (roles/resourcemanager.projectIamAdmin). Learn how to grant roles. -
In the Google Cloud console, go to the Create service account page.
Go to Create service account - Select your project.
-
In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.
In the Service account description field, enter a description. For example,
Service account for quickstart. - Click Create and continue.
-
Grant the Project > Owner role to the service account.
To grant the role, find the Select a role list, then select Project > Owner.
- Click Continue.
-
Click Done to finish creating the service account.
-
Ensure that you have the Create Service Accounts IAM role
(
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init - Grant the App Lifecycle Manager
service account the required permissions:
Navigate to App Lifecycle Manager > Overview Get started.
- In the banner with the message The required permissions for App Lifecycle Manager account haven't been granted, click Grant permissions.
Model your Cloud SQL offering using a composite template
In this section, you'll use App Lifecycle Manager to model a composite template
(sql-quickstart-template) consisting of a Cloud SQL instance using
Application Design Center.
In Google Cloud console, go to App Lifecycle Manager > SaaS Offering.
Click Create.
In the Name of the SaaS offering field, type:
my-sql-quickstart-saas-offering.In the Region drop-down, select the regions:
us-central1us-east1us-east5
Click Ok.
Click Create. It may take a few minutes to create
my-sql-quickstart-saas-offering.The SaaS offering details page opens.
On the SaaS offering details page, click Create new template.
On the Create a new composite template page:
- In the Template ID box, enter
sql-quickstart-template. Click Create template. App Lifecycle Manager will take a few minutes to create the composite template.
When App Lifecycle Manager has created the template successfully, you'll see its details in the Connected application template section of the SaaS offering details page.
- In the Template ID box, enter
In the Connected application template section, go to Manage template > Configure in canvas.
App Design Center opens in the Google Cloud console window.
In the Components area, find and click the Cloud SQL (My SQL) template.
A Cloud SQL (My SQL) component is added to the canvas.
Click Continue > Deploy at scale with App Lifecycle Manager.
App Lifecycle Manager opens in the Google Cloud console window.
In the Connected application template section, click Update template revision.
On the Update template revision page, select
r-2in the Revision drop-down.Click Update. The Connected application template section displays Importing Application Template.
It may take a few minutes for App Lifecycle Manager to import the template revision. When the revision has finished importing, you'll see the list of unit kinds populated in the Unit kinds tab.
Provision a Cloud SQL instance using App Lifecycle Manager
In this section, you'll create and provision a unit (my-sql-quickstart-unit)
with a Cloud SQL instance in the us-central1 region.
On the SaaS offering details page of
my-sql-quickstart-saas-offering, click Provision.A Provision page opens.
On the Provision page, select
us-central1in the Region drop-down.Click Add to add a unit to your SaaS offering.
On the Add unit to provision panel:
- In the Unit name box, type
my-sql-quickstart-unit-1. - In the Unit kind drop-down, select the
sql-quickstart-templateunit kind. - In the Release drop-down, select (
r-3). - In the Service account drop-down, select the service account you created in the Before you begin section.
- In the Unit name box, type
Click Add tenant project variables.
- Select your project to provision your resources.
In the Other input variables section of the Add unit to provision panel:
Click the
sql-my-sql-1_database_versiondrop-down.- In the Variable value box, type
MY_SQL_8_0.
Click Done.
- In the Variable value box, type
Click the
sql-my-sql-1_namedrop-down.- In the Variable value box, type
my-sql-db-1.
Click Done.
- In the Variable value box, type
Click the
sql-my-sql-1_project_iddrop-down.- In the Variable value box, type your project ID.
Click Done.
Click the
sql-my-sql-1_regiondrop-down.- In the Variable value box, type
us-central1.
Click Done.
- In the Variable value box, type
Click Add. You'll see
my-sql-quickstart-unit-1in the Units to be provisioned table.Click Provision to provision the
my-sql-quickstart-unit-1which will create a live Cloud SQL instance in your SaaS offering.It may take a few minutes for App Lifecycle Manager to provision
my-sql-quickstart-unit-1.
View the deployed Cloud SQL instance
You have now used App Lifecycle Manager to deploy a Cloud SQL instance.
To view the Cloud SQL instance that you deployed in this quickstart:
In Google Cloud console, go to the App Lifecycle Manager > Units > Unit details page.
Click the name of your unit:
my-sql-quickstart-unit-1.On the Unit details page:
See that the State is:
- Ready if the Cloud SQL instance is provisioned.
- Provisioning if the operation is still in progress.
Clean up
To avoid incurring charges to your Google Cloud account for the resources used on this page, follow these steps.
Delete the project
If you deployed the Cloud SQL instance in a new Google Cloud project, and if you no longer need the project, then delete it by completing the following steps:
- In the Google Cloud console, go to the Manage resources page.
- In the project list, select the project that you want to delete, and then click Delete.
- At the prompt, type the project ID, and then click Shut down.
What's next
- To understand more about App Lifecycle Manager, see App Lifecycle Manager overview.
- To get started with App Lifecycle Manager, begin with Create a SaaS offering.
- To understand how service accounts are used and how to grant the required permissions for these accounts, see App Lifecycle Manager service accounts.
- For the steps to update the release, see Rollout a release.