Skip to content

Workspace

The Workspace resource represents a Kubernetes environment that can be managed, hibernated, and forked by the forkspacer operator. It provides capabilities for environment lifecycle management, including automatic hibernation scheduling and connection configuration.

  • API Group: batch.forkspacer.com
  • API Version: v1
  • Kind: Workspace
  • Short Name: ws
apiVersion: batch.forkspacer.com/v1
kind: Workspace
metadata:
name: dev-environment
namespace: default
spec:
type: kubernetes
hibernated: false
connection:
type: local
autoHibernation:
enabled: true
schedule: "0 18 * * 1-5" # Hibernate at 6 PM on weekdays
wakeSchedule: "0 8 * * 1-5" # Wake at 8 AM on weekdays
status:
phase: ready
ready: true
lastActivity: "2025-10-01T10:30:00Z"
conditions:
- type: Available
status: "True"
lastTransitionTime: "2025-10-01T10:30:00Z"
reason: WorkspaceReady
message: Workspace is fully operational

The .spec field defines the desired state of the Workspace.

FieldTypeDescriptionRequired
typestringType of workspace. Currently only supports kubernetes.No (default: kubernetes)
fromobjectReference to another workspace to fork from. See FromReference.No
hibernatedbooleanWhether the workspace should be in hibernated state.No (default: false)
connectionobjectConfiguration for connecting to the workspace. See Connection.No
autoHibernationobjectConfiguration for automatic hibernation scheduling. See AutoHibernation.No

The from field allows you to create a workspace by forking from an existing workspace.

FieldTypeDescriptionRequired
namestringName of the source workspace to fork from.Yes
namespacestringNamespace of the source workspace.Yes (default: default)

Example:

spec:
from:
name: production-workspace
namespace: prod

The connection field configures how the operator connects to the workspace.

FieldTypeDescriptionRequired
typestringConnection type. Options: local, in-cluster, kubeconfig.Yes (default: local)
secretReferenceobjectReference to a secret containing connection credentials. See SecretReference.No

Example:

spec:
connection:
type: kubeconfig
secretReference:
name: workspace-kubeconfig
namespace: default

The secretReference field within connection specifies a Kubernetes Secret containing connection credentials.

FieldTypeDescriptionRequired
namestringName of the secret.Yes
namespacestringNamespace of the secret.No (default: default)

The autoHibernation field enables automatic hibernation and wake scheduling based on cron expressions.

FieldTypeDescriptionRequired
enabledbooleanWhether auto-hibernation is enabled.No (default: false)
schedulestringCron expression for hibernation schedule. Supports standard 5-field format or 6-field format with optional seconds.Yes (when enabled)
wakeSchedulestringCron expression for wake schedule. Supports standard 5-field format or 6-field format with optional seconds.No

Cron Format:

The cron expressions support two formats:

  • 5-field format: minute hour day month weekday (e.g., 0 22 * * *)
  • 6-field format: second minute hour day month weekday (e.g., 0 0 22 * * *)

Example:

spec:
autoHibernation:
enabled: true
schedule: "0 22 * * *" # 5-field: Hibernate at 10 PM daily
wakeSchedule: "0 0 6 * * *" # 6-field: Wake at 6 AM daily (with seconds)

The .status field reflects the observed state of the Workspace.

FieldTypeDescriptionRequired
phasestringCurrent phase of the workspace. Values: ready, hibernated, failed, terminating.Yes
readybooleanIndicates if the workspace is fully operational.No (default: false)
lastActivitystring (date-time)Timestamp of the last activity in the workspace.No
hibernatedAtstring (date-time)Timestamp when the workspace was hibernated.No
messagestringHuman-readable message about the current state.No
conditionsarrayStandard Kubernetes conditions. See Conditions.No

Standard Kubernetes condition types used to represent the workspace state:

  • Available: The workspace is fully functional and ready for use.
  • Progressing: The workspace is being created, updated, or transitioning between states.
  • Degraded: The workspace failed to reach or maintain its desired state.

Each condition has the following fields:

FieldTypeDescription
typestringCondition type (e.g., “Available”, “Progressing”, “Degraded”).
statusstringCondition status: True, False, or Unknown.
lastTransitionTimestring (date-time)Last time the condition transitioned.
reasonstringProgrammatic identifier for the condition’s last transition.
messagestringHuman-readable message explaining the condition.
observedGenerationintegerThe .metadata.generation that the condition was set based upon.

The status.phase field can have the following values:

  • ready: Workspace is operational and available for use.
  • hibernated: Workspace is in hibernated state with resources scaled down.
  • failed: Workspace encountered an error and is not operational.
  • terminating: Workspace is being deleted.
apiVersion: batch.forkspacer.com/v1
kind: Workspace
metadata:
name: my-workspace
spec:
type: kubernetes

Creating a Workspace with Auto-Hibernation

Section titled “Creating a Workspace with Auto-Hibernation”
apiVersion: batch.forkspacer.com/v1
kind: Workspace
metadata:
name: cost-optimized-workspace
spec:
autoHibernation:
enabled: true
schedule: "0 18 * * 1-5" # Hibernate on weekday evenings
wakeSchedule: "0 8 * * 1-5" # Wake on weekday mornings
apiVersion: batch.forkspacer.com/v1
kind: Workspace
metadata:
name: testing-workspace
spec:
from:
name: production-workspace
namespace: prod
apiVersion: batch.forkspacer.com/v1
kind: Workspace
metadata:
name: my-workspace
spec:
hibernated: true
  • Module - Modules are deployed into Workspaces
  • Overview - CRD overview and architecture