Skip to content

Commit 171fb19

Browse files
authored
Merge pull request #1 from mathworks-ref-arch/1.1.0
v1.1.0
2 parents 5d7c043 + fe7cd55 commit 171fb19

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1636
-1082
lines changed
Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
name: Release Artifacts
1+
# Copyright 2024 The MathWorks, Inc.
2+
name: Release Helm Chart
23

3-
on:
4+
on:
45
release:
5-
types: [created, edited]
6+
types: [created]
67

78
jobs:
89
release-controller-image:
@@ -16,19 +17,18 @@ jobs:
1617
uses: actions/checkout@v4
1718

1819
- name: Log in to GitHub Container Registry
19-
uses: docker/login-action@v2
20+
uses: docker/login-action@v3
2021
with:
2122
registry: ghcr.io
2223
username: ${{ github.actor }}
2324
password: ${{ secrets.GITHUB_TOKEN }}
2425

2526
- name: Build and push Docker image
26-
uses: docker/build-push-action@v3
27+
uses: docker/build-push-action@v5
2728
with:
2829
push: true
2930
tags: ghcr.io/mathworks-ref-arch/matlab-parallel-server-k8s/mjs-controller-image:${{ github.event.release.tag_name }}
3031
context: ./controller
31-
file: ./controller/Dockerfile
3232

3333
release-helm-chart:
3434
runs-on: ubuntu-latest
@@ -38,23 +38,22 @@ jobs:
3838

3939
steps:
4040
- name: Check out the repo
41-
uses: actions/checkout@v3
41+
uses: actions/checkout@v4
4242

4343
- name: Install Helm
4444
uses: azure/setup-helm@v4
4545

46-
- name: Lint the chart
46+
- name: Lint chart
4747
run: helm lint mjs --set maxWorkers=4,matlabPVC=test,checkpointPVC=test,logPVC=test,workerLogPVC=test
4848

4949
- name: Check chart versions
5050
run: grep "version. ${{ github.event.release.tag_name }}" mjs/Chart.yaml && grep "appVersion. ${{ github.event.release.tag_name }}" mjs/Chart.yaml # Use "." (any character) rather than ":", since ":" breaks YAML parser
5151

52-
- name: Package the chart
53-
run: echo ${{ github.event.release.tag_name }} && helm package mjs --version ${{ github.event.release.tag_name }} --app-version ${{ github.event.release.tag_name }}
52+
- name: Package chart
53+
run: helm package mjs --version ${{ github.event.release.tag_name }} --app-version ${{ github.event.release.tag_name }}
5454

