Terraform provider with Tanzu Mission Control gives operations teams the ability to be infrastructure agnostic and build a code pipeline that accommodates a variety of infrastructure back ends. With Terraform, you can attach any conformant Kubernetes cluster to Tanzu Mission Control, therefore providing increased DevOps velocity by offering an additional route to consistent deployments and management of Kubernetes. In this post, I will explain the steps to create workload cluster using Terraform on vSphere with Tanzu.
Pre reqs
For this demo, I have registered management cluster (vSphere with Tanzu) to TMC.
Install terraform
Install steps are given here, you can follow the same based on bootstrap machine:
// Basic details needed to configure Tanzu Mission Control provider provider "tanzu-mission-control" { endpoint = "<org name>.tmc.cloud.vmware.com" // Required, provide the org name vmw_cloud_api_token = "<APi Token>" // Required, provide the API Token }
variable "SESSION_NAMESPACE" {}
endpoint and api token ref
Create file (create-cg.tf) with below content in directory terraform-demo
// Create cluster group resource "tanzu-mission-control_cluster_group" "create_cluster_group" { name = "${var.SESSION_NAMESPACE}-cg" }
Create file (tkgs-create-cluster.tf) with below content in directory terraform-demo
resource "tanzu-mission-control_cluster" "create_tkgs_workload" { management_cluster_name = "partnerse-demo-mgmt" // Required, change me provisioner_name = "partnerse-demo-tkgs" // Required, change me name = "${var.SESSION_NAMESPACE}-tf"