Setting up continuous deployment with Schematics and a DevOps toolchain
Description
In this tutorial, you can learn to use your credentials and an API key to use a Terraform template of IBM Cloud® Object Storage in the Schematics workspace. Then, you also learn to automate the continuous deployment by using DevOps delivery
pipeline. As part of the tutorial, you use ibm_cos_bucket
Terraform template example.
The ibm_cos_bucket
example creates an instance of IBM Cloud Object Storage, IBM Cloud® Activity Tracker, and IBM Cloud® Monitoring.
Costs are incurred based on your resource usage. For more information about the pricing, see Pricing. About the support and help, see Schematics help.
Objectives
In this tutorial, you can:
- Explore an IBM provided Terraform template to create an IBM Cloud Object Storage instance that binds with the IBM resource instance, and IBM resource group.
- Learn how to create an IBM Cloud Schematics workspace.
- Learn to automate continuous deployment of a resource by using IBM Cloud Schematics and DevOps toolchain.
- Review the IBM Cloud resources that you create.
Time needed
1 hour
Audience
This tutorial is intended for the developer and system administrators who want to learn how to use Terraform templates to create. And automate the continuous deployment of resource by using IBM Cloud Schematics and DevOps toolchain.
Prerequisites
About IBM Cloud Schematics
IBM Cloud Schematics is an IBM Cloud automation tool. It provides simplified provisioning, orchestrating Infrastructure as Code (IaC), templates, and managing IBM Cloud resources in your IBM Cloud environment by using various resources tools such as Terraform, Helm. IaC helps you codify your cloud environment to automate the provisioning, speeds deployment, and managing your resources. The infrastructure is treated the same way as your app code, so that you can automate the DevOps core practices such as version control, testing, continuous integration, and deployment.
About DevOps toolchain
A DevOps toolchain is a set of tools that automates the tasks of developing and deploying your app. A toolchain is a set of tool integrations that support development, deployment, and operations tasks. The collective power of a toolchain is greater than the sum of its individual tool integrations.
For the information, see DevOps toolchain. The Schematics option enables the continuous delivery of your infrastructure configurations as well with IBM Cloud toolchain.
Complete the following prerequisites for the tutorial:
- If you do not have IBM Cloud account, create an IBM Cloud account, and pay as you use. For more information about managing IBM Cloud account, see Managing IBM Cloud account.
- Install the IBM Cloud CLI and the Schematics CLI plug-in. For more information about command-line setup, see Schematics command-line setup.
- Ensure you are assigned the needed permissions in IBM Cloud® Identity and Access Management to create and work with IBM Cloud Schematics workspace. see Schematics access and to create an IBM Cloud Object Storage service instance.
- Follow the instructions to ensure you are assigned the needed permissions in Cloud Identity and Access Management to create resources. For more information about create IBM Cloud Object Storage, see IBM Cloud Object Storage.
Accessing the IBM Cloud and GitHub
Complete these steps to access the IBM Cloud and the Terraform templates from the GitHub:
-
If you do not have one, create an IBM Cloud Pay-As-You-Go or Subscription IBM Cloud account.
-
Log in to your GitHub account.
-
Open the Terraform template to create an IBM Cloud Object Storage.
-
From the side of the GitHub page, click
Fork
icon to create your own fork of the shared repository.You need to copy the URL of the Terraform template of the GitHub or the GitLab Repository URL to create your Schematics workspace.
Creating your IBM Cloud Schematics workspace
Complete these steps to create the IBM Cloud Schematics and the Terraform template URL.
-
From the Schematics workspaces dashboard, click Create workspace.
-
In Specify template section. Enter
GitHub, GitLab, or Bitbucket Repository URL
ashttps://github.com/IBM-Cloud/terraform-provider-ibm/blob/master/examples/ibm-cos-bucket
-
For the private repository, provide your GitHub personal access token. You can click the
Open reference picker
to select a your Secrets Manager key reference. For more information, see creating a Secrets Manager instance. See the steps to fetch the GitHub personal access token. -
Select
terraform_v1.4
from the Terraform version drop-down. -
Click Next.
-
In the workspace details section, enter your Workspace name, Tags, Resource group, Location, and Description.
Ensure you provide the resource group, and the location details where you want to create the workspace.
-
Click Next and then click Create to create Schematics workspaces successfully.
Configuring variables
Click ...
to configure the variables as described in the table to authenticate your credentials and save the changes.
Name | Value |
---|---|
iaas_classic_username |
Enter the username to access IBM Cloud classic infrastructure. |
iaas_classic_api_key |
Enter the API key to access IBM Cloud classic infrastructure. For more information, see Classic infrastructure API keys. |
ibmcloud_api_key |
Enter your IBM Cloud API Key, for more information, see IBM Cloud API key. |
resource_group_name |
Keep as default. |
Automating the continuous deployment process
The Enable continuous delivery
option automates the different Terraform actions to the Schematics workspace. Complete these steps to observe the automation of the end to end Schematics workspaces deployment.
The GitHub Server type parameter expects the authorization. You need to provide GitHub credentials and confirm the authorization.
-
On the variable page, click
Enable continuous delivery
link option to view Schematics Infrastructure as Code Tekton Toolchain page. -
Click
Delivery Pipeline Required
tab. -
Enter your
IBM Cloud API key
. -
Click Authorize > Authorize IBM-Cloud and enter your GitHub password to get authorized.
-
Click
Create
to view Toolchains page. -
Click
Deliver Pipeline
pane to view Schematics-deploy Dashboard page. -
Click Run Pipeline
Observe the
UPDATE
is inSTAGE RUNNING
state, without the click.
Analyzing the pipeline execution process
Observe the pipeline dashboard and view the status of your workspace execution.
- During the update stage process, from the example of
ibm-cos-bucket
repository observe themain.tf
file configuration with thecos_instance
name andbucket_name
. These details are updated in the Schematics workspaces after the APPLY stage is passed. - The
UPDATE
stage completes, PLAN stage is in running state. - Click Jobs and history to view the status of the job from the
PLAN
pane. - Observe that the PLAN stage is passed, and APPLY stage is in running state.
- From the Schematics workspaces, check that the resource name and bucket name are created successfully.
- Observe that the
APPLY
stage is passed and TEST stage is inRunning
state. - Observe that the
TEST
stage is passed successfully. - Now, you can edit your template in the configured repository and observe an automatic pull of your workspace by the continuous delivery toolchain.
Analyzing the Schematics workspace
Alternatively, through the IBM Cloud dashboard, you can view the status of the workspace.
- From the Schematics workspaces dashboard.
- Select
Navigation Menu > Schematics > Workspaces > Resources
to observe the apply state of the resources in your workspace. - You can view the output from your working directory, or from the IBM Cloud dashboard plan logs to view the workspace status.
You successfully created the Schematics workspaces and automated the end to end deployment by using the DevOps toolchain.
What's next?
You can now learn how to set up a continuous delivery pipeline for an IBM cluster. For more information, see Setting up a continuous delivery pipeline for an IBM cluster.