1. Prerequisite

This post is a continuation of the previous post on how to use NSX Advance LB (AVI Networks) for Openshift control-plane nodes. In this note, I’m going to create Terraform manifest for automating the creation of load balancer objects in AVI. The manifests can be altered or modified if necessary for another purpose. The objective is to create a framework for automating the creation of load balancer objects.

This is created with below software version:

  • Terraform v0.11.12
  • AVI v18.2.7

Below are the prerequisite:

Install unzip

sudo apt-get install wget unzip

Download respective version and extract the archive

export VER="0.11.12"
wget https://releases.hashicorp.com/terraform/${VER}/terraform_${VER}_linux_amd64.zip
unzip terraform_${VER}_linux_amd64.zip

Move file fo /usr/local/bin directory

sudo mv terraform /usr/local/bin/

2. AVI LB Service

In this post, I’m going to automate the creation of LB service objects for Openshift Master nodes load balancing:

  • Create a local load balancing service and pool for API Server (TCP 6443)
  • Create a local load balancing service and pool for Machineconfig (TCP 22623)
  • Create a local load balancing service and pool for HTTP (TCP 80)
  • Create a local load balancing service and pool for HTTPS (TCP 443)

The complete Terraform manifests can be found in my Github page

3. How to use

  • Edit the Variable files as necessary My lab variables are below:

    # AVI Controller Variables
    avi_controller        = ""
    avi_username          = "<username>"
    avi_password          = "<password>"
    avi_api_version       = "18.2.7"
    # Cloud Variables
    cloud_name            = "Default-Cloud"
    tenant_name           = "admin"
    # General Virtual Service Variables
    vs_subnet_ip          = ""
    vs_subnet_prefix      = "24"
    vs_placement_net      = "LabNet"
    # API Server VS Variables
    vs_api_server         = "Openshift-API-Server"
    vip_api_server        = ""
    api_server_pool_name  = "openshift-api-server-pool"
    master_pool_placement_net    = "LabNet"
    bootstrap_server      = ""
    master_server_1       = ""
    master_server_2       = ""
    master_server_3       = ""
    # Machine Config VS Variables
    vs_machineconfig         = "Openshift-MachineConfig"
    machineconfig_server_pool_name = "openshift-machineconfig-pool"
    # Infra Nodes HTTP VS Variables
    vs_http_server        = "Openshift-Apps-HTTP"
    vip_infra_server      = ""
    infra_nodes_pool_name = "openshift-apps-server-pool"
    infra_pool_placement_net = "LabNet"
    infra_server_1        = ""
    infra_server_2        = ""
    infra_server_3        = ""
    http_server_pool_name = "openshift-apps-http-pool"
    # Infra Nodes HTTPS VS Variables
    vs_https_server          = "Openshift-Apps-HTTPS"
    https_server_pool_name  = "openshift-apps-https-pool"
  • Run Terraform to initialize and provision the environment

    terraform init
    terraform plan
    terraform apply -auto-approve
    data.avi_healthmonitor.system_tcp: Refreshing state...
    data.avi_network.master_pool_placement_net: Refreshing state...
    data.avi_tenant.default_tenant: Refreshing state...
    data.avi_network.vs_placement_net: Refreshing state...
    data.avi_applicationprofile.system_l4: Refreshing state...
    data.avi_cloud.default_cloud: Refreshing state...
    data.avi_network.infra_pool_placement_net: Refreshing state...
    data.avi_networkprofile.system-tcp-proxy: Refreshing state...
    avi_vsvip.k8s_api_vsvip: Creating...
      cloud_ref:                                                           "" => ""
      east_west_placement:                                                 "" => "false"
    <output ommited>
    avi_virtualservice.https_server: Creation complete after 3s (ID:
    avi_virtualservice.machineconfig_server: Creation complete after 3s (ID:
    avi_virtualservice.api_server: Creation complete after 4s (ID:
    avi_virtualservice.http_server: Creation complete after 4s (ID:
    Apply complete! Resources: 10 added, 0 changed, 0 destroyed.
  • Verification