Skip to content

mathworks-ref-arch/matlab-production-server-on-gcp-using-terraform

Repository files navigation

Setting up MATLAB Production Server® on Google Cloud Platform™ using Terraform®

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.

Requirements:

Getting Started :

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 through variables.tf and the MATLAB Production Server installation for the Version configured in variables.tf by the user.

  • Deploy Stage: In this stage the terraform scripts are used to leverage the sourcediskimage and sourcedisksize returned by the Build stage to set up a fully functionaly MATLAB Production Server on Google Cloud Platform.

See more details on Build Stage & Deploy Stage.

Here are some steps to can help in getting started.

  1. Clone this repository as follows:
>> git clone https://github.com/mathworks-ref-arch/matlab-production-server-on-gcp-using-terraform.git
  1. 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.

  2. Install Google Cloud SDK. This step will ensure you are able to run gcloud and gsutil commands from the system provisioning Google Cloud resources. Perform gcloud authentication using command gcloud auth login. This will authorize the gcloud API to access the Cloud Platform with your Google user credentials.

  3. Install Terraform v1.0 on Linux.

  4. 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 within variables.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"
}
  1. Configure the default values for variables within Software/Build and Software/Deploy folders. For more details see Build/Readme.md and Deploy/Readme.md.

  2. Run terraform init and terraform validate within both Build and Deploy folders to make sure your current config is loaded and valid.

  3. 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 within variables.tf within Build and Deploy stages respectively.

Authentication:

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.

Resources created by this Reference Architecture:

  • 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 and ssh.
    • Target tags to apply Firewall rules for selected Google Compute instances.
  • Google Cloud Storage buckets:
    • To upload deployed artifacts into the autodeploy location.
    • To access and modify current MATLAB Production Server config.

Architecture of Deployed MATLAB Production Server on Google Cloud:

Architecture

Quick Links:

License

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.

Enhancement Requests

Provide suggestions for additional features or capabilities using the following link: https://www.mathworks.com/products/reference-architectures/request-new-reference-architectures.html

Support

Email: mwlab@mathworks.com

About

Terraform scripts for setting up MATLAB Production Server on Google Cloud Platform.

Topics

Resources

License

Unknown, MPL-2.0 licenses found

Licenses found

Unknown
LICENSE.MD
MPL-2.0
Mozilla_Public_License.txt

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •