-
Notifications
You must be signed in to change notification settings - Fork 54
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?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/ok-to-test |
// NewExampleWorkspaceKindWithEmptyPortsArrayInPodTemplate returns a WorkspaceKind with an empty ports array in podTemplate.ports. | ||
func NewExampleWorkspaceKindWithEmptyPortsArrayInPodTemplate(name string) *kubefloworgv1beta1.WorkspaceKind { | ||
workspaceKind := NewExampleWorkspaceKind(name) | ||
workspaceKind.Spec.PodTemplate.Ports = []kubefloworgv1beta1.WorkspaceKindPort{} | ||
return workspaceKind | ||
} | ||
|
||
// NewExampleWorkspaceKindWithDuplicatePortsInPodTemplate returns a WorkspaceKind with duplicate ports in podTemplate.ports. | ||
func NewExampleWorkspaceKindWithDuplicatePortsInPodTemplate(name string) *kubefloworgv1beta1.WorkspaceKind { | ||
workspaceKind := NewExampleWorkspaceKind(name) | ||
workspaceKind.Spec.PodTemplate.Ports = []kubefloworgv1beta1.WorkspaceKindPort{ | ||
{ | ||
PortId: "jupyterlab", | ||
}, | ||
{ | ||
PortId: "jupyterlab", | ||
}, | ||
} | ||
return workspaceKind | ||
} | ||
|
||
// NewExampleWorkspaceKindWithNonExistentPortIdInImageConfig returns a WorkspaceKind with a non-existent portId in imageConfig.ports. | ||
func NewExampleWorkspaceKindWithNonExistentPortIdInImageConfig(name string) *kubefloworgv1beta1.WorkspaceKind { | ||
workspaceKind := NewExampleWorkspaceKind(name) | ||
workspaceKind.Spec.PodTemplate.Ports = []kubefloworgv1beta1.WorkspaceKindPort{ | ||
{ | ||
PortId: "non-existent-port-id", | ||
}, | ||
} | ||
return workspaceKind | ||
} | ||
|
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.
I wonder if we should create a helper function:
// NewExampleWorkspaceKindWithCustomPorts returns a WorkspaceKind with custom ports in podTemplate.ports.
func NewExampleWorkspaceKindWithCustomPorts(name string, ports []kubefloworgv1beta1.WorkspaceKindPort) *kubefloworgv1beta1.WorkspaceKind {
workspaceKind := NewExampleWorkspaceKind(name)
workspaceKind.Spec.PodTemplate.Ports = ports
return workspaceKind
}
open question on if this should be an exported function (or not) - but i'd lean towards leaving it exportable for other ad-hoc re-use...
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.
while trying to address this, realized unless we write more elaborate test case, creating helper function would only increase the line of code, by not have any additional effect.
since major bit is already encapsulated in NewExampleWorkspaceKind
function.
I couldn't find direct impact of creating a common helper only for port changes.
WDYT ?
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.
I think we need to update the samples/
workspacekind.yaml
to reflect these changes.
workspaces/controller/config/crd/bases/kubeflow.org_workspacekinds.yaml
Outdated
Show resolved
Hide resolved
// +kubebuilder:validation:MinLength:=1 | ||
// +kubebuilder:validation:MaxLength:=32 |
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.
Not a problem - just moreso curiousity...
is this MaxLength
tied to any inherent restriction in k8s? just wondering if the 32 length was arbitrary or if it has a real constraint underlying it.
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.
the portId is not related to direct k8s object,
it is more of endpoint that initial application should be served at.
for example: in case of jupyter, jupyterlab
id , would mean, when application is served,
the route of service , would be served at {route}/jupyterlab
the validation length needs to be discussed further.
|
||
// the http proxy config for the port | ||
// +kubebuilder:validation:Optional | ||
HTTPProxy *HTTPProxy `json:"httpProxy,omitempty"` |
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.
Out of curiosity - what is the practical purpose of defining a PortId
with no HTTProxy
? Is this moreso future-proofing as we anticipate other types of structs to be defined here in future (like SSH
, etc)?
// +kubebuilder:validation:Optional | ||
HTTPProxy *HTTPProxy `json:"httpProxy,omitempty"` | ||
Ports []WorkspaceKindPort `json:"ports,omitempty"` |
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.
Out of curiosity - what is the practical purpose of defining a WorkspaceKind with no Ports
? Why would someone want to do that ?
workspaces/controller/internal/webhook/workspacekind_webhook.go
Outdated
Show resolved
Hide resolved
5170f6e
to
438e485
Compare
- add validation webhook for podtemplate.ports - update the sample workspacekind with ports reference - referencing same id for portid in imageconfig and podtemplate.ports Signed-off-by: Harshad Reddy Nalla <[email protected]>
438e485
to
3239dde
Compare
/ok-to-test |
/lgtm testing these changes on a cluster and was able to:
|
// PortId represents a port identifier | ||
// - this is NOT used as the Container or Service port name, but as part of the HTTP path | ||
// - this is used to reference the port in the `imageconfig` ports.[].id | ||
// - this is also used to reference the port in the podtemplate ports.[].portId | ||
// |
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.
// PortId represents a port identifier | |
// - this is NOT used as the Container or Service port name, but as part of the HTTP path | |
// - this is used to reference the port in the `imageconfig` ports.[].id | |
// - this is also used to reference the port in the podtemplate ports.[].portId | |
// | |
// PortId the id of the port |
@@ -115,9 +125,9 @@ type WorkspaceKindPodTemplate struct { | |||
// volume mount paths | |||
VolumeMounts WorkspaceKindVolumeMounts `json:"volumeMounts"` | |||
|
|||
// http proxy configs (MUTABLE) | |||
// ports that the container listens on |
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.
// ports that the container listens on | |
// ports that the container listens on | |
// +listType:="map" | |
// +listMapKey:="id" |
// the id of the port | ||
// - identifier for the port in `imageconfig` ports.[].id | ||
// +kubebuilder:example="jupyterlab" | ||
PortId PortId `json:"portId"` |
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.
Probably lets just make this id
, because its kind of implied by the ports list.
// - identifier for the port in `imageconfig` ports.[].id | ||
// +kubebuilder:example="jupyterlab" | ||
PortId PortId `json:"portId"` | ||
|
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.
Because all ports of the same ID should have the same protocol, we should remove the Protocol
from imageConfigValue to here.
// - identifier for the port in `imageconfig` ports.[].id | ||
// +kubebuilder:example="jupyterlab" | ||
PortId PortId `json:"portId"` | ||
|
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 add a DefaultDisplayName field here, and make the one in imageConfigValue optional (pointer) so that people can override it for a specific image config option.
related: #37
This PR adds
spec.podTemplate.ports[]
to workspaceKind CRD, which lets users include ports httpproxy setting for their workspaces.WorkspaceKind CRD changes
These changes would be consider while setting the routing for proper traffic controller/routing to the pods.