Skip to content

Commit

Permalink
Publish R2024b (#31)
Browse files Browse the repository at this point in the history
* helm chart action - initial commit

* deprecate chart older than 3 years

* helm chart action - initial commit

* Enable action for non-main branch

* Added chart version check

* Added chart version check

* Added chart version check

* Added chart version check

* Added chart version check

* Test run

* Test run

* Test run

* Test run

* Test run

* Test run

* Test run

* Test run

* Cleanup

* Cleanup

* Chart updates for R2024b

* Add Quick Start instructions to readme (#30)

* Add Quick Start instructions to readme

* Update README.md

---------

Co-authored-by: esteinerMW <[email protected]>
Co-authored-by: Eitan Steiner <[email protected]>
Co-authored-by: EUdler <[email protected]>
  • Loading branch information
4 people authored Sep 12, 2024
1 parent a3faedd commit 7bbf2ce
Show file tree
Hide file tree
Showing 9 changed files with 234 additions and 76 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/helm-chart.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Prerelease Helm Chart

on:
workflow_dispatch:
push:
branches:
- Helm_artifacts

env:
HELM_CHART_VERSION: 1.1.0
MATLAB_APP_VERSION: "R2024b"

jobs:
release-helm-chart:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Check out the repo
uses: actions/checkout@v4

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

- name: Check that chart exists
run: |
CHART_DIR="releases/${{ env.MATLAB_APP_VERSION }}/matlab-prodserver" && cat ${CHART_DIR}/Chart.yaml
echo "CHART_DIR=${CHART_DIR}" >> $GITHUB_ENV # Add to env if exists
- name: Check chart versions
run: |
grep 'version: ${{ env.HELM_CHART_VERSION }}' ${CHART_DIR}/Chart.yaml && grep 'appVersion: "${{ env.MATLAB_APP_VERSION }}"' ${CHART_DIR}/Chart.yaml
- name: Package the chart
run: helm package ${CHART_DIR} --version ${{ env.HELM_CHART_VERSION }} --app-version ${{ env.MATLAB_APP_VERSION }}

- name: Login to GitHub Container Registry
run: echo ${{ secrets.CR_TOKEN }} | helm registry login ${{ secrets.MATHWORKS_REGISTRY }} --username ${{ secrets.CR_USER }} --password-stdin

- name: Deploy the chart
run: helm push matlab-prodserver-k8s-${{ env.HELM_CHART_VERSION }}.tgz oci://${{ secrets.MATHWORKS_REGISTRY }}

38 changes: 33 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,42 @@ Before starting, you need the following:
* [Git™](https://git-scm.com/)
* [Docker®](https://www.docker.com/)
* Running [Kubernetes](https://kubernetes.io/) cluster that meets the following conditions:
* Uses Kubernetes version 1.27 or later.
* Uses Kubernetes version 1.28 or later.
* Each MATLAB Production Server container in the Kubernetes cluster requires at least 1 CPU core and 2 GiB RAM.
* [kubectl](https://kubernetes.io/docs/reference/kubectl/overview/) command-line tool that can access your Kubernetes cluster
* [Helm](https://helm.sh/) package manager to install Helm charts that contain preconfigured Kubernetes resources for MATLAB Production Server
* Uses Helm version v3.13.0 or later.
* Uses Helm version v3.14 or later.

If you do not have a license, please contact your MathWorks representative [here](https://www.mathworks.com/company/aboutus/contact_us/contact_sales.html) or [request a trial license](https://www.mathworks.com/campaigns/products/trials.html?prodcode=PR).

## Quick Start
The Quick Start option is recommended for the following cases:
* You are deploying MATLAB Production Server R2024b or newer
* You don't require significant changes to the Helm chart
* You are not running MATLAB Production server on Kubernetes as part of a CI/CD workflow
For CI/CD workflows, we recommend that you cache docker images in your private container registry. For more complex workflows, use the [Deployment Steps](#Deployment-Steps)

The Quick Start option only requires you to download a single file, rather than cloning the full GitHub repository. For more complex workflows, use the [Deployment Steps](#Deployment-Steps)

1. Download the `values-overrides.yaml` file containing configuration options that apply across all release deployments from the MATLAB Production Server on Kubernetes GitHub repository. You can use the cURL command below or click the "Download Raw File" icon.
```
curl -O https://raw.githubusercontent.com/mathworks-ref-arch/matlab-production-server-on-kubernetes/main/values-overrides.yaml
```
2. Complete the steps in [Provide Mapping for Deployable Archives](#Provide-Mapping-for-Deployable-Archives).
3. Before installing the chart, first set parameters that state your agreement to the MathWorks cloud reference architecture license and specify the address of the network license manager. In the top-level values-overrides.yaml file, set these parameters:
To accept the license terms, set global > agreeToLicense to "yes".
To specify the address of the license server, set global > licenseServer using the format port_number@host.
Next, install the Helm chart for MATLAB Production Server by using the following `helm install` command:
```
helm install -f <path/to/values-overrides.yaml> [-n <k8s-namespace>] --generate-name oci://containers.mathworks.com/matlab-prodserver-k8s --version 1.1.0
```
4. 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.
## Deployment Steps
### Clone GitHub® Repository that Contains Helm Chart
The MATLAB Production Server on Kubernetes GitHub repository contains Helm charts that reference Ubuntu-based Docker container images for MATLAB Production Server deployment.
Expand All @@ -43,7 +71,7 @@ The MATLAB Production Server on Kubernetes GitHub repository contains Helm chart
```
This repository includes Helm chart folders for each supported MATLAB Production Server release and a `values-overrides.yaml` file containing configuration options that apply across all release deployments.
2. Navigate to the Helm chart folder for the release you want to use. Replace `<release>` with the release version, for example, `R2024a`.
2. Navigate to the Helm chart folder for the release you want to use. Replace `<release>` with the release version, for example, `R2024b`.
```
cd matlab-production-server-on-kubernetes/releases/<release>/matlab-prodserver
```
Expand All @@ -60,7 +88,7 @@ The MATLAB Production Server on Kubernetes GitHub repository contains Helm chart
```
* `containers.mathworks.com` is the name of the container registry.
* `matlab-production-server` is the name of the repository.
* `<release-tag>` is the tag name of the MATLAB Production Server release, for example, `r2024a`.
* `<release-tag>` is the tag name of the MATLAB Production Server release, for example, `r2024b`.
The `values.yaml` file specifies these values in the `productionServer` section, in the `registry`, `repository`, and `tag` variables, respectively.
Expand All @@ -71,7 +99,7 @@ The MATLAB Production Server on Kubernetes GitHub repository contains Helm chart
```
* `containers.mathworks.com` is the name of the container registry.
* `matlab-runtime` is the name of the repository.
* `<release-tag>` is the tag name of the MATLAB Runtime release. Update this value to the release version of the MATLAB Runtime you are using, for example, `r2024a`. MATLAB Production Server supports MATLAB Runtime versions up to six releases back from the MATLAB Production Server version you are using.
* `<release-tag>` is the tag name of the MATLAB Runtime release. Update this value to the release version of the MATLAB Runtime you are using, for example, `r2024b`. MATLAB Production Server supports MATLAB Runtime versions up to six releases back from the MATLAB Production Server version you are using.
The `values.yaml` file specifies these values in the `matlabRuntime` section, in the `registry`, `repository`, and `tag` variables, respectively.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v2
appVersion: "R2021b"
appVersion: "R2024b"
description: MATLAB Production Server Helm chart for Kubernetes
name: matlab-prodserver-k8s
version: 0.1.0
version: 1.1.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#
# Expose MATLAB Production Server internal endpoint
#
kind: Service
apiVersion: v1
metadata:
name: matlab-production-server
namespace: {{ .Release.Namespace }}
labels:
app: mps
release: {{ .Release.Name }}
spec:
selector:
app: mps
ports:
- name: mps-port
port: 9910
targetPort: 9910
type: ClusterIP

---
{{- if .Values.global.ingressController.enabled }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: matlab-production-server-ingress
namespace: {{ .Release.Namespace }}
labels:
release: {{ .Release.Name }}
annotations:
{{ if .Values.global.ingressController }}
## set ingress-conroller vendor-specific annotations:
{{- range $key, $value := .Values.global.ingressController.annotations }}
{{ $key }}: {{ quote $value }}
{{- end }}
{{ end }}
spec:
ingressClassName: {{ .Values.global.ingressController.name }}
{{ if .Values.global.ingressController.tls.enabled }}
tls:
- hosts:
- {{ .Values.global.ingressController.domainBase }}
{{- if .Values.global.ingressController.tls.secretName }}
secretName: {{ .Values.global.ingressController.tls.secretName }}
{{- end }}
{{ end }}

rules:
- host: {{ .Values.global.ingressController.domainBase }}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: matlab-production-server
port:
number: 9910
{{- end }}

---
{{ if and (.Values.optionalSettings.Prometheus.enabled) (.Capabilities.APIVersions.Has "monitoring.coreos.com/v1/ServiceMonitor") }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: matlab-production-server-monitor
labels:
app: mps
app.kubernetes.io/part-of: {{ .Values.optionalSettings.Prometheus.matchOn }}
release: {{ .Values.optionalSettings.Prometheus.matchOn }}
spec:
selector:
matchLabels:
app: mps
release: {{ .Release.Name }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
endpoints:
- port: mps-port
path: /api/metrics
{{ end }}

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ data:
main_config: |
--http 9910
--ssl-verify-peer-mode no-verify-peer
--ssl-protocols TLSv1.1,TLSv1.2
--ssl-protocols TLSv1.2
--ssl-ciphers ALL
--mcr-root /opt/matlabruntime/{{ .Values.images.matlabRuntime.variant }}
--num-workers {{ .Values.matlabProductionServerSettings.numWorkers | default 1 }}
Expand Down Expand Up @@ -42,15 +42,26 @@ data:
--server-memory-threshold-overflow-action purge_responses
--enable-discovery
--enable-metrics
--routes-file ./config/routes.json
{{- if .Values.optionalSettings.Redis.host }}
mps_cache_config: |
{"Connections":
{"{{ .Values.optionalSettings.Redis.name }}":
{"Provider":"Redis",
"Host":{{ .Values.optionalSettings.Redis.host | quote }},
"Port":{{ .Values.optionalSettings.Redis.port | default 6379 }}}
"Port":{{ .Values.optionalSettings.Redis.port | default 6379 }}
{{- if .Values.optionalSettings.Redis.auth }}
,"Key":{{ .Values.optionalSettings.Redis.auth | quote }}
{{- end }}
}
}
}
{{- end }}

routes.json: |
{
"version": "1.0.0",
"pathmap": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,34 @@ spec:
labels:
app: mps
annotations:
{{ if not .Values.optionalSettings.Prometheus.enabled }}
prometheus.io/scrape: 'true'
prometheus.io/path: '/api/metrics'
prometheus.io/port: '9910'
{{ end }}
spec:
securityContext:
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 1000
runAsUser: 1001
runAsGroup: 1001

containers:
- name: mps
image: {{ .Values.images.productionServer.registry }}/{{ .Values.images.productionServer.repository }}:{{ .Values.images.productionServer.tag }}
image: {{ .Values.global.images.registry | default .Values.images.productionServer.registry }}/{{ .Values.images.productionServer.repository }}:{{ .Values.images.productionServer.tag }}
env:
- name: AGREE_TO_MATHWORKS_SOFTWARE_LICENSE
value: {{ .Values.global.agreeToLicense | default "no" | lower | quote }}
value: {{ required "agreeToLicense must be set to \"yes\"." .Values.global.agreeToLicense | default "no" | lower | quote }}
- name: AGREE_TO_MATLAB_RUNTIME_LICENSE
value: {{ .Values.global.agreeToLicense | default "no" | lower | quote }}
value: {{ required "agreeToLicense must be set to \"yes\"." .Values.global.agreeToLicense | default "no" | lower | quote }}
- name: LD_LIBRARY_PATH
value: "/opt/matlabruntime/{{ .Values.images.matlabRuntime.variant }}/runtime/glnxa64:/opt/matlabruntime/{{ .Values.images.matlabRuntime.variant }}/bin/glnxa64:/opt/matlabruntime/{{ .Values.images.matlabRuntime.variant }}/sys/os/glnxa64:/opt/matlabruntime/{{ .Values.images.matlabRuntime.variant }}/extern/bin/glnxa64:/opt/matlabruntime/{{ .Values.images.matlabRuntime.variant }}/sys/opengl/lib/glnxa64"
{{ if .Values.optionalSettings.Redis.secretName }}
- name: MPS_REDIS_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.optionalSettings.Redis.secretName }}
key: {{ .Values.optionalSettings.Redis.secretKey | default "redis-password" }}
{{ end }}

ports:
- containerPort: 9910
Expand All @@ -62,8 +71,8 @@ spec:
exec:
command:
- ls
- /opt/matlabruntime/{{ .Values.images.matlabRuntime.variant }}/MCR_license.txt
initialDelaySeconds: 30
- /opt/matlabruntime/{{ .Values.images.matlabRuntime.variant }}/matlabruntime_license_agreement.pdf
initialDelaySeconds: 10
periodSeconds: 30

livenessProbe:
Expand All @@ -82,7 +91,7 @@ spec:

initContainers:
- name: matlab-runtime
image: {{ .Values.images.matlabRuntime.registry }}/{{ .Values.images.matlabRuntime.repository }}:{{ .Values.images.matlabRuntime.tag }}
image: {{ .Values.global.images.registry | default .Values.images.matlabRuntime.registry }}/{{ .Values.images.matlabRuntime.repository }}:{{ .Values.images.matlabRuntime.tag }}

command:
- /bin/sh
Expand All @@ -97,10 +106,13 @@ spec:

restartPolicy: {{ .Values.deploymentSettings.restartPolicy }}
imagePullSecrets:
{{- if .Values.global.images.pullSecret }}
- name: {{ .Values.global.images.pullSecret }}
{{- end }}
{{- if .Values.images.productionServer.pullSecret }}
- name: {{ .Values.images.productionServer.pullSecret }}
{{- end }}
{{- if .Values.images.matlabRuntime.pullSecret }}
{{- if and .Values.images.matlabRuntime.pullSecret (ne .Values.images.matlabRuntime.pullSecret .Values.images.productionServer.pullSecret) }}
- name: {{ .Values.images.matlabRuntime.pullSecret }}
{{- end }}

Expand All @@ -120,6 +132,9 @@ spec:
server: {{ .Values.matlabProductionServerSettings.autoDeploy.server }}
path: {{ .Values.matlabProductionServerSettings.autoDeploy.path }}
readOnly: true
{{- else if eq .Values.matlabProductionServerSettings.autoDeploy.volumeType "pvc" }}
persistentVolumeClaim:
claimName: {{ .Values.matlabProductionServerSettings.autoDeploy.claimName }}
{{- else if eq .Values.matlabProductionServerSettings.autoDeploy.volumeType "azurefileshare" }}
azureFile:
shareName: {{ .Values.matlabProductionServerSettings.autoDeploy.shareName }}
Expand Down
Loading

0 comments on commit 7bbf2ce

Please sign in to comment.