Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions api/v1alpha1/workspace_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,26 @@ type AccessStrategyRef struct {
Namespace string `json:"namespace,omitempty"`
}

// IdleShutdownSpec defines idle shutdown configuration
type IdleShutdownSpec struct {
// Enabled indicates if idle shutdown is enabled
Enabled bool `json:"enabled"`

// TimeoutMinutes specifies idle timeout in minutes
// +kubebuilder:validation:Minimum=1
TimeoutMinutes int `json:"timeoutMinutes"`

// Detection specifies how to detect idle state
Detection IdleDetectionSpec `json:"detection"`
}

// IdleDetectionSpec defines idle detection methods
type IdleDetectionSpec struct {
// HTTPGet specifies the HTTP request to perform for idle detection
// +optional
HTTPGet *corev1.HTTPGetAction `json:"httpGet,omitempty"`
}

// WorkspaceSpec defines the desired state of Workspace
type WorkspaceSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
Expand Down Expand Up @@ -133,6 +153,10 @@ type WorkspaceSpec struct {
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="templateRef is immutable"
// +optional
TemplateRef *string `json:"templateRef,omitempty"`

// IdleShutdown specifies idle shutdown configuration
// +optional
IdleShutdown *IdleShutdownSpec `json:"idleShutdown,omitempty"`
}

// AccessResourceStatus defines the status of a resource created from a template
Expand Down
26 changes: 25 additions & 1 deletion api/v1alpha1/workspacetemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ type WorkspaceTemplateSpec struct {
// +kubebuilder:default="Public"
// +optional
DefaultOwnershipType string `json:"defaultOwnershipType,omitempty"`

// DefaultIdleShutdown provides default idle shutdown configuration
// Includes timeout, detection endpoint, and enable/disable
// +optional
DefaultIdleShutdown *IdleShutdownSpec `json:"defaultIdleShutdown,omitempty"`

// IdleShutdownOverrides controls override behavior and bounds
// +optional
IdleShutdownOverrides *IdleShutdownOverridePolicy `json:"idleShutdownOverrides,omitempty"`
}

// ResourceBounds defines minimum and maximum resource limits
Expand Down Expand Up @@ -148,12 +157,27 @@ type StorageConfig struct {
DefaultMountPath string `json:"defaultMountPath,omitempty"`
}

// IdleShutdownOverridePolicy defines idle shutdown override constraints
type IdleShutdownOverridePolicy struct {
// Allow controls whether workspaces can override idle shutdown
// +kubebuilder:default=true
// +optional
Allow *bool `json:"allow,omitempty"`

// MinTimeoutMinutes is the minimum allowed timeout
// +optional
MinTimeoutMinutes *int `json:"minTimeoutMinutes,omitempty"`

// MaxTimeoutMinutes is the maximum allowed timeout
// +optional
MaxTimeoutMinutes *int `json:"maxTimeoutMinutes,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:resource:scope=Cluster
// +kubebuilder:printcolumn:name="Display Name",type="string",JSONPath=".spec.displayName"
// +kubebuilder:printcolumn:name="Default Image",type="string",JSONPath=".spec.defaultImage"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
// +kubebuilder:validation:XValidation:rule="self.spec == oldSelf.spec",message="template spec is immutable after creation"

// WorkspaceTemplate is the Schema for the workspacetemplates API
// Templates define reusable, secure-by-default configurations for workspaces.
Expand Down
81 changes: 81 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 69 additions & 0 deletions config/crd/bases/workspace.jupyter.org_workspaces.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,75 @@ spec:
displayName:
description: Display Name of the server
type: string
idleShutdown:
description: IdleShutdown specifies idle shutdown configuration
properties:
detection:
description: Detection specifies how to detect idle state
properties:
httpGet:
description: HTTPGet specifies the HTTP request to perform
for idle detection
properties:
host:
description: |-
Host name to connect to, defaults to the pod IP. You probably want to set
"Host" in httpHeaders instead.
type: string
httpHeaders:
description: Custom headers to set in the request. HTTP
allows repeated headers.
items:
description: HTTPHeader describes a custom header to
be used in HTTP probes
properties:
name:
description: |-
The header field name.
This will be canonicalized upon output, so case-variant names will be understood as the same header.
type: string
value:
description: The header field value
type: string
required:
- name
- value
type: object
type: array
x-kubernetes-list-type: atomic
path:
description: Path to access on the HTTP server.
type: string
port:
anyOf:
- type: integer
- type: string
description: |-
Name or number of the port to access on the container.
Number must be in the range 1 to 65535.
Name must be an IANA_SVC_NAME.
x-kubernetes-int-or-string: true
scheme:
description: |-
Scheme to use for connecting to the host.
Defaults to HTTP.
type: string
required:
- port
type: object
type: object
enabled:
description: Enabled indicates if idle shutdown is enabled
type: boolean
timeoutMinutes:
description: TimeoutMinutes specifies idle timeout in minutes
minimum: 1
type: integer
required:
- detection
- enabled
- timeoutMinutes
type: object
image:
description: Image specifies the container image to use
type: string
Expand Down
90 changes: 87 additions & 3 deletions config/crd/bases/workspace.jupyter.org_workspacetemplates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,77 @@ spec:
type: string
type: array
type: object
defaultIdleShutdown:
description: |-
DefaultIdleShutdown provides default idle shutdown configuration
Includes timeout, detection endpoint, and enable/disable
properties:
detection:
description: Detection specifies how to detect idle state
properties:
httpGet:
description: HTTPGet specifies the HTTP request to perform
for idle detection
properties:
host:
description: |-
Host name to connect to, defaults to the pod IP. You probably want to set
"Host" in httpHeaders instead.
type: string
httpHeaders:
description: Custom headers to set in the request. HTTP
allows repeated headers.
items:
description: HTTPHeader describes a custom header to
be used in HTTP probes
properties:
name:
description: |-
The header field name.
This will be canonicalized upon output, so case-variant names will be understood as the same header.
type: string
value:
description: The header field value
type: string
required:
- name
- value
type: object
type: array
x-kubernetes-list-type: atomic
path:
description: Path to access on the HTTP server.
type: string
port:
anyOf:
- type: integer
- type: string
description: |-
Name or number of the port to access on the container.
Number must be in the range 1 to 65535.
Name must be an IANA_SVC_NAME.
x-kubernetes-int-or-string: true
scheme:
description: |-
Scheme to use for connecting to the host.
Defaults to HTTP.
type: string
required:
- port
type: object
type: object
enabled:
description: Enabled indicates if idle shutdown is enabled
type: boolean
timeoutMinutes:
description: TimeoutMinutes specifies idle timeout in minutes
minimum: 1
type: integer
required:
- detection
- enabled
- timeoutMinutes
type: object
defaultImage:
description: DefaultImage is the default container image for workspaces
using this template
Expand Down Expand Up @@ -1281,6 +1352,22 @@ spec:
- name
type: object
type: array
idleShutdownOverrides:
description: IdleShutdownOverrides controls override behavior and
bounds
properties:
allow:
default: true
description: Allow controls whether workspaces can override idle
shutdown
type: boolean
maxTimeoutMinutes:
description: MaxTimeoutMinutes is the maximum allowed timeout
type: integer
minTimeoutMinutes:
description: MinTimeoutMinutes is the minimum allowed timeout
type: integer
type: object
primaryStorage:
description: PrimaryStorage defines storage configuration
properties:
Expand Down Expand Up @@ -1389,9 +1476,6 @@ spec:
- displayName
type: object
type: object
x-kubernetes-validations:
- message: template spec is immutable after creation
rule: self.spec == oldSelf.spec
served: true
storage: true
subresources: {}
Loading