DC/OS on GCP using the Universal Installer

Guide for DC/OS on GCP using the Universal Installer

You can use the Universal Installer to create DC/OS clusters on the Google Cloud Platform (GCP) for an evaluation or production deployment. The Universal Installer on GCP installation method is officially supported by Mesosphere. Upgrades are also supported using this installation method.

If you are new to Terraform and want to deploy DC/OS on GCP with minimal configuration or customization, the following tasks summarize the basic installation process:

Create an Open Source DC/OS Cluster on GCP.

Scale the cluster to increase the number of nodes deployed.

Upgrade the cluster to use a newer version of DC/OS.

Destroy the cluster and all GCP resources associated with it.

Prerequisites

Terraform

Cloud credentials

SSH keys

Install using Terraform

Run the following command if you are on a Mac environment with homebrew installed:

brew install terraform

Run the following command to verify the output is consistent with the version of Terraform you have installed:

Set the GCP default region and project

The GCP provider requires you to export the Region (desired-gcp-region) and Project (desired-gcp-project) identifiers into environment variables even if those values are set in gcloud-cli. For example:

You can verify the region and project settings by running the following commands:

> echo $GOOGLE_REGION
us-west1
> echo $GOOGLE_PROJECT
production-123

Verify you have a license key for Enterprise Edition

DC/OS Enterprise Edition also requires a valid license key provided by Mesosphere that will be passed into the main.tf configuration file as dcos_license_key_contents. Use the default superuser and password to log in:

Username: bootstrapuser
Password: deleteme

IMPORTANT: You should NOT use the default credentials in a production environment. When you create or identify an administrative account for the production environment, you also need to generate a password hash for the account.

Creating a cluster

Create a local folder.

mkdir dcos-tf-gcp-demo && cd dcos-tf-gcp-demo

Copy and paste the example code below into a new file and save it as main.tf in the local folder.

For simplicity in this example, the configuration values are hard-coded. If you have a desired cluster name or number of masters/agents, you can adjust the values directly in the main.tf configuration file.

Change to the dcos-tf-gcp-demo folder where you just created your main.tf file, if needed.

cd dcos-tf-gcp-demo

Initialize the Terraform modules.

terraform init

You should see a confirmation message similar to the following:

Run the execution plan and save it to a static file. For example, save the output in the plan.out file.

terraform plan -out=plan.out

Writing the execution plan to a file allows you to pass the execution plan to the apply command and guarantees the accuracy of the plan. Every time you run the terraform plan command, its output provides details about the resources the plan will add, change, or destroy. Since this sample installation creates the first DC/OS cluster, the output indicates that execution of the plan adds 38 pieces of infrastructure/resources.

The plan output file is created in the `dcos-tf-gcp-demo` folder alongside the `main.tf` file. This file is **only readable** by Terraform, however.
A message similar to the following confirms that you have successfully saved the execution plan to the `plan.out` file.

Run the following command to deploy the plan that builds the cluster:

terraform apply plan.out

Once Terraform has completed applying the plan, you should see output similar to the following:

Congratulations!

You have successfully installed a DC/OS cluster on GCP with minimal configuration or customization. From here, you can log in to begin using the new cluster.

Re-run the new execution plan with the changes you have made to the main.tfconfiguration file.

terraform plan -out=plan.out

This step ensures that the state is stable and confirms that you can create the resources necessary to scale the private agents to the desired number. Executing the plan adds the following resources as a result of scaling up the cluster’s private agents:
- One instance resource
- Two null resources which handle the DC/OS installation and prerequisites in the background.
You should see a message similar to the following:

Run the following command to have Terraform deploy the new set of resources:

terraform apply plan.out

You should see an output similar to the following:

Check your DC/OS cluster using the DC/OS UI to verify the additional agents have been added.

You should see four total nodes connected. For example:

Upgrading the cluster

Terraform also makes it easy to upgrade the DC/OS cluster to a newer version of DC/OS.

Read more about the upgrade procedure that Terraform performs in the official DC/OS Upgrade documentation.

To perform an upgrade:

Open the main.tf configuration file.

Modify the current DC/OS Version (dcos_version) to 1.12.1 and set the dcos_install_mode parameter to upgrade.

By default, the dcos_install_mode parameter value is install to enable you to create the initial DC/OS cluster and scale it without explicitly setting its value. To upgrade an existing cluster, however, you must explicitly set the parameter value to upgrade.

IMPORTANT: Do not change the number of masters, agents, or public agents while performing an upgrade.