Azure 上使用 Universal 安装工具的多分域 DC/OS

Azure 上 DC/OS 使用 Universal 安装工具添加远程分域的指南。

This guide expects that you already have a running DC/OS cluster based on Universal Installer . To learn more about running DC/OS with the Universal Installer have a look into the Guide for DC/OS on Azure using the Universal Installer.

You will learn how to place additional infrastructure into an Azure remote region. Remote regions will be connected to each other by using the peering functionality of Azure VNETs.

Prerequisites

  • A running DC/OS Enterprise cluster set up with Universal Installer 0.2 modules
  • A subnet range for your remote region

Getting started with remote region

We expect your already running DC/OS clusters main.tf will look similar to this example. To deploy a remote region we have to do some changes to your main.tf

To create the remote region and its infrastructure we will use the same underlying modules as in our master region. This also means there will be some information needed for both infrastructures like cluster_name, admin_ips and ssh_public_key_file. To make the operation easier you should define local variables in your main.tf that will be used in every module.

  1. #...
  2. // lets define variables which are shared between all regions
  3. locals {
  4. ssh_public_key_file = "~/.ssh/id_rsa.pub"
  5. cluster_name = "my-dcos-demo"
  6. admin_ips = ["${data.http.whatismyip.body}/32"]
  7. }
  8. #...

Part of the shared information is which internal subnets are used in your infrastructure. If you did not specify subnet_range, terraform uses the default which is 172.12.0.0/16. The remote region we want to specify needs its own subnet.

IMPORTANT: You should not take 172.17.0.0/16, it is dockers internal network default which will lead to problems.

To have a clear separation between our master and our remote regions we will take 10.128.0.0/16 as our remote regions subnet. Also, we will use a to assign the networks to regions. This will make it easier when adding additional regions in the future.

The locals section will now look like this

Before we start changing values within the dcos module we will append the infrastructure definition of the remote region to your main.tf. In our example case we only want to have private agents in our remote region, and both private and public agents can be put in a remote region.

To only start private agents we will set num_bootstrap = 0, num_masters = 0 and num_public_agents = 0.

Another important topic to mention is naming. To distinguish between instances of your main and your remote region we introduced the name_prefix variable which allows you to add a prefix to the name of every resource. In this example we set the name_prefix to the short name of the remote region.

In the following example you will also find the shared config options being used in the module call referenced by e.g. local.ssh_public_key_file.

  1. #...
  2. module "dcos-wus2" {
  3. source = "dcos-terraform/infrastructure/azurerm"
  4. azure = "azure"
  5. }
  6. location = "West US 2"
  7. avset_platform_fault_domain_count = 2
  8. subnet_range = "${local.region_networks["West US 2"]}"
  9. admin_ips = ["${local.admin_ips}"]
  10. name_prefix = "wus2"
  11. cluster_name = "${local.cluster_name}"
  12. num_bootstrap = 0
  13. num_masters = 0
  14. num_private_agents = 1
  15. num_public_agents = 0
  16. ssh_public_key_file = "${local.ssh_public_key_file}"
  17. }

We now need to establish a connection between the two infrastructures. The Universal Installer provides a module for this task. In this module we reference data from both infrastructures the main region holding DC/OS masters and the remote region holding your remote private agents.

The only information this module needs to receive is the output of our dcos and dcos-wus2 modules. We will append this module to the end of your main.tf

Here is the example vnet-peering-section

At this point its time to do changes to your dcos module so it knows about the remote region and is able to install the remote agents.

  1. Choose a subnet range. In general this change is not needed but we wanted to make your example pretty specific.

    subnet_range = "${local.region_networks["master"]}"

  2. cluster_name = "${local.cluster_name}"

  3. List the SSH key. This is also a shared resource and we can make use of the local variable

    ssh_public_key_file = "${local.ssh_public_key_file}"

  4. Add the admin IPs following the same pattern.

    admin_ips = ["${local.admin_ips}"]

  5. Add the private agents. This nearly the most important new variable. This tells the DC/OS installation module which other agents need to be installed.

    additional_private_agent_ips = ["${module.dcos-wus2.private_agents.private_ips}"]

Example dcos module

After the changes above got applied your dcos module should look like this

  1. module "dcos" {
  2. version = "~> 0.2.0"
  3. azure = "azure"
  4. }
  5. location = "West US"
  6. avset_platform_fault_domain_count = 3
  7. subnet_range = "${local.region_networks["master"]}"
  8. cluster_name = "${local.cluster_name}"
  9. ssh_public_key_file = "${local.ssh_public_key_file}"
  10. admin_ips = ["${local.admin_ips}"]
  11. num_masters = 3
  12. num_private_agents = 2
  13. num_public_agents = 1
  14. dcos_version = "1.13.3"
  15. dcos_variant = "ee"
  16. dcos_license_key_contents = "${file("./license.txt")}"
  17. # Make sure to set your credentials if you do not want the default EE
  18. # dcos_superuser_username = "superuser-name"
  19. # dcos_superuser_password_hash = "${file("./dcos_superuser_password_hash.sha512")}"
  20. dcos_instance_os = "centos_7.6"
  21. additional_private_agent_ips = ["${module.dcos-wus2.private_agents.private_ips}"]
  22. }

Full main.tf example

Here is the complete main.tf you should see once you completed this guide.