-
Notifications
You must be signed in to change notification settings - Fork 62
feat(ws): add spec.podTemplate.ports[] to WorkspaceKind #507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: notebooks-v2
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -340,12 +340,9 @@ func buildServices(ws *kubefloworgv1beta1.Workspace, imageConfigValue *kubeflowo | |
services := make([]Service, len(imageConfigValue.Spec.Ports)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We might want to first build a map from |
||
for i := range imageConfigValue.Spec.Ports { | ||
port := imageConfigValue.Spec.Ports[i] | ||
switch port.Protocol { //nolint:gocritic | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should keep this switch statement, but instead switch on the protocol from the outer workspace kind |
||
case kubefloworgv1beta1.ImagePortProtocolHTTP: | ||
services[i].HttpService = &HttpService{ | ||
DisplayName: port.DisplayName, | ||
HttpPath: fmt.Sprintf("/workspace/%s/%s/%s/", ws.Namespace, ws.Name, port.Id), | ||
} | ||
services[i].HttpService = &HttpService{ | ||
DisplayName: *port.DisplayName, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will null pointer deref error, you should use something like |
||
HttpPath: fmt.Sprintf("/workspace/%s/%s/%s/", ws.Namespace, ws.Name, port.Id), | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,13 @@ import ( | |
=============================================================================== | ||
*/ | ||
|
||
// PortId the id of the port | ||
// | ||
// +kubebuilder:validation:MinLength:=1 | ||
// +kubebuilder:validation:MaxLength:=32 | ||
// +kubebuilder:validation:Pattern:=^[a-z0-9][a-z0-9_-]*[a-z0-9]$ | ||
type PortId string | ||
|
||
// WorkspaceKindSpec defines the desired state of WorkspaceKind | ||
type WorkspaceKindSpec struct { | ||
|
||
|
@@ -115,9 +122,11 @@ type WorkspaceKindPodTemplate struct { | |
// volume mount paths | ||
VolumeMounts WorkspaceKindVolumeMounts `json:"volumeMounts"` | ||
|
||
// http proxy configs (MUTABLE) | ||
// ports that the container listens on | ||
thesuperzapper marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// +kubebuilder:validation:Optional | ||
HTTPProxy *HTTPProxy `json:"httpProxy,omitempty"` | ||
// +listType:="map" | ||
// +listMapKey:="id" | ||
Ports []WorkspaceKindPort `json:"ports,omitempty"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Out of curiosity - what is the practical purpose of defining a WorkspaceKind with no There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a great question , we should rethink this 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should require at least one port, just so that the frontend does not have to deal with the possibility of a workspace with no ports.
|
||
|
||
// environment variables for Workspace Pods (MUTABLE) | ||
// - the following go template functions are available: | ||
|
@@ -151,6 +160,27 @@ type WorkspaceKindPodTemplate struct { | |
Options WorkspaceKindPodOptions `json:"options"` | ||
} | ||
|
||
type WorkspaceKindPort struct { | ||
// the id of the port | ||
// - identifier for the port in `imageconfig` ports.[].id | ||
// +kubebuilder:example="jupyterlab" | ||
Id PortId `json:"id"` | ||
|
||
// the protocol of the port | ||
// +kubebuilder:example:="HTTP" | ||
Protocol ImagePortProtocol `json:"protocol"` | ||
|
||
// the display name of the port | ||
// +kubebuilder:validation:MinLength:=2 | ||
// +kubebuilder:validation:MaxLength:=64 | ||
// +kubebuilder:example:="JupyterLab" | ||
DefaultDisplayName string `json:"displayName"` | ||
|
||
thesuperzapper marked this conversation as resolved.
Show resolved
Hide resolved
thesuperzapper marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// the http proxy config for the port (MUTABLE) | ||
// +kubebuilder:validation:Optional | ||
HTTPProxy *HTTPProxy `json:"httpProxy,omitempty"` | ||
thesuperzapper marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
type WorkspaceKindPodMetadata struct { | ||
// labels to be applied to the Pod resource | ||
// +kubebuilder:validation:Optional | ||
|
@@ -339,11 +369,8 @@ type ImageConfigSpec struct { | |
type ImagePort struct { | ||
// 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"` | ||
Id PortId `json:"id"` | ||
|
||
// the port number | ||
// +kubebuilder:validation:Minimum:=1 | ||
|
@@ -354,12 +381,8 @@ 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 protocol of the port | ||
// +kubebuilder:example:="HTTP" | ||
Protocol ImagePortProtocol `json:"protocol"` | ||
// +kubebuilder:validation:Optional | ||
DisplayName *string `json:"displayName,omitempty"` | ||
} | ||
|
||
// +kubebuilder:validation:Enum:={"HTTP"} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be testing with at least one of these being nil, so that we use the default.