This tutorial explains how to automate the deployment of a Red Hat® OpenShift® cluster within your IBM Cloud® account by using IBM Cloud Schematics.
Red Hat OpenShift on IBM Cloud is a fully managed OpenShift service that can increase your productivity by autoscaling your cluster. It also provides total control over worker node provisioning and flexibility, so you no longer worry about over- and under-provisioning your apps.
IBM Cloud Schematics is a managed Terraform solution, which delivers Terraform-as-a-Service so that you can use a high-level scripting language to model the resources that you want in your IBM Cloud environment and enable Infrastructure as Code (IaC).
Prerequisites
Before starting with IBM Cloud Schematics, note the following prerequisites:
- An IBM Cloud account and sufficient permissions to create an OpenShift cluster within your account.
- The creation of an OpenShift cluster requires public and private virtual LANs.
- A GitHub account.
Estimated time
Completing this tutorial should take you about 8 minutes.
Steps
- Step 1. Codify OpenShift on IBM Cloud
- Step 2. Create a workspace in IBM Cloud Schematics
- Step 3. Create an execution plan
- Step 4. Deploy your OpenShift cluster to IBM Cloud
Step 1. Codify OpenShift on IBM Cloud
In this step, you will use the Terraform HashiCorp Configuration Language (HCL) format to specify the IBM Cloud resources that you want to provision in your IBM Cloud environment. With the following Terraform configuration, you are able to create an OpenShift cluster with a default worker_pool
of size 1 (default_pool_size
), in the zone ams03
, and in region eu-de
.
Create a
provider.tf
file in your GitHub repository with the following provider configuration:variable "ibmcloud_api_key" { description = "Enter your IBM Cloud API, you can get your IBM Cloud API key using: https://cloud.ibm.com/iam#/apikeys" } provider "ibm" { ibmcloud_api_key = var.ibm.cloud_api_key }
Note: Learn more about the configuration file in the IBM Cloud Provider documentation.
Create a file called
main.tf
in your GitHub repository with the following configuration for your OpenShift cluster:resource "ibm_container_cluster" "cluster" { name = "${var.cluster_name}${random_id.name.hex}" datacenter = var.datacenter default_pool_size = 3 machine_type = var.machine_type hardware = var.hardware kube_version = var.kube_version public_vlan_id = var.public_vlan_id private_vlan_id = var.private_vlan_id }
This GitHub repo explains the template configuration which deploys the OpenShift cluster.
Step 2. Create a workspace in IBM Cloud Schematics
Follow the detailed steps for setting up your workspace in the IBM Cloud Schematics product documentation.
On the workspace Settings page, enter the URL for your GitHub repository.
Update the variables under the Variable section as follows:
datacenter
The datacenter where you want to provision the worker nodes. The zone that you choose must be supported in the region where you want to create the cluster. To find supported zones, run theibmcloud ks zones
command. Default iswdc04
.machine_type
The machine type for your worker node. The machine type determines the amount of memory, CPU, and disk space that is available to the worker node. Default isb3c.4x16
.hardware
The level of hardware isolation for your worker node. Usededicated
to have available physical resources dedicated to you only, orshared
to allow physical resources to be shared with other IBM customers. This option is available for virtual machine worker node flavors only. Default isshared
.public_vlan_id
The ID of the public VLAN that you want to use for your worker nodes. You can retrieve the VLAN ID with theibmcloud ks vlans --zone <zone>
command.private_vlan_id
The ID of the private VLAN that you want to use for your worker nodes. You can retrieve the VLAN ID with theibmcloud ks vlans --zone <zone>
command.cluster_name
The name of the cluster. The name must start with a letter and can contain letters, numbers, and hyphens (-). It also must be 35 characters or fewer. Use a name that is unique across regions. The cluster name and the region in which the cluster is deployed form the fully qualified domain name for the Ingress subdomain. To ensure that the Ingress subdomain is unique within a region, the cluster name might be truncated and appended with a random value within the Ingress domain name. Default isiks_openshift
.kube_version
The Kubernetes or OpenShift version that you want to set up in your cluster. For OpenShift clusters, you can specifyversion 3.11_openshift
or4.3.1_openshift
. Default is4.3_openshift
.
Step 3. Create an execution plan
- Review the variables under Settings and click Generate plan to create the execution plan.
Click on View log to review the execution plan log. The following screen capture shows an example plan.
Step 4. Deploy your OpenShift cluster to IBM Cloud
- After you review the plan, apply it by clicking Apply plan. This will deploy your OpenShift cluster on IBM Cloud.
- After the activity is completed, you can view the logs by clicking View log.
Summary
I hope this tutorial was helpful for you to learn how to automate the deployment of an OpenShift cluster on IBM Cloud. IBM Cloud Schematics is a powerful way for you to automate infrastructure deployment. With it, you can organize your IBM Cloud resources across environments by using workspaces.
You can go to the OperatorHub in your OpenShift 4.3 cluster to discover other services that are available to install in your cluster. You can also find certified software on the Red Hat Marketplace. Or you can go to OperatorHub.io for a larger list of operators that you can install manually.
Next steps
Use the open source code and instructions in the following articles and video to further understand how to deploy infrastructure with IBM Cloud Schematics: