The following guide will help you automate the process of running MATLAB Production Server on the Google Cloud Platform™ (GCP). The automation is accomplished using Terraform™ scripts and is supported for Linux environments only.
- MathWorks:
- MATLAB Production Servers® release R2020a or later
- MATLAB® License Manager on Google Cloud Platform
- Google Cloud Platform:
- Access to Google Cloud™ service account credentials
- Access to Google Cloud™ project
- Enabled Google Cloud Platform APIs
- Install Google Cloud SDK to access gcloud™ and gsutil™ APIs.
- SSH keys for authenticating gcloud™ and gsutil™ communication.:
- Learn how to create SSH keys.
- Learn how to locate an existing SSH key.
- Terraform (v1.0) : Documentation for Installing Terraform
- Linux : Install the following Linux packages on your system/VM: unzip, wget, curl, jq.
To set up a fully functional MATLAB Production Server using this reference architecture, there are two stages:
-
Build Stage: In this stage the Terraform scripts are used to temporarily create a single worker MATLAB Production Server instance so that a disk image for the installed product can be created and saved within Google Cloud Project for on demand deployment of larger clusters. The image contains the
MATLAB Runtime
installation for all releases configured in the build stage throughvariables.tf
and theMATLAB Production Server
installation for theVersion
configured invariables.tf
by the user. -
Deploy Stage: In this stage the terraform scripts are used to leverage the
sourcediskimage
andsourcedisksize
returned by theBuild
stage to set up a fully functionalyMATLAB Production Server
on Google Cloud Platform.
See more details on Build Stage & Deploy Stage.
Here are some steps to can help in getting started.
- Clone this repository as follows:
>> git clone https://github.com/mathworks-ref-arch/matlab-production-server-on-gcp-using-terraform.git
-
Make sure you have an existing Network License Manager setup on Google Cloud as well. See instructions on setting up a Network License Manager on Google Cloud here.
-
Install Google Cloud SDK. This step will ensure you are able to run
gcloud
andgsutil
commands from the system provisioning Google Cloud resources. Perform gcloud authentication using commandgcloud auth login
. This will authorize the gcloud API to access the Cloud Platform with your Google user credentials. -
Install Terraform v1.0 on Linux.
-
Terraform configuration uses some startup scripts for initialization of VMs. To authenticate Terraform requires
metadata-based SSH key configurations
. Create a set of SSH keys if one does not exist. See this link for steps. Provide the location of this key withinvariables.tf
for both Build and Deploy stage as follows.
# Path to ssh key for gcloud login and authorization
variable "gce_ssh_key_file_path" {
type = string
description = "/home/local-gce-user/.ssh/google_compute_engine.pub"
default = "/home/matlabuser/.ssh/google_compute_engine.pub"
}
-
Configure the default values for variables within
Software/Build
andSoftware/Deploy
folders. For more details see Build/Readme.md and Deploy/Readme.md. -
Run
terraform init
andterraform validate
within bothBuild
andDeploy
folders to make sure your current config is loaded and valid. -
This repository includes an example build and deploy script, which can used to standup a sample MATLAB Production Server cluster on Google Cloud, provided all dependencies have been installed and authentication related steps have been followed. Note: The values used for the subset of variables initialized within the
exampleBuildandDeploy.sh
script will override the values for the variables set withinvariables.tf
withinBuild
andDeploy
stages respectively.
In order to make requests against any required Google Cloud Platform API, the user needs to authenticate himself/herself. The preferred method of provisioning resources with Terraform is to use a Google Cloud service account, that can be granted a limited set of IAM permissions scoped out by the platform administrator.
In order to access a set of credentials, a user can visit the service account key page in the Cloud Console and choose an accessible Google cloud project to list the existing service accounts. One can either choose an existing service account, or create a new one based on permissions. See steps for creating a service account. Once a service account is ready for use, the user needs to download the JSON key file from the selected service account on the local machine/VM being used for provisioning. The next step is to define an environment variable GOOGLE_APPLICATION_CREDENTIALS
to provide application level access to the credentials. See instructions for setting the environment variable.
Also, provide the location of the credentials within variables.tf
in both Build and Deploy stage as shown below.
# Path to service account credentials
variable "credentials_file_path"{
type = string
default = "credentials.json"
description = "Provide full path to the credentials file for your service account"
}
For more details, see Terraform documentation on support for adding credentials.
- Multiple Google Compute instances as configured by the user.
- Google Cloud Managed instance group.
- Google Cloud Load Balancer.
- VPC network (Optional):
- Firewall rules allowing INGRESS for MATLAB Production Server ports over
http
,https
andssh
. - Target tags to apply Firewall rules for selected Google Compute instances.
- Firewall rules allowing INGRESS for MATLAB Production Server ports over
- Google Cloud Storage buckets:
- To upload deployed artifacts into the
autodeploy
location. - To access and modify current MATLAB Production Server
config
.
- To upload deployed artifacts into the
- Configure MATLAB Production Server Licensing on the Cloud
- Google Cloud authentication using Service Accounts
- About MATLAB Production Server
- MATLAB Runtime Installers
The license for this reference architecture is available in the LICENSE.MD file in this repository. This package uses certain third-party content which is licensed under separate license agreements.
Provide suggestions for additional features or capabilities using the following link: https://www.mathworks.com/products/reference-architectures/request-new-reference-architectures.html
Email: mwlab@mathworks.com