SkillAgentSearch skills...

Terraform Icp Vmware

Terraform recipe to deploy IBM Cloud Private on VMware

Install / Use

npx skills add hassenius/terraform-icp-vmware

Installs into whichever agent you are using.

About this skill

Quality Score

0/100

Category

Operations

Supported Platforms

Universal

README

Terraform ICP VMware HA

This Terraform example configurations uses the VMware vSphere provider to provision virtual machines on VMware and TerraForm Module ICP Deploy to prepare VMs and deploy IBM Cloud Private on them. This Terraform template automates best practices learned from installing ICP on VMware at numerous client sites in production.

This template provisions an HA cluster with ICP 3.1 enterprise edition.

Pre-requisites

  • Working copy of Terraform
  • The example assumes the VMs are provisioned from a template that has ssh public keys loaded in ${HOME}/.ssh/authorized_keys. After VM creation, terraform will SSH into the VM to prepare and start installation of ICP using the SSH private key provided. If your VM template uses a different user from root, update the ssh_user section in variables.tf
  • The template is tested on VM templates based on Ubuntu 16.04

VM Template image preparation

  1. Create a VM image (RHEL or Ubuntu 16.04).

    • The automation will create an additional block device at unit number 1 (i.e. /dev/sdb) for local docker container images and attempt to configure Docker in direct-lvm or overlay2 mode, depending on your operating system. RHEL 7.4 and older will default to devicemapper, RHEL 7.5 and newer will default to Overlay2. All supported Ubuntu versions will default to Overlay2. Additional block devices are also mounted at various directories that hold ICP data depending on the node role. You may pre-install docker, but it must be configured in direct-lvm or overlay2 mode. For direct-lvm the block device must be set as the second disk. The simplest way of getting this to work is to create a template with a single OS disk without installing docker and let the automation configure direct-lvm or overlay2 mode as appropriate.
  2. Ensure that the ssh_user can call sudo without password.

  3. Install any other needed packages:

    1. Shared storage clients, e.g. if the shared storage is NFS for the registry and audit directories, install NFS clients.
    2. In environments with restricted outbound internet, the terraform automation requires and attempts to install PyYAML. You can pre-install it into the template:
      • yum install PyYAML on RHEL
      • apt install python-yaml on Ubuntu
    3. Install VMware Tools or open-vm-tools
    4. For docker installation, install any additional pre-requisites:
      • yum install device-mapper libseccomp libtool-ltdl libcgroup iptables on RHEL
      • apt install libtdl7 thin-provisioning-tools lvm2 on Ubuntu
    5. For RHEL templates, VMware guest customization requires perl.
    6. For RHEL templates, either disable the firewall (systemctl disable firewalld), or add firewall_enabled: true to icp-config.yaml.
  4. (optional) If you are not providing image_location, and have pre-installed docker, you can also pre-load the docker images from the ICP package you wish to install.

    tar xf ibm-cloud-private-x86_64-3.1.tar.gz -O | sudo docker load
    
  5. Shutdown the VM Convert to a template, make note the name of the template.

Other environment preparation

The automation requires an HTTP or NFS server to hold the ICP binaries and docker packages. NFS storage is recommended as it can host these binaries and also the shared storage location for registry_mount_src, audit_mount_src, docker_package_location and image_location.

