IBM Cloud Docs
Setting up continuous deployment with Schematics and DevOps toolchain

Setting up continuous deployment with Schematics and 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:

  1. If you do not have one, create an IBM Cloud Pay-As-You-Go or Subscription IBM Cloud account.

  2. Log in to your GitHub account.

  3. Open the Terraform template to create an IBM Cloud Object Storage.

  4. From the right 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.

  1. From the Schematics workspaces dashboard, click Create workspace.

  2. In Specify template section. Enter GitHub, GitLab, or Bitbucket Repository URL as

    https://github.com/IBM-Cloud/terraform-provider-ibm/blob/master/examples/ibm-cos-bucket
    
  3. For the private repository, provide your GitHub personal access token. See the steps to fetch the GitHub personal access token.

  4. Select terraform_v01.0 from the Terraform version drop-down.

  5. Click Next.

  6. In the workspace details section, enter your Workspace name, Tags, Resource group, Location, and Description.

    Ensure you provide the right resource group, and the location details where you want to create the workspace.

  7. 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.

Variables
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.

  1. On the variable page, click Enable continuous delivery link option to view Schematics Infrastructure as Code Tekton Toolchain page.

  2. Click Delivery Pipeline Required tab.

  3. Enter your IBM Cloud API key.

  4. Click Authorize > Authorize IBM-Cloud and enter your GitHub password to get authorized.

  5. Click Create to view Toolchains page.

  6. Click Deliver Pipeline pane to view Schematics-deploy Dashboard page.

  7. Click Run Pipeline

    Observe the UPDATE is in STAGE RUNNING state, without the click.

Analyzing the pipeline execution process

Observe the pipeline dashboard and view the status of your workspace execution.

  1. During the update stage process, from the example of ibm-cos-bucket repository observe the main.tf file configuration with the cos_instance name and bucket_name. These details are updated in the Schematics workspaces after the APPLY stage is passed.
  2. The UPDATE stage completes, PLAN stage is in running state.
  3. Click Jobs and history to view the status of the job from the PLAN pane.
  4. Observe that the PLAN stage is passed, and APPLY stage is in running state.
  5. From the Schematics workspaces, check that the resource name and bucket name are created successfully.
  6. Observe that the APPLY stage is passed and TEST stage is in Running state.
  7. Observe that the TEST stage is passed successfully.
  8. 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.

  1. From the Schematics workspaces dashboard.
  2. Select Navigation Menu > Schematics > Workspaces > Resources to observe the apply state of the resources in your workspace.
  3. 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.