Kubernetes controller that manages the lifecycle of Workspace custom resources.
The controller watches for Workspace CRs and reconciles them into:
- A StatefulSet (replicas 0 or 1) running the workspace container
- A ClusterIP Service exposing the workspace on port 80
- Group:
kubeworkspaces.io - Version:
v1alpha1 - Kind:
Workspace - Scope: Namespaced
The spec wraps a full corev1.PodSpec under spec.template.spec, mirroring the Kubeflow Notebook CRD pattern. This gives full flexibility for container configuration including env vars, args, volume mounts, resource limits, etc.
The controller reports:
readyReplicas- Number of ready pods (0 or 1)containerState- Running/waiting/terminated state of the first containerconditions- Pod conditions mirrored to the workspace
- Stop: Add annotation
kubeworkspaces.io/stopped: "true"(sets replicas to 0) - Start: Remove the annotation (sets replicas to 1)
The controller watches for annotation changes and updates the StatefulSet replicas accordingly.
- Ensure StatefulSet exists (create or update)
- Ensure Service exists (create if missing)
- Check for
kubeworkspaces.io/stoppedannotation -> set replicas to 0 or 1 - Update workspace status from pod state (container state, conditions, ready replicas)
- Ensure default container port if not specified (default: 8080)
# Generate CRD manifests
make manifests
# Generate deepcopy code
make generate
# Install CRD to cluster
make install
# Run controller locally
make rundocker build -t kube-workspaces-controller:latest -f Dockerfile .kubectl apply --server-side -f config/samples/v1alpha1_workspace.yaml
kubectl apply --server-side -f config/samples/v1alpha1_workspace_desktop.yamlNote: --server-side is required because the CRD is too large for client-side apply.
The controller requires a ClusterRole with permissions for:
workspaces.kubeworkspaces.io- all verbs + status subresourceapps/statefulsets- create, get, list, watch, update, deletecore/services- create, get, list, watch, update, deletecore/pods- get, list, watchcore/pods/log- getcore/events- get, list, watch
| Repository | Description |
|---|---|
| kube-workspaces/api | REST API service |
| kube-workspaces/proxy | Workspace reverse proxy |
| kube-workspaces/frontend | Next.js web UI |
| kube-workspaces/deploy | Deployment manifests and documentation |
Apache License 2.0