This repository contains the source code and Packer configuration files to create an image, for either Hyper-V or Azure, that contains an instance of the Fabio load balancer.
This repository contains the source code necessary to build Ubuntu Hyper-V hard-drives containing the
Fabio reverse proxy.
The resulting hard-drive is used to create Hyper-V virtual machines which act as a reverse proxy
which allows the users to access the different services in a given environment
without having to know the individual addresses of these services. The Fabio reverse proxy will
automatically detect the different instances and handle the proxying of the HTTP calls. Each
environment can have one or more instances at known IP addresses so that a DNS name can be
pointed to the machines.
The image is created by using the Linux base image
and amending it using a Chef cookbook which installs Fabio.
There are two different images that can be created. One for use on a Hyper-V server and one for use
in Azure. Which image is created depends on the build command line used.
In addition to the default applications installed in the template image the following items are
also installed and configured:
The image is configured to add Fabio as a service to the Consul services list with under the
proxy
service name.
The configuration for the Fabio instance comes from a
Consul-Template template file which replaces some
of the template parameters with values from the Consul Key-Value store.
Important parts of the configuration file are
No additional configuration is applied other than the default one for the base image.
No additional configuration is applied other than the default one for the base image.
Metrics are collected by Fabio sending StatsD
metrics to Telegraf.
The build process follows the standard procedure for
building Calvinverse images.
For building Hyper-V images use the following command line
msbuild entrypoint.msbuild /t:build /P:ShouldCreateHypervImage=true /P:RepositoryArchive=PATH_TO_ARTIFACTLOCATION
where PATH_TO_ARTIFACTLOCATION
is the full path to the directory where the base image artifact
file is stored.
In order to run the smoke tests on the generated image run the following command line
msbuild entrypoint.msbuild /t:test /P:ShouldCreateHypervImage=true
For building Azure images use the following command line
msbuild entrypoint.msbuild /t:build
/P:ShouldCreateAzureImage=true
/P:AzureLocation=LOCATION
/P:AzureClientId=CLIENT_ID
/P:AzureClientCertPath=CLIENT_CERT_PATH
/P:AzureSubscriptionId=SUBSCRIPTION_ID
/P:AzureImageResourceGroup=IMAGE_RESOURCE_GROUP
where:
LOCATION
- The azure data center in which the image should be created. Note that this needs to be the sameCLIENT_ID
- The client ID of the user that Packer will use toCLIENT_CERT_PATH
- The client certificate which Packer will use to authenticate with AzureSUBSCRIPTION_ID
- The subscription ID in which the image should be created.IMAGE_RESOURCE_GROUP
- The resource group from which the base image will be pulled and in which the new imageFor running the smoke tests on the Azure image
msbuild entrypoint.msbuild /t:test
/P:ShouldCreateAzureImage=true
/P:AzureLocation=LOCATION
/P:AzureClientId=CLIENT_ID
/P:AzureClientCertPath=CLIENT_CERT_PATH
/P:AzureSubscriptionId=SUBSCRIPTION_ID
/P:AzureImageResourceGroup=IMAGE_RESOURCE_GROUP
/P:AzureTestImageResourceGroup=TEST_RESOURCE_GROUP
where all the arguments are similar to the build arguments and TEST_RESOURCE_GROUP
points to an Azure resource
group in which the test images are placed. Note that this resource group needs to be cleaned out after successful
tests have been run because Packer will in that case create a new image.
Linux Consul Client
imageconsul leave
commandsudo shutdown now
commandThe easiest way to deploy the Azure images into a cluster on Azure is to use the terraform scripts
provided by the Azure ingress
repository. Those scripts will create a proxy cluster of the suitable size.