The matlab-production-server-on-kubernetes
repository contains utilities for using MATLAB® Production Server™ in a Kubernetes® cluster.
This guide helps you to automate the process of running MATLAB
Production Server in a Kubernetes cluster by using a Helm® chart. The chart is a collection of YAML
files that define the resources you need to deploy MATLAB Production
Server in Kubernetes. Once you deploy the server, you can manage it using the
kubectl
command-line tool.
For more information about MATLAB Production Server, see the MATLAB Production Server documentation.
Before starting, you need the following:
- MATLAB Production Server license that meets the following conditions:
- Current on Software Maintenance Service (SMS).
- Linked to a MathWorks Account.
- Concurrent license type. To check your license type, see MathWorks License Center.
- Configured to use a network license manager. The license manager must be accessible from the Kubernetes cluster where you deploy MATLAB Production Server but must not be installed in the cluster.
- Network access to the MathWorks container registry, containers.mathworks.com
- Git™
- Docker®
- Running Kubernetes cluster that meets the following conditions:
- Uses Kubernetes version 1.21 or later
- Each MATLAB Production Server container in the Kubernetes cluster requires at least 1 CPU core and 2GiB RAM.
- kubectl command-line tool that can access your Kubernetes cluster
- Helm package manager to install Helm charts that contain preconfigured Kubernetes resources for MATLAB Production Server
The MATLAB Production Server on Kubernetes GitHub repository contains Helm charts that reference Ubuntu-based Docker container images for MATLAB Production Server deployment.
- Clone the MATLAB Production Server on Kubernetes GitHub repository to your machine.
git clone https://github.com/mathworks-ref-arch/matlab-production-server-on-kubernetes.git
- Navigate to the folder that contains the Helm chart for the release that you want to use, for example,
R2022b
.
cd matlab-production-server-on-kubernetes/releases/<release>/matlab-prodserver
- Log in to the MathWorks container registry,
containers.mathworks.com
, using the credentials of your MathWorks account.
docker login containers.mathworks.com
- Pull the container image for MATLAB Production Server to your machine by specifying as input parameters the name of the container registry (
containers.mathworks.com
), name of the repository (matlab-production-server
), and the release (for example,r2022b
).
The values.yaml
file contains the values for these parameters. The values.yaml
file is located in /releases/<release>/matlab-prodserver
in the GitHub repository that you cloned earlier. In values.yaml
, under the productionServer
variable, locate the registry
, repository
, and tag
variables. registry
contains the the name of the container registry, repository
contains the name of the repository, and tag
contains the release.
docker pull containers.mathworks.com/matlab-production-server:<release>
- Pull the container image for MATLAB Runtime to your machine by specifying as input parameters the name of the container registry (
containers.mathworks.com
), name of the repository (matlab-runtime
), and the release (for example,r2022b
).
The values.yaml
file contains the values for these parameters. The values.yaml
file is located in /releases/<release>/matlab-prodserver
in the GitHub repository that you cloned earlier. In values.yaml
, under the matlabRuntime
variable, locate the registry
, repository
, and tag
variables. registry
contains the the name of the container registry, repository
contains the name of the repository, and tag
contains the release.
docker pull containers.mathworks.com/matlab-runtime:<release>
After you pull the MATLAB Production Server and MATLAB Runtime container images to your system, upload them to a private container registry that your Kubernetes cluster can access.
-
Tag the images with information about your private registry. For details, see docker tag.
-
Push the images to your private registry. For details, see docker push.
-
In the GitHub repository that you cloned earlier, update the
values.yaml
file located in/releases/<release>/matlab-prodserver
with the name of your private registry. To do so, update the value of theregistry
variable nested underproductionServer
andmatlabRuntime
variables. -
If your private registry requires authentication, create a Kubernetes Secret that your pod can use to pull the image from the private registry. For more information, see Pull an Image from a Private Registry on the Kubernetes website.
A running Kubernetes cluster is required for deploying MATLAB Production Server. From the Kubernetes cluster that you use for MATLAB Production Server, provide a mapping from the storage location where you want to store MATLAB Production Server deployable archives (CTF files) to a storage resource in your cluster. You can store the deployable archives on the network file system or on the cloud. After the MATLAB Production Server deployment is complete, the deployable archives that you store in the mapped location are automatically deployed to the server.
To specify mapping, in the values.yaml
file, under matlabProductionServerSettings
, set values for the variables under autoDeploy
.
-
To specify a location on the network file system for storing deployable archives, under
autoDeploy
, setvolumeType
to"nfs"
and specify values forserver
andpath
variables. -
To specify Azure™ file share as the storage location for deployable archives, under
autoDeploy
, setvolumeType
to"azurefileshare"
and specify values forshareName
andsecretName
variables. This assumes that you have already created the file share and created a Kubernetes secret to access the file share. For more information about using an Azure file share, see Azure documentation.
The default value for volumeType
is "empty"
. However, to access deployable archives, you must set it to either "nfs"
or "azurefileshare"
.
The Helm chart for MATLAB Production Server is located in the repository in /releases/<release_number>/matlab-prodserver
. Use the helm install command to install the Helm chart for the MATLAB Production Server release that you want to deploy. It is recommended that you install the chart in a separate Kubernetes namespace. For more information about Kubernetes namespaces, see the Kubernetes documentation Share a Cluster with Namespaces.
To install the chart, you must set parameters that state your agreement to the MathWorks cloud reference architecture license and specify the address of the network license manager. You can set the parameters either in the values.yaml
file in the chart or when running helm install
.
- To accept the license terms, set the
global.agreeToLicense
parameter toYes
. - To specify the address of the license server, set the
global.licenseServer
parameter in the formatport_number@host
.
For example, this sample helm install
command installs the Helm chart for MATLAB Production Server:
helm install [-n <k8s-namespace>] --generate-name <path/to/chart> --set global.agreeToLicense=Yes --set global.licenseServer=<port_number@host>
After you install the chart, the pod takes a few minutes to initialize because the installation consists of approximately 10 GB of container images.
The deployment name is deployment.apps/matlab-production-server
. You can use the kubectl get command to confirm that MATLAB Production Server is running. The name of the service that enables network access to the pod is service/matlab-production-server
.
After the deployment is complete, upload the MATLAB Production Server deployable archive to your network file server or Azure file share. All users must have read permission to the deployable archive.
By default, the server runs on port 9910 inside the cluster. If you want the server to be accessible from outside the cluster, add port forwarding that maps the internal port 9910 to a port that is available outside the cluster. To add port forwarding, you can use the kubectl
command or the Ingress Kubernetes API object.
- This sample
kubectl
command allows the service,svc/matlab-production-server
, to accept connections from any client and maps the port 9910 inside the cluster to port 19910 available outside the cluster:
kubectl port-forward --address 0.0.0.0 --namespace=<k8s-namespace> svc/matlab-production-server 19910:9910 &
- To use Ingress, specify values in the
ingressController
variable in thevalues.yaml
file or use the default values.
The default server configuration properties are stored in a ConfigMap located at /releases/<release_number>/matlab-prodserver/templates/mps-2-configmap.yaml
. To update server properties, you can update mps-2-configmap.yaml
or values.yaml
. To apply the updated server properties to the deployment, see helm upgrade and kubectl scale.
To evaluate MATLAB functions deployed on the server, see Client Programming. Starting in R2022a, asynchronous request execution is supported, in addition to existing support for synchronous request execution.
To suggest additional features or capabilities, see Request Reference Architectures.
If you require assistance, contact MathWorks Technical Support.
MATHWORKS CLOUD REFERENCE ARCHITECTURE LICENSE © 2022 The MathWorks, Inc.