5555
- name: Login to GitHub Container Registry
56-
run: echo ${{ secrets.HELM_TOKEN }} | helm registry login ghcr.io/hannahpullen --username hannahpullen --password-stdin
57-
58-
- name: Deploy the chart
59-
run: helm push mjs-${GITHUB_REF#refs/tags/}.tgz oci://ghcr.io/mathworks-ref-arch/matlab-parallel-server-k8s
56+
run: echo ${{ secrets.HELM_TOKEN }} | helm registry login ghcr.io/mathworks-ref-arch --username hannahpullen --password-stdin
6057

58+
- name: Upload chart
59+
run: helm push mjs-${{ github.event.release.tag_name }}.tgz oci://ghcr.io/mathworks-ref-arch/matlab-parallel-server-k8s
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Copyright 2024 The MathWorks, Inc.
2+
name: Build and push MATLAB Parallel Server images
3+
4+
on:
5+
workflow_dispatch:
6+
push:
7+
# Trigger the workflow if image files or this workflow file are changed
8+
branches:
9+
- main
10+
paths:
11+
- "images/job-manager/**"
12+
- "images/worker/**"
13+
- ".github/workflows/parallel-server-images.yml"
14+
schedule:
15+
# Run at 00:00 on every Tuesday (2nd Day of the Week)
16+
# This captures updates to matlab-deps, which is rebuilt every Monday
17+
- cron: "0 0 * * 2"
18+
19+
env:
20+
LICENSE_FILE_PATH: ${{ github.workspace }}/license.lic
21+
JM_IMAGE: ghcr.io/mathworks-ref-arch/matlab-parallel-server-k8s/mjs-job-manager-image
22+
23+
jobs:
24+
# Build the job manager image and push to GHCR.
25+
build-push-job-manager-image:
26+
runs-on: ubuntu-latest
27+
permissions:
28+
contents: read
29+
packages: write
30+
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
matlab-release: [r2024a]
35+
36+
steps:
37+
- name: Checkout repo
38+
uses: actions/checkout@v4
39+
40+
- name: Login to GitHub Container Registry
41+
uses: docker/login-action@v3
42+
with:
43+
registry: ghcr.io
44+
username: ${{ github.actor }}
45+
password: ${{ secrets.GITHUB_TOKEN }}
46+
47+
- name: Build local image
48+
uses: docker/build-push-action@v5
49+
with:
50+
platforms: linux/amd64
51+
context: ./images/job-manager
52+
build-args: MATLAB_RELEASE=${{ matrix.matlab-release }}
53+
tags: ${{ env.JM_IMAGE }}:${{ matrix.matlab-release }}
54+
55+
- name: Test MJS on container
56+
env:
57+
BIN_DIR: /opt/matlab/toolbox/parallel/bin
58+
run: docker run ${JM_IMAGE}:${{ matrix.matlab-release }} bash -c "${BIN_DIR}/mjs start && ${BIN_DIR}/startjobmanager && ${BIN_DIR}/glnxa64/mjshealthcheck -matlabroot /opt/matlab"
59+
60+
- name: Push to GHCR
61+
uses: docker/build-push-action@v5
62+
with:
63+
platforms: linux/amd64
64+
context: ./images/job-manager
65+
tags: ${{ env.JM_IMAGE }}:${{ matrix.matlab-release }}
66+
push: true
67+
68+
# Build the worker image on top of the job manager image. This requires a large runner so we have enough storage for the local image.
69+
build-push-worker-image:
70+
runs-on: ubuntu-latest-m
71+
needs: [build-push-job-manager-image]
72+
permissions:
73+
contents: read
74+
packages: write
75+
76+
strategy:
77+
fail-fast: false
78+
matrix:
79+
matlab-release: [r2024a]
80+
81+
env:
82+
WORKER_IMAGE: ghcr.io/mathworks-ref-arch/matlab-parallel-server-k8s/mjs-worker-image
83+
84+
steps:
85+
- name: Checkout repo
86+
uses: actions/checkout@v4
87+
88+
- name: Login to GitHub Container Registry
89+
uses: docker/login-action@v3
90+
with:
91+
registry: ghcr.io
92+
username: ${{ github.actor }}
93+
password: ${{ secrets.GITHUB_TOKEN }}
94+
95+
- name: Build local image
96+
uses: docker/build-push-action@v5
97+
with:
98+
platforms: linux/amd64
99+
context: ./images/worker
100+
build-args: MATLAB_RELEASE=${{ matrix.matlab-release }}
101+
tags: ${{ env.WORKER_IMAGE }}:${{ matrix.matlab-release }}
102+
103+
- name: Generate MATLAB license file
104+
run: echo '${{ secrets.MATLAB_LICENSE_FILE_R2024A }}' > ${{ env.LICENSE_FILE_PATH }}
105+
106+
- name: Test MATLAB on container
107+
env:
108+
MLM_LICENSE_FILE: /tmp/license.lic # License file path on container
109+
run: docker run -v ${LICENSE_FILE_PATH}:${MLM_LICENSE_FILE} ${WORKER_IMAGE}:${{ matrix.matlab-release }} bash -c "MLM_LICENSE_FILE=${MLM_LICENSE_FILE} /opt/matlab/bin/matlab -batch 'version'"
110+
111+
- name: Push to GHCR
112+
uses: docker/build-push-action@v5
113+
with:
114+
platforms: linux/amd64
115+
context: ./images/worker
116+
tags: ${{ env.WORKER_IMAGE }}:${{ matrix.matlab-release }}
117+
build-args: MATLAB_RELEASE=${{ matrix.matlab-release }}
118+
push: true

README.md

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
[![View MATLAB Parallel Server in Kubernetes on File Exchange](https://www.mathworks.com/matlabcentral/images/matlab-file-exchange.svg)](https://www.mathworks.com/matlabcentral/fileexchange/167676-matlab-parallel-server-in-kubernetes)
44

5-
This repository contains utilities for using MATLAB® Parallel Server in a Kubernetes® cluster.
5+
This repository contains utilities for using MATLAB® Parallel Server™ in a Kubernetes® cluster.
66

77
## Introduction
88

99
This guide explains how to deploy MATLAB Job Scheduler onto your Kubernetes cluster.
1010
You can then connect to the MATLAB Job Scheduler and use it to run MATLAB Parallel Server jobs on the Kubernetes cluster.
1111

12-
For more information on MATLAB Job Scheduler and MATLAB Parallel Server, see the MathWorks documentation on [MATLAB Parallel Server](https://www.mathworks.com/help/matlab-parallel-server/index.html).
12+
For more information on MATLAB Job Scheduler and MATLAB Parallel Server, see the MathWorks® documentation on [MATLAB Parallel Server](https://www.mathworks.com/help/matlab-parallel-server/index.html).
1313

1414
## Requirements
1515

@@ -20,7 +20,6 @@ Before you start, you need the following:
2020
- Uses Kubernetes version 1.21.1 or later.
2121
- Meets the system requirements for running MATLAB Job Scheduler. For details, see the MathWorks documentation for [MATLAB Parallel Server Product Requirements](https://www.mathworks.com/support/requirements/matlab-parallel-server.html).
2222
- Configured to create external load balancers that allow traffic into the cluster.
23-
- Docker® installed on your computer. For help with installing Docker, see [Get Docker](https://docs.docker.com/get-docker/).
2423
- Kubectl installed on your computer and configured to access your Kubernetes cluster. For help with installing Kubectl, see [Install Tools](https://kubernetes.io/docs/tasks/tools/) on the Kubernetes website.
2524
- Helm® version 3.8.0 or later installed on your computer. For help with installing Helm, see [Quickstart Guide](https://helm.sh/docs/intro/quickstart/).
2625
- Network access to the MathWorks Container Registry, `containers.mathworks.com`, and the GitHub® Container registry, `ghcr.io`.
@@ -51,14 +50,11 @@ Create these volumes using your preferred storage medium.
5150
For instructions, see the [Kubernetes PersistentVolume documentation](https://kubernetes.io/docs/concepts/storage/persistent-volumes/).
5251

5352
The software requires three PersistentVolumes to retain job data and logs.
54-
You can also use a PersistentVolume to mount your own MATLAB Parallel Server installation onto the MATLAB Job Scheduler pods.
55-
If you do not create a PersistentVolume containing a MATLAB Parallel Server installation, you must use a Docker image that has MATLAB Parallel Server installed.
5653

5754
Create a PersistentVolume for each of the following applications:
5855
- An empty PersistentVolume with access mode `ReadWriteOnce` for MATLAB Job Scheduler's checkpoint folder, which retains job data after exiting the session
5956
- An empty PersistentVolume with access mode `ReadWriteOnce` to retain logs from the MATLAB Job Scheduler job manager
6057
- An empty PersistentVolume with access mode `ReadWriteMany` to retain logs from the MATLAB Job Scheduler workers
61-
- A PersistentVolume with access mode `ReadOnlyMany` containing a MATLAB Parallel Server installation
6258

6359
Now create a *PersistentVolumeClaim* for each PersistentVolume.
6460
You can create a PersistentVolumeClaim by using the following example configuration file.
@@ -82,25 +78,6 @@ spec:
8278
storage: <capacity>
8379
```
8480
85-
### Build MATLAB Parallel Server Docker Image (Optional)
86-
87-
The MATLAB Job Scheduler pods require a MATLAB Parallel Server installation.
88-
By default, you mount this from a PersistentVolume, as described in the previous step.
89-
If you do not have a MATLAB Parallel Server installation to mount, you can build a Docker image containing a MATLAB Parallel Server installation instead.
90-
91-
Build a Docker image that contains a MATLAB Parallel Server installation.
92-
- Specify `<release>` as a MATLAB release number with a lowercase `r`. For example, to install MATLAB R2024a, specify `<release>` as `r2024a`. The MATLAB release must be version R2024a or later.
93-
- Specify `<other-products>` as a space-separated list of MATLAB toolboxes you want to install. The toolbox names must match the product names listed on the MathWorks&reg; product page with any spaces replaced by underscores. For example, to install Parallel Computing Toolbox and Deep Learning Toolbox, specify `<other-products>` as `Parallel_Computing_Toolbox Deep_Learning_Toolbox`. For a complete list of product names, see [MathWorks Products](https://www.mathworks.com/products.html).
94-
- Specify `<my-tag>` as the Docker tag to use for the image.
95-
```
96-
docker build https://raw.githubusercontent.com/mathworks-ref-arch/matlab-dockerfile/main/Dockerfile --build-arg MATLAB_INSTALL_LOCATION=/opt/matlab --build-arg MATLAB_RELEASE=<release> --build-arg MATLAB_PRODUCT_LIST="MATLAB MATLAB_Parallel_Server <other-products>" -t <my-tag>
97-
```
98-
99-
Push the image to a repository that is visible to your Kubernetes cluster.
100-
101-
For more information on building a MATLAB Docker image, see [Create a MATLAB Container Image](https://github.com/mathworks-ref-arch/matlab-dockerfile) in the GitHub repository.
102-
103-
10481
### Create Administrator Password Secret
10582
10683
By default, MATLAB Job Scheduler in Kubernetes runs at security level 2.
@@ -123,24 +100,30 @@ Copy the following lines into a YAML file, `values.yaml`, and modify the values
123100
```yaml
124101
matlabRelease: r2024a
125102
maxWorkers: 100
126-
matlabPVC: "matlab-pvc"
103+
104+
# Licensing settings
105+
useOnlineLicensing: true
106+
networkLicenseManager: ""
107+
108+
# PersistentVolumeClaim settings
127109
checkpointPVC: "checkpoint-pvc"
128110
logPVC: "log-pvc"
129111
workerLogPVC: "worker-log-pvc"
112+
113+
# Security settings
130114
jobManagerUserID: 0
131115
jobManagerGroupID: 0
132-
matlabImage: ""
133116
```
134117
Modify the following values:
135118
- `matlabRelease` &mdash; Specify the release number of the MATLAB Parallel Server installation.
136119
- `maxWorkers` &mdash; Specify the maximum number of MATLAB Parallel Server workers to run in the cluster. The cluster starts with zero workers and automatically scales up to this number as the cluster becomes busy.
137-
- `matlabPVC` &mdash; Specify the name of a PersistentVolumeClaim that is bound to the PersistentVolume with a MATLAB Parallel Server installation.
120+
- `useOnlineLicensing` &mdash; Option to use MathWorks online licensing. Set this parameter to true to use online licensing to manage licensing for your cluster users. When enabled, users must log in to their MathWorks account to connect to the cluster, and their account must be linked to a MATLAB Parallel Server license that is managed online. For more information about online licensing, see [Use Online Licensing for MATLAB Parallel Server](https://www.mathworks.com/products/matlab-parallel-server/online-licensing.html) on the MathWorks website. To learn how to set up online licensing, see the MathWorks documentation [Configure MATLAB Parallel Server Licensing for Cloud Platforms](https://www.mathworks.com/help/matlab-parallel-server/configure-matlab-parallel-server-licensing-for-cloud-platforms.html).
121+
- `networkLicenseManager` &mdash; To use a network license manager to manage licensing for your cluster users, specify the address of your network license manager in the format `port@host`. The license manager must be accessible from the Kubernetes cluster. You can install or use an existing network license manager running on-premises or on AWS&reg;. To install a network license manager on-premises, see the MathWorks documentation [Install License Manager on License Server](https://www.mathworks.com/help/install/ug/install-license-manager-on-license-server.html). To deploy a network license manager reference architecture on AWS, select a MATLAB release from [Network License Manager for MATLAB on AWS](https://github.com/mathworks-ref-arch/license-manager-for-matlab-on-aws).
138122
- `checkpointPVC` &mdash; Specify the name of a PersistentVolumeClaim that is bound to a PersistentVolume used to retain job data.
139123
- `logPVC` &mdash; Specify the name of a PersistentVolumeClaim that is bound to a PersistentVolume used to retain job manager logs.
140124
- `workerLogPVC` &mdash; Specify the name of a PersistentVolumeClaim that is bound to a PersistentVolume used to retain worker logs.
141125
- `jobManagerUserID` &mdash; Specify the user ID of the user account that MATLAB Job Scheduler should use to run the job manager pod. The user must have write permission for the checkpoint and log PersistentVolumes. To find the user ID, on a Linux machine, run `id -u`.
142126
- `jobManagerGroupID` &mdash; Specify the group ID of the user account that MATLAB Job Scheduler should use to run the job manager pod. The user must have write permission for the checkpoint and log PersistentVolumes. To find the group ID, on a Linux machine, run `id -g`.
143-
- `matlabImage` &mdash; Specify the URI of a Docker image that contains a MATLAB Parallel Server installation. Specify a URI only if you built a Docker image instead of mounting a MATLAB Parallel Server installation from a PersistentVolume. If you specify this parameter, set the `matlabPVC` parameter to an empty string (`""`).
144127

145128
For a full list of the configurable Helm values that you can set in this file, see the [Helm Values](helm_values.md) page.
146129

@@ -228,6 +211,13 @@ If you created a custom load balancer service, delete the service:
228211
kubectl delete service mjs-ingress-proxy --namespace mjs
229212
```
230213

214+
If you want to reinstall MATLAB Job Scheduler, you must ensure that the load balancer service is deleted first.
215+
To check the status of the load balancer service, run:
216+
```
217+
kubectl get service mjs-ingress-proxy --namespace mjs
218+
```
219+
If the load balancer service appears, wait for some time, then run the command again to confirm that the load balancer service is not found before proceeding with the MATLAB Job Scheduler reinstallation.
220+
231221
## Examples
232222

233223
Create a cluster object using your cluster profile `<name>`:
@@ -311,6 +301,29 @@ end
311301

312302
## Advanced Setup Steps
313303

304+
### Customize Worker Image
305+
306+
The MATLAB Parallel Server workers run on an image that contains MATLAB, Simulink, all MathWorks toolboxes, and the Deep Learning Support Packages by default.
307+
If you want to increase the performance of creating worker pods or customise the toolboxes or support packages used, you have two options:
308+
1. Build a custom Docker image with only the toolboxes you need
309+
2. Mount the MATLAB installation from a PersistentVolume
310+
311+
#### Build Custom Docker Image
312+
313+
To build a custom Docker image, see [Create a MATLAB Parallel Server Container Image](images/worker/README.md).
314+
Push the image to a repository that is visible to your Kubernetes cluster.
315+
316+
Modify your `values.yaml` file to set the `workerImage` and `workerImageTag` parameters to the URI and tag of your image before installating the Helm chart.
317+
318+
#### Mount MATLAB from a PersistentVolume
319+
320+
To mount MATLAB from a PersistentVolume, create a PersistentVolume and PersistentVolumeClaim with access mode `ReadOnlyMany` containing a MATLAB Parallel Server installation.
321+
For example, if your Kubernetes cluster runs on-premise, you could create a PersistentVolume from an NFS server containing the MATLAB Parallel Server installation.
322+
For details on creating the PersistentVolumeClaim, see the [Create Persistent Volumes](#create-persistent-volumes) section.
323+
324+
Modify your `values.yaml` file to set the `matlabPVC` parameter to the name of your PersistentVolumeClaim before installating the Helm chart.
325+
The worker pods will now use the image URI specified in the `matlabDepsImage` parameter instead of the `workerImage` parameter.
326+
314327
### Customize Load Balancer
315328

316329
MATLAB Job Scheduler in Kubernetes uses a Kubernetes load balancer service to expose MATLAB Job Scheduler to MATLAB clients running outside of the Kubernetes cluster.

mjs/Chart.yaml renamed to chart/mjs/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ apiVersion: v2
33
name: mjs
44
description: A Helm chart for MATLAB (R) Job Scheduler in Kubernetes
55
type: application
6-
version: 1.0.0
7-
appVersion: 1.0.0
6+
version: 1.1.0
7+
appVersion: 1.1.0

chart/mjs/templates/_derived.tpl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Define derived settings for use in multiple template files.
2+
# Copyright 2024 The MathWorks, Inc.
3+
4+
# Maximum number of pool proxies needed by this chart
5+
{{- define "derived.numProxies" -}}
6+
{{ divf .Values.maxWorkers .Values.workersPerPoolProxy | ceil }}
7+
{{- end -}}
8+
9+
# MJS lookup port
10+
{{- define "derived.lookupPort" -}}
11+
{{ add .Values.basePort 6 | int }}
12+
{{- end -}}
13+
14+
# Job manager port
15+
{{- define "derived.jobManagerPort" -}}
16+
{{ add .Values.basePort 9 | int }}
17+
{{- end -}}
18+
19+
# Whether to create environment variables for each service in the namespace (default false to prevent creation of too many environment variables)
20+
{{- define "derived.enableServiceLinks" -}}
21+
{{ .Values.enableServiceLinks | default false }}
22+
{{- end -}}

0 commit comments

Comments
 (0)