Skip to content

Commit 60c2a16

Browse files
committed
Version 1.0.0
0 parents  commit 60c2a16

35 files changed

+8323
-0
lines changed

.github/workflows/workflows.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Release Artifacts
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
release-controller-image:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
packages: write
13+
14+
steps:
15+
- name: Check out the repo
16+
uses: actions/checkout@v4
17+
18+
- name: Log in to GitHub Container Registry
19+
uses: docker/login-action@v2
20+
with:
21+
registry: ghcr.io
22+
username: ${{ github.actor }}
23+
password: ${{ secrets.GITHUB_TOKEN }}
24+
25+
- name: Build and push Docker image
26+
uses: docker/build-push-action@v3
27+
with:
28+
push: true
29+
tags: ghcr.io/mathworks-ref-arch/matlab-parallel-server-k8s/mjs-controller-image:${{ github.event.release.tag_name }}
30+
context: ./controller
31+
file: ./controller/Dockerfile
32+
33+
release-helm-chart:
34+
runs-on: ubuntu-latest
35+
permissions:
36+
contents: read
37+
packages: write
38+
39+
steps:
40+
- name: Check out the repo
41+
uses: actions/checkout@v3
42+
43+
- name: Install Helm
44+
uses: azure/setup-helm@v4
45+
46+
- name: Lint the chart
47+
run: helm lint mjs --set maxWorkers=4,matlabPVC=test,checkpointPVC=test,logPVC=test,workerLogPVC=test
48+
49+
- name: Check chart versions
50+
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
51+
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 }}
54+
55+
- 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
60+

LICENSE.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
MATHWORKS CLOUD REFERENCE ARCHITECTURE LICENSE
2+
3+
The files in this GitHub repository refer to commercial software products and services, virtual machine images, and related materials of The MathWorks, Inc. (“MathWorks Programs”). MathWorks Programs are separately licensed under the MathWorks Software License Agreement, available in the desktop installation of the MathWorks Programs or in the virtual machine image. The files in this GitHub repository may also refer to third-party software licensed under separate terms provided by such third parties.
4+
5+
The following license terms apply only to the files in this GitHub repository, including files in this folder and its subfolders, and do not apply to MathWorks Programs. References to “software” and “code” in the following license terms refer to the files in this GitHub repository.
6+
7+
Copyright (c) 2024, The MathWorks, Inc.
8+
9+
All rights reserved.
10+
11+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
12+
13+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
14+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
15+
3. In all cases, the software is, and all modifications and derivatives of the software shall be, licensed to you solely for use in conjunction with MathWorks products and service offerings.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 393 additions & 0 deletions
Large diffs are not rendered by default.

