Skip to content

Understanding the Template

Kevin Mack edited this page Aug 24, 2018 · 3 revisions

This page provides a description of the TerraForm template being leveraged to assist in making changes. This will provide a walk through of the various pieces of the template.

Deployment Script

Below are the files that are found at the top level of the template: tf-deploy.sh: This script encapsulates the necessary steps of initializing TerraForm and connecting to Microsoft azure. This script is invoked whenever you need to push updates.

Packer

This folder contains all required code to build the custom vm images required by leveraging packer. Inside you will find:

  • Scripts Folder: This folder contains the necessary scripts for configuring the kubernetes machines. These scripts are run either as Provisioners by Packer, or as part of a VM Extension when each VM is created.
  • Ubuntu Folder: This folder contains the json configuration files required to create the packer image.
    • sus1.json: This stands for Staging United States 1 deployment, and this json file contains configuration information for the azure deployment of the template.
    • ubuntu.json: This contains the necessary configuration information to create the custom image with packer, including the base image, and the provisioners to execute.

Azure

This folder contains all the required code to deploy the TerraForm template to Azure. This includes files that will configure the virtual network, the key vault, the different vm types, and resource groups leveraged.

This includes a variables.tf file, which contains the definition and description of the top level variables utilized by this template to configure the deployment.

Inside you will find:

  • Azure\Modules: This contains a custom module called "create_vm_linux" which contains the standardized code for each vm that is created. This script leverages parameters / variables to control how the vm is created and the custom image created by packer to create vm instances that match the specifications of the template. The "main.tf" contains the script for the creation of the vm, and the "variables.tf" contains the different variables / parameters that can be passed to it.
  • Azure\sus1: This folder contains the "Environment.tfvars" which contains all the configuration information for the deployment. This includes the subscription and naming convention values, but additionally it holds the number of each Virtual Machine Type, size of disks, static or dynamic ips, and Virtual Machine sizes. It also will contains the secrets.tfvars file that you need to create with important configuration information.

Virtual Machine Scripts

This template contains two types of machines:

  • lkma: The linux kubernetes master.
  • lkwn: The linux kubernetes worker node.

Each of these files contains the TerraForm script required to create all resources for that VM type which include.

  • Network Security Groups / Rules
  • Load Balancers / Rules / Pools
  • Module for Virtual Machine creation

At the bottom of each file is the values passed through to the create_vm_linux module that will create the vm. Of particular note is "vm_extensions_command" which has the code to build to execute to either configure the master or a worker node.