Skip to content

Commit

Permalink
mathew updates 5
Browse files Browse the repository at this point in the history
Signed-off-by: Mathew Wicks <[email protected]>
  • Loading branch information
thesuperzapper committed Jul 15, 2024
1 parent 7b7a6bb commit 27d03c4
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 57 deletions.
24 changes: 16 additions & 8 deletions workspaces/controller/api/v1beta1/workspacekind_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ type WorkspaceKindPodTemplate struct {
HTTPProxy *HTTPProxy `json:"httpProxy,omitempty"`

// environment variables for Workspace Pods (MUTABLE)
// - the following string templates are available:
// - `.PathPrefix`: the path prefix of the Workspace (e.g. '/workspace/{profile_name}/{workspace_name}/')
// - the following go template functions are available:
// - `httpPathPrefix(portId string)`: returns the HTTP path prefix of the specified port
//+kubebuilder:validation:Optional
//+listType:="map"
//+listMapKey:="name"
Expand Down Expand Up @@ -336,23 +336,31 @@ type ImageConfigSpec struct {
// in a dropdown menu on the Workspace overview page
//+kubebuilder:validation:MinItems:=1
//+listType:="map"
//+listMapKey:="port"
//+listMapKey:="id"
Ports []ImagePort `json:"ports"`
}

type ImagePort struct {
// the display name of the port
//+kubebuilder:validation:MinLength:=2
//+kubebuilder:validation:MaxLength:=64
//+kubebuilder:example:="JupyterLab"
DisplayName string `json:"displayName"`
// the id of the port
// - this is NOT used as the Container or Service port name, but as part of the HTTP path
//+kubebuilder:validation:MinLength:=1
//+kubebuilder:validation:MaxLength:=32
//+kubebuilder:validation:Pattern:=^[a-z0-9][a-z0-9_-]*[a-z0-9]$
//+kubebuilder:example="jupyterlab"
Id string `json:"id"`

// the port number
//+kubebuilder:validation:Minimum:=1
//+kubebuilder:validation:Maximum:=65535
//+kubebuilder:example:=8888
Port int32 `json:"port"`

// the display name of the port
//+kubebuilder:validation:MinLength:=2
//+kubebuilder:validation:MaxLength:=64
//+kubebuilder:example:="JupyterLab"
DisplayName string `json:"displayName"`

// the protocol of the port
//+kubebuilder:example:="HTTP"
Protocol ImagePortProtocol `json:"protocol"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ spec:
extraEnv:
description: |-
environment variables for Workspace Pods (MUTABLE)
- the following string templates are available:
- `.PathPrefix`: the path prefix of the Workspace (e.g. '/workspace/{profile_name}/{workspace_name}/')
- the following go template functions are available:
- `httpPathPrefix(portId string)`: returns the HTTP path prefix of the specified port
items:
description: EnvVar represents an environment variable present
in a Container.
Expand Down Expand Up @@ -2323,6 +2323,15 @@ spec:
maxLength: 64
minLength: 2
type: string
id:
description: |-
the id of the port
- this is NOT used as the Container or Service port name, but as part of the HTTP path
example: jupyterlab
maxLength: 32
minLength: 1
pattern: ^[a-z0-9][a-z0-9_-]*[a-z0-9]$
type: string
port:
description: the port number
example: 8888
Expand All @@ -2338,13 +2347,14 @@ spec:
type: string
required:
- displayName
- id
- port
- protocol
type: object
minItems: 1
type: array
x-kubernetes-list-map-keys:
- port
- id
x-kubernetes-list-type: map
required:
- image
Expand Down
13 changes: 8 additions & 5 deletions workspaces/controller/config/samples/v1beta1_workspacekind.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,16 @@ spec:
## environment variables for Workspace Pods (MUTABLE)
## - spec for EnvVar:
## https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#envvar-v1-core
## - the following string templates are available:
## - `.PathPrefix`: the path prefix of the Workspace (e.g. '/workspace/{profile_name}/{workspace_name}/')
## - the following go template functions are available:
## - `httpPathPrefix(portId string)`: returns the HTTP path prefix of the specified port
##
extraEnv:

## to enable backwards compatibility with old Jupyter images from Kubeflow Notebooks V1
## https://github.com/kubeflow/kubeflow/blob/v1.8.0/components/example-notebook-servers/jupyter/s6/services.d/jupyterlab/run#L12
- name: "NB_PREFIX"
value: "{{ .PathPrefix }}"
value: |-
{{ httpPathPrefix "juptyerlab" }}
## extra volume mounts for Workspace Pods (MUTABLE)
## - spec for VolumeMount:
Expand Down Expand Up @@ -267,7 +268,8 @@ spec:
## in a dropdown menu on the Workspace overview page
##
ports:
- displayName: "JupyterLab"
- id: "jupyterlab"
displayName: "JupyterLab"
port: 8888
protocol: "HTTP"

Expand All @@ -285,7 +287,8 @@ spec:
image: "docker.io/kubeflownotebookswg/jupyter-scipy:v1.9.0"
imagePullPolicy: "IfNotPresent"
ports:
- displayName: "JupyterLab"
- id: "jupyterlab"
displayName: "JupyterLab"
port: 8888
protocol: "HTTP"

Expand Down
4 changes: 3 additions & 1 deletion workspaces/controller/internal/controller/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func NewExampleWorkspaceKind1(name string) *kubefloworgv1beta1.WorkspaceKind {
ExtraEnv: []v1.EnvVar{
{
Name: "NB_PREFIX",
Value: "{{ .PathPrefix }}",
Value: `{{ httpPathPrefix "jupyterlab" }}`,
},
},
ExtraVolumeMounts: []v1.VolumeMount{
Expand Down Expand Up @@ -278,6 +278,7 @@ func NewExampleWorkspaceKind1(name string) *kubefloworgv1beta1.WorkspaceKind {
Image: "docker.io/kubeflownotebookswg/jupyter-scipy:v1.8.0",
Ports: []kubefloworgv1beta1.ImagePort{
{
Id: "jupyterlab",
DisplayName: "JupyterLab",
Port: 8888,
Protocol: "HTTP",
Expand All @@ -301,6 +302,7 @@ func NewExampleWorkspaceKind1(name string) *kubefloworgv1beta1.WorkspaceKind {
Image: "docker.io/kubeflownotebookswg/jupyter-scipy:v1.9.0",
Ports: []kubefloworgv1beta1.ImagePort{
{
Id: "jupyterlab",
DisplayName: "JupyterLab",
Port: 8888,
Protocol: "HTTP",
Expand Down
Loading

0 comments on commit 27d03c4

Please sign in to comment.