Using the Terraform templates

  1. git clone or download the templates

  2. Export your vSphere username and password into environment variables on the system you will run Terraform from. This can be done via the following commands:

    • export VSPHERE_USER={myusername} replacing {myusername} with your vSphere username
    • export VSPHERE_PASSWORD={mypassword} replacing {mypassword} with your vSphere password
  3. Create a terraform.tfvars file to reflect your environment. Please see variables.tf and below tables for variable names and descriptions. Here is an example terraform.tfvars file:

    #######################################
    ##### vSphere Access Credentials ######
    #######################################
    vsphere_server = "10.25.0.20"
    
    # Set username/password as environment variables VSPHERE_USER and VSPHERE_PASSWORD
    
    ##############################################
    ##### vSphere deployment specifications ######
    ##############################################
    # Following resources must exist in vSphere
    vsphere_datacenter = "DC1"
    vsphere_cluster = "Cluster1"
    vsphere_resource_pool = "ICP31_pool/terraform_icp_31"
    network_label = "LabPrivate"
    datastore = "LabDatastore"
    template = "ubuntu_1604_base_template"
    # Folder to provision the new VMs in, does not need to exist in vSphere
    folder = "terraform_icp_31"
    
    ##################################
    ##### ICP deployment details #####
    ##################################
    
    ##### ICP instance name #####
    # MUST consist of only lower case alphanumeric characters and '-'
    instance_name = "user1-icp-31"
    
    
    ##### Network #####
    staticipblock = "10.30.0.0/24"
    staticipblock_offset = 2
    gateway = "10.0.0.1"
    netmask = "16"
    dns_servers = [ "10.0.0.11", "10.0.0.12" ]
    
    # Cluster access
    cluster_vip = "10.30.0.1"
    cluster_vip_iface = "ens160"
    proxy_vip = "10.0.0.2"
    proxy_vip_iface = "ens160"
    
    ##### Local Terraform connectivity details #####
    ssh_user = "virtuser"
    ssh_password = "SuperPa88w0rd"
    
    ##### ICP installation method #####
    icp_inception_image = "ibmcom/icp-inception:3.1.0-ee"
    private_registry    = "registry.example.com"
    registry_username   = "myUsername"
    registry_password   = "myPassword"
    
    ##### ICP admin user password #####
    # Non default admin user password 'admin' recommended
    icppassword = "SuperPa88w0rd"
    
    ##### ICP Cluster Components #####
    master = {
        nodes = "3"
        vcpu = "8"
        memory = "16384"
        docker_disk_size = "250"
        thin_provisioned = "true"
    }
    proxy = {
        nodes = "3"
        vcpu = "4"
        memory = "8192"
        thin_provisioned = "true"
    }
    worker = {
        nodes = "3"
        vcpu = "8"
        memory = "8192"
        thin_provisioned = "true"
    }
    management = {
        nodes = "3"
        vcpu = "4"
        memory = "16384"
        thin_provisioned = "true"
    }
    va = {
        nodes = "2"
        vcpu = "4"
        memory = "8192"
        thin_provisioned = "true"
    }
    
    ##### NFS Server #####
    registry_mount_src = "10.0.0.5:/storage/user1-icp-31/registry"
    audit_mount_src = "10.0.0.5:/storage/user1-icp-31/audit"
    
  4. Run terraform init to download dependencies (modules and plugins)

  5. Run terraform plan to investigate deployment plan

  6. Run terraform apply to start deployment

ICP installation method

Below you can find the different paths to install ICP on VMware.

  1. Install from ICP binary package. In order to install ICP from it's binary package, we need to specify the image_location of the binary in the terraform.tfvars file:
##### ICP installation method #####
icp_inception_image = "ibmcom/icp-inception:3.1.0-ee"
image_location = "nfs:<nfs_server_ip_address>:<path_within_your_nfs_server>/ibm-cloud-private-x86_64-3.1.0.tar.gz"
  1. Install from a private Docker registry which does not require authentication. In order to install ICP from a previously configured (with ICP images loaded into) private Docker registry which does not require authentication, we need to specify the private_registry in the terraform.tfvars file:
##### ICP installation method #####
icp_inception_image = "ibmcom/icp-inception:3.1.0-ee"
private_registry    = "registry.example.com"
  1. Install from a private Docker registry which requires authentication. In order to install ICP from a previously configured (with ICP images loaded into) private Docker registry which requires authentication, we need to specify the private_registry and its credentials, registry_username and registry_password, in the terraform.tfvars file:
##### ICP installation method #####
icp_inception_image = "ibmcom/icp-inception:3.1.0-ee"
private_registry    = "registry.example.com"
registry_username   = "myUsername"
registry_password   = "myPassword"

Terraform configuration

vSphere variables

| name | required | value | |----------------|------------|--------------| | vsphere_server | yes | IP or hostname of vSphere server | | vsphere_user | no, moved to environment variables | Username for vSphere server | | vsphere_password | no, moved to environment variables | Password for vSphere user | | allow_unverified_ssl | no | SSL certificate verification when connecting to vSphere, true by default. | | vsphere_datacenter | yes | Name of the vSphere datacenter to deploy VMs to | | vsphere_cluster | yes | Name of the vSphere cluster to deploy VMs to (must be under the vSphere datacenter) | | vsphere_resource_pool | no | Path of the Resource Pool to deploy VMs to (must be under the vSphere cluster), will be in the format like /path/to/target, by default will add VMs to root resource pool in the cluster | | network_label | yes | Network label to place all VMs on | | datastore | yes | Name of the datastore to place all disk images in. | | folder | no | Name of the VM folder to create where all created VMs are placed in, if not supplied, will place in root folder. | | template | yes | Name of the VM template to use to c

Related Skills

View on GitHub
GitHub Stars6
CategoryOperations
Updated2y ago
Forks19

Languages

HCL

Security Score

55/100

Audited on Mar 12, 2024

No findings