Skip to content

Commit

Permalink
feat: Update for Kubeflow v1.3.0 (#67)
Browse files Browse the repository at this point in the history
* feat: Update for Kubeflow v1.3.0

Implement the start/stop functionality

* feat(config): Switch to yaml to go generation

Signed-off-by: William Hearn <[email protected]>

* feat: Update create notebok for v1.3.0

Switch to https://github.com/StatCan/kubeflow-apis for Kubeflow resources

* fix(workflow): Update go to 1.17.7

Co-authored-by: William Hearn <[email protected]>
  • Loading branch information
Zachary Seguin and sylus authored Feb 17, 2022
1 parent dcfba4c commit 863a996
Show file tree
Hide file tree
Showing 16 changed files with 1,175 additions and 417 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- uses: actions/setup-go@v2
with:
go-version: '1.17.7'

- name: Gather dependencies
run: |
mkdir -p ${GITHUB_WORKSPACE}/bin/
Expand Down
1 change: 0 additions & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ tasks:
check:
desc: Check for problems associated with the project
deps:
- task: go:lint
- task: go:vet
- task: go:test

Expand Down
6 changes: 4 additions & 2 deletions access.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ func (s *server) checkAccess(subjectAccessReviewTemplate authorizationv1.Subject
user := r.URL.User.Username()
if user == "" {
log.Printf("no user found")
s.respond(w, r, APIResponse{
s.respond(w, r, &APIResponseBase{
Success: false,
Status: http.StatusNotFound,
Log: "no user found",
})
return
Expand All @@ -77,8 +78,9 @@ func (s *server) checkAccess(subjectAccessReviewTemplate authorizationv1.Subject

log.Println(msg)

s.respond(w, r, APIResponse{
s.respond(w, r, &APIResponseBase{
Success: false,
Status: http.StatusForbidden,
Log: msg,
})
return
Expand Down
159 changes: 98 additions & 61 deletions config.go
Original file line number Diff line number Diff line change
@@ -1,106 +1,143 @@
package main

import "net/http"
import (
"net/http"

// ConfigurationsConfiguration Struct.
type ConfigurationsConfiguration struct {
Value []string `yaml:"value" json:"value"`
ReadOnly bool `yaml:"readOnly" json:"readOnly"`
corev1 "k8s.io/api/core/v1"
)

type SpawnerFormDefaults struct {
Image Image `yaml:"image" json:"image"`
ImageGroupOne ImageGroup `yaml:"imageGroupOne" json:"imageGroupOne"`
ImageGroupTwo ImageGroup `yaml:"imageGroupTwo" json:"imageGroupTwo"`
AllowCustomImage bool `yaml:"allowCustomImage" json:"allowCustomImage"`
ImagePullPolicy ImagePullPolicy `yaml:"imagePullPolicy" json:"imagePullPolicy"`
CPU CPU `yaml:"cpu" json:"cpu"`
Memory CPU `yaml:"memory" json:"memory"`
WorkspaceVolume WorkspaceVolume `yaml:"workspaceVolume" json:"workspaceVolume"`
DataVolumes DataVolumes `yaml:"dataVolumes" json:"dataVolumes"`
GPUs GPUs `yaml:"gpus" json:"gpus"`
Shm Shm `yaml:"shm" json:"shm"`
Configurations Configurations `yaml:"configurations" json:"configurations"`
AffinityConfig AffinityConfig `yaml:"affinityConfig" json:"affinityConfig"`
TolerationGroup TolerationGroup `yaml:"tolerationGroup" json:"tolerationGroup"`
}

// SharedMemoryConfiguration Struct.
type SharedMemoryConfiguration struct {
Value bool `yaml:"value" json:"value"`
ReadOnly bool `yaml:"readOnly" json:"readOnly"`
type AffinityConfig struct {
Value string `yaml:"value" json:"value"`
Options []AffinityConfigOption `yaml:"options" json:"options"`
ReadOnly bool `yaml:"readOnly" json:"readOnly"`
}

// GPUVendorConfiguration Struct.
type GPUVendorConfiguration struct {
LimitsKey string `yaml:"limitsKey" json:"limitsKey"`
UIName string `yaml:"uiName" json:"uiName"`
type AffinityConfigOption struct {
ConfigKey string `yaml:"configKey" json:"configKey"`
DisplayName string `yaml:"displayName" json:"displayName"`
Affinity corev1.Affinity `yaml:"affinity" json:"affinity"`
}

// GPUValueConfiguration Struct.
type GPUValueConfiguration struct {
Quantity string `yaml:"num" json:"num"`
Vendors []GPUVendorConfiguration `yaml:"vendors" json:"vendors"`
Vendor string `yaml:"vendor" json:"vendor"`
type LabelSelectorMatchExpression struct {
Key string `yaml:"key" json:"key"`
Operator string `yaml:"operator" json:"operator"`
}

// GPUConfiguration Struct.
type GPUConfiguration struct {
Value GPUValueConfiguration `yaml:"value" json:"value"`
ReadOnly bool `yaml:"readOnly" json:"readOnly"`
type CPU struct {
Value string `yaml:"value" json:"value"`
LimitFactor string `yaml:"limitFactor" json:"limitFactor"`
ReadOnly bool `yaml:"readOnly" json:"readOnly"`
}

// ValueConfiguration Struct.
type ValueConfiguration struct {
Value string `yaml:"value" json:"value"`
type Configurations struct {
Value []string `yaml:"value" json:"value"`
ReadOnly bool `yaml:"readOnly" json:"readOnly"`
}

type DataVolumes struct {
Value []ValueElement `yaml:"value" json:"value"`
ReadOnly bool `yaml:"readOnly" json:"readOnly"`
}

type ValueElement struct {
Value ValueValue `yaml:"value" json:"value"`
}

// VolumeValueConfiguration Struct.
type VolumeValueConfiguration struct {
Type ValueConfiguration `yaml:"type" json:"type"`
Name ValueConfiguration `yaml:"name" json:"name"`
Size ValueConfiguration `yaml:"size" json:"size"`
MountPath ValueConfiguration `yaml:"mountPath" json:"mountPath"`
AccessModes ValueConfiguration `yaml:"accessModes" json:"accessModes"`
Class ValueConfiguration `yaml:"class" json:"class"`
type ValueValue struct {
Type ImagePullPolicy `yaml:"type" json:"type"`
Name ImagePullPolicy `yaml:"name" json:"name"`
Size ImagePullPolicy `yaml:"size" json:"size"`
MountPath ImagePullPolicy `yaml:"mountPath" json:"mountPath"`
AccessModes ImagePullPolicy `yaml:"accessModes" json:"accessModes"`
Class ImagePullPolicy `yaml:"class" json:"class"`
}

// DataVolumesConfiguration Struct.
type DataVolumesConfiguration struct {
Values []VolumeValueConfiguration `yaml:"value" json:"value"`
ReadOnly bool `yaml:"readOnly" json:"readOnly"`
type ImagePullPolicy struct {
Value string `yaml:"value" json:"value"`
}

// WorkspaceVolumeConfiguration Struct.
type WorkspaceVolumeConfiguration struct {
Value VolumeValueConfiguration `yaml:"value" json:"value"`
ReadOnly bool `yaml:"readOnly" json:"readOnly"`
type GPUs struct {
Value GpusValue `yaml:"value" json:"value"`
ReadOnly bool `yaml:"readOnly" json:"readOnly"`
}

// ResourceConfiguration Struct.
type ResourceConfiguration struct {
Value string `yaml:"value" json:"value"`
ReadOnly bool `yaml:"readOnly" json:"readOnly"`
type GpusValue struct {
Num string `yaml:"num" json:"num"`
Vendors []Vendor `yaml:"vendors" json:"vendors"`
Vendor string `yaml:"vendor" json:"vendor"`
}

// ImageConfiguration Struct.
type ImageConfiguration struct {
type Vendor struct {
LimitsKey string `yaml:"limitsKey" json:"limitsKey"`
UIName string `yaml:"uiName" json:"uiName"`
}

type Image struct {
Value string `yaml:"value" json:"value"`
Options []string `yaml:"options" json:"options"`
ReadOnly bool `yaml:"readOnly" json:"readOnly"`
HideRegistry bool `yaml:"hideRegistry" json:"hideRegistry"`
HideVersion bool `yaml:"hideVersion" json:"hideVersion"`
}

// SpawnerFormDefaults Struct.
type SpawnerFormDefaults struct {
Image ImageConfiguration `yaml:"image" json:"image"`
CPU ResourceConfiguration `yaml:"cpu" json:"cpu"`
Memory ResourceConfiguration `yaml:"memory" json:"memory"`
WorkspaceVolume WorkspaceVolumeConfiguration `yaml:"workspaceVolume" json:"workspaceVolume"`
DataVolumes DataVolumesConfiguration `yaml:"dataVolumes" json:"dataVolumes"`
GPUs GPUConfiguration `yaml:"gpus" json:"gpus"`
SharedMemory SharedMemoryConfiguration `yaml:"shm" json:"shm"`
Configurations ConfigurationsConfiguration `yaml:"configurations" json:"configurations"`
type ImageGroup struct {
Value string `yaml:"value" json:"value"`
Options []string `yaml:"options" json:"options"`
}

type Shm struct {
Value bool `yaml:"value" json:"value"`
ReadOnly bool `yaml:"readOnly" json:"readOnly"`
}

type TolerationGroup struct {
Value string `yaml:"value" json:"value"`
Options []TolerationGroupOption `yaml:"options" json:"options"`
ReadOnly bool `yaml:"readOnly" json:"readOnly"`
}

type TolerationGroupOption struct {
GroupKey string `yaml:"groupKey" json:"groupKey"`
DisplayName string `yaml:"displayName" json:"displayName"`
Tolerations []corev1.Toleration `yaml:"tolerations" json:"tolerations"`
}

type WorkspaceVolume struct {
Value ValueValue `yaml:"value" json:"value"`
ReadOnly bool `yaml:"readOnly" json:"readOnly"`
}

// Configuration Struct.
type Configuration struct {
SpawnerFormDefaults SpawnerFormDefaults `yaml:"spawnerFormDefaults" json:"spawnerFormDefaults"`
}

type configresponse struct {
APIResponse
APIResponseBase
Config SpawnerFormDefaults `json:"config"`
}

func (s *server) GetConfig(w http.ResponseWriter, r *http.Request) {
s.respond(w, r, configresponse{
APIResponse: APIResponse{
s.respond(w, r, &configresponse{
APIResponseBase: APIResponseBase{
Success: true,
Status: http.StatusOK,
},
Config: s.Config.SpawnerFormDefaults,
})
Expand Down
85 changes: 50 additions & 35 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,42 +1,57 @@
module github.com/StatCan/jupyter-apis

go 1.14
go 1.17

require (
github.com/Azure/go-autorest/autorest v0.11.4 // indirect
github.com/Azure/go-autorest/autorest/adal v0.9.2 // indirect
github.com/StatCan/kubeflow-controller v0.0.0-20200811133651-33215007413e
github.com/andanhm/go-prettytime v1.0.0
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef // indirect
github.com/golang/protobuf v1.4.2 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/gorilla/handlers v1.4.2
github.com/gorilla/mux v1.7.4
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/imdario/mergo v0.3.10 // indirect
github.com/json-iterator/go v1.1.10 // indirect
github.com/kr/pretty v0.2.0 // indirect
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de // indirect
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc // indirect
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect
golang.org/x/sys v0.0.0-20200817155316-9781c653f443 // indirect
golang.org/x/text v0.3.3 // indirect
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/protobuf v1.25.0 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
github.com/StatCan/kubeflow-apis v0.0.0-20220217170523-72ec9dc9b637
github.com/andanhm/go-prettytime v1.1.0
github.com/gorilla/handlers v1.5.1
github.com/gorilla/mux v1.8.0
gopkg.in/inf.v0 v0.9.1
gopkg.in/yaml.v2 v2.3.0
k8s.io/api v0.18.6
k8s.io/apimachinery v0.18.8
k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible
k8s.io/utils v0.0.0-20200815180417-3bc9d57fc792 // indirect
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.23.3
k8s.io/apimachinery v0.23.3
k8s.io/client-go v0.23.3
)

replace k8s.io/client-go => k8s.io/client-go v0.18.6

replace k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.18.6

replace sigs.k8s.io/controller-runtime => sigs.k8s.io/controller-runtime v0.6.2

replace github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.4.0
require (
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
github.com/Azure/go-autorest/autorest v0.11.18 // indirect
github.com/Azure/go-autorest/autorest/adal v0.9.13 // indirect
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
github.com/Azure/go-autorest/logger v0.2.1 // indirect
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/felixge/httpsnoop v1.0.1 // indirect
github.com/form3tech-oss/jwt-go v3.2.3+incompatible // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/go-logr/logr v1.2.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.5 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/googleapis/gnostic v0.5.5 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/onsi/gomega v1.17.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
golang.org/x/net v0.0.0-20211209124913-491a49abca63 // indirect
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect
golang.org/x/sys v0.0.0-20211029165221-6e7872819dc8 // indirect
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/klog/v2 v2.30.0 // indirect
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 // indirect
k8s.io/utils v0.0.0-20211116205334-6203023598ed // indirect
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
Loading

0 comments on commit 863a996

Please sign in to comment.