SECURITY.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Reporting Security Vulnerabilities
2+
3+
If you believe you have discovered a security vulnerability, please report it to
4+
5+
[MathWorks Vulnerability Disclosure Policy for Security Researchers](https://www.mathworks.com/company/aboutus/policies_statements/vulnerability-disclosure-policy.html)
6+
for additional information.

controller/Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2024 The MathWorks, Inc.
2+
3+
# Stage 1: Build the controller executable
4+
FROM golang:1.21.6 as builder
5+
WORKDIR /app
6+
COPY src/ /app
7+
RUN go version
8+
RUN go mod tidy
9+
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o controller /app/cmd/main.go
10+
11+
# Stage 2: Build the controller image
12+
FROM scratch
13+
LABEL maintainer="The MathWorks"
14+
COPY --from=builder /app/controller /controller
15+
16+
ENTRYPOINT ["./controller"]

controller/src/cmd/main.go

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Package main runs the MJS in Kubernetes controller
2+
// Copyright 2024 The MathWorks, Inc.
3+
package main
4+
5+
import (
6+
"controller/internal/config"
7+
"controller/internal/controller"
8+
"controller/internal/logging"
9+
"errors"
10+
"flag"
11+
"fmt"
12+
"os"
13+
"os/signal"
14+
"syscall"
15+
16+
"go.uber.org/zap"
17+
)
18+
19+
func main() {
20+
config, err := loadConfig()
21+
if err != nil {
22+
fmt.Println(err)
23+
os.Exit(1)
24+
}
25+
26+
// Create logger
27+
logger, loggerErr := logging.NewLogger(config.ControllerLogfile, config.LogLevel)
28+
if loggerErr != nil {
29+
fmt.Printf("Error creating logger: %v\n", loggerErr)
30+
os.Exit(1)
31+
}
32+
defer logger.Close()
33+
34+
// Catch SIGTERMs in a channel
35+
cancelChan := make(chan os.Signal, 1)
36+
signal.Notify(cancelChan, syscall.SIGTERM, syscall.SIGINT)
37+
38+
// Run controller
39+
logger.Info("Starting MJS controller")
40+
scaler, err := controller.NewController(config, logger)
41+
if err != nil {
42+
fmt.Println(err)
43+
logger.Error("Error creating controller", zap.Any("error", err))
44+
os.Exit(1)
45+
}
46+
go scaler.Run()
47+
48+
// Block until a cancellation is received
49+
sig := <-cancelChan
50+
logger.Info("Caught signal; shutting down", zap.Any("sig", sig))
51+
scaler.Stop()
52+
}
53+
54+
// loadConfig reads the path to a config file from the command line arguments and reads in the config file
55+
func loadConfig() (*config.Config, error) {
56+
var configFile string
57+
flag.StringVar(&configFile, "config", "", "Path to config file")
58+
flag.Parse()
59+
if configFile == "" {
60+
return nil, errors.New("must provide path to config file")
61+
}
62+
return config.LoadConfig(configFile)
63+
}

controller/src/go.mod

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
module controller
2+
3+
go 1.21.6
4+
5+
require (
6+
github.com/google/uuid v1.3.0
7+
github.com/mathworks/mjssetup v1.0.0
8+
github.com/stretchr/testify v1.8.4
9+
k8s.io/api v0.29.2
10+
k8s.io/apimachinery v0.29.2
11+
k8s.io/client-go v0.29.2
12+
)
13+
14+
require (
15+
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
16+
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
17+
github.com/go-logr/logr v1.3.0 // indirect
18+
github.com/go-openapi/jsonpointer v0.19.6 // indirect
19+
github.com/go-openapi/jsonreference v0.20.2 // indirect
20+
github.com/go-openapi/swag v0.22.3 // indirect
21+
github.com/gogo/protobuf v1.3.2 // indirect
22+
github.com/golang/protobuf v1.5.3 // indirect
23+
github.com/google/gnostic-models v0.6.8 // indirect
24+
github.com/google/gofuzz v1.2.0 // indirect
25+
github.com/gorilla/websocket v1.5.0 // indirect
26+
github.com/imdario/mergo v0.3.6 // indirect
27+
github.com/josharian/intern v1.0.0 // indirect
28+
github.com/json-iterator/go v1.1.12 // indirect
29+
github.com/mailru/easyjson v0.7.7 // indirect
30+
github.com/moby/spdystream v0.2.0 // indirect
31+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
32+
github.com/modern-go/reflect2 v1.0.2 // indirect
33+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
34+
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
35+
github.com/pkg/errors v0.9.1 // indirect
36+
github.com/spf13/pflag v1.0.5 // indirect
37+
go.uber.org/multierr v1.10.0 // indirect
38+
golang.org/x/net v0.19.0 // indirect
39+
golang.org/x/oauth2 v0.10.0 // indirect
40+
golang.org/x/sys v0.15.0 // indirect
41+
golang.org/x/term v0.15.0 // indirect
42+
golang.org/x/text v0.14.0 // indirect
43+
golang.org/x/time v0.3.0 // indirect
44+
google.golang.org/appengine v1.6.7 // indirect
45+
google.golang.org/protobuf v1.31.0 // indirect
46+
gopkg.in/inf.v0 v0.9.1 // indirect
47+
gopkg.in/yaml.v2 v2.4.0 // indirect
48+
k8s.io/klog/v2 v2.110.1 // indirect
49+
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
50+
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
51+
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
52+
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
53+
sigs.k8s.io/yaml v1.3.0 // indirect
54+
)
55+
56+
require (
57+
github.com/davecgh/go-spew v1.1.1 // indirect
58+
github.com/pmezard/go-difflib v1.0.0 // indirect
59+
github.com/stretchr/objx v0.5.0 // indirect
60+
go.uber.org/zap v1.26.0
61+
gopkg.in/yaml.v3 v3.0.1 // indirect
62+
)

0 commit comments

Comments
 (0)