Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
d0213f5
feat: devbox daemon controller, devbox state change handler
lingdie Jul 19, 2025
05b0218
cotainer commit (#38)
Zllinc Jul 28, 2025
1a1d5fb
fix committer init
lingdie Jul 29, 2025
8a8043e
Add acceptance scoring for devbox scheduling (#39)
dinoallo Jul 29, 2025
18fa790
add log for score
lingdie Jul 29, 2025
c5970aa
Add NodeStatsProvider to Devbox controller and enhance error handling…
dinoallo Jul 30, 2025
b2a3f32
add node rbac
lingdie Jul 30, 2025
c59c7d2
Increase some example values and refactor some types (#43)
dinoallo Jul 30, 2025
c4c4336
fix
lingdie Jul 30, 2025
86c5ddc
Minor fixes for acceptance scoring (#44)
dinoallo Jul 31, 2025
220bc00
fix snapshot error
Zllinc Aug 1, 2025
bd176bc
Add PodNodeNameIndex constant and refactor CPU/Memory ratio functions…
dinoallo Aug 1, 2025
a800c40
gRPC reconnect and fix container name err (#49)
Zllinc Aug 1, 2025
4091d76
Add push image function (#50)
Zllinc Aug 5, 2025
cbb7e1a
fix registry
lingdie Aug 6, 2025
9dc652b
update snapshot (#52)
luanshaotong Aug 7, 2025
0e215ed
delete pod when pod failed
lingdie Aug 11, 2025
54f0f5d
Gc fix (#53)
Zllinc Aug 11, 2025
6337c8f
fix containerd errdefs
lingdie Aug 11, 2025
d71e3d5
fix content id error
lingdie Aug 13, 2025
66eca82
add pod annotation (#55)
Zllinc Aug 15, 2025
2a9a543
add committing status
lingdie Aug 19, 2025
d46401a
update go mod
lingdie Aug 20, 2025
b44b21a
chanage api to v1alpha2
lingdie Aug 21, 2025
87ec9bc
chanage api to v1alpha2
lingdie Aug 21, 2025
c5259c5
Add remove check and fix container name error (#56)
Zllinc Aug 21, 2025
bb5eacd
add ports
lingdie Aug 21, 2025
709e45f
devbox v1alpha2
lingdie Aug 22, 2025
7ff4b4c
devbox release define
lingdie Aug 22, 2025
9f1e167
devbox release impl, retag refactor
lingdie Aug 26, 2025
819ae02
fix target state change
lingdie Aug 27, 2025
7ae4c04
add print and fix logic
lingdie Aug 29, 2025
7e5bb58
fix release controller
lingdie Aug 29, 2025
448c5b0
fix status update when commit
lingdie Sep 2, 2025
be6c2a1
add last container status
lingdie Sep 2, 2025
87b1c27
add error handling for event processing and pod deletion
dinoallo Sep 5, 2025
91388d7
handler fix (#60)
Zllinc Sep 5, 2025
5876514
fix(commit): remove lv during delete devbox (#63)
Zllinc Sep 10, 2025
8a76747
fix devboxrelease type (#65)
lingdie Sep 10, 2025
0bdc308
improve devbox event handler. (#66)
lingdie Sep 12, 2025
461842e
add start config in devbox release (#67)
lingdie Sep 12, 2025
a04cc89
add login action when new committer (#68)
lingdie Sep 16, 2025
2ae4f9b
fix(commit): close image layer merge operation (#69)
Zllinc Sep 23, 2025
22940b8
add commit time logs
lingdie Oct 10, 2025
5f6d74d
fix controller ref for secret
lingdie Oct 16, 2025
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
4 changes: 2 additions & 2 deletions controllers/devbox/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ IMG ?= ghcr.io/labring/sealos-devbox-controller:latest
TARGETARCH ?= amd64

# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.24.1
ENVTEST_K8S_VERSION = 1.28.0

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand Down Expand Up @@ -127,7 +127,7 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest

## Tool Versions
KUSTOMIZE_VERSION ?= v5.3.0
CONTROLLER_TOOLS_VERSION ?= v0.14.0
CONTROLLER_TOOLS_VERSION ?= v0.18.0

KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
.PHONY: kustomize
Expand Down
32 changes: 8 additions & 24 deletions controllers/devbox/PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,24 @@ resources:
domain: sealos.io
group: devbox
kind: Devbox
path: github.com/labring/sealos/controllers/devbox/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
domain: sealos.io
group: devbox
kind: Runtime
path: github.com/labring/sealos/controllers/devbox/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
domain: sealos.io
group: devbox
kind: RuntimeClass
path: github.com/labring/sealos/controllers/devbox/api/v1alpha1
version: v1alpha1
path: github.com/labring/sealos/controllers/devbox/api/v1alpha2
version: v1alpha2
- api:
crdVersion: v1
namespaced: true
controller: true
domain: sealos.io
group: devbox
kind: DevBoxRelease
path: github.com/labring/sealos/controllers/devbox/api/v1alpha1
version: v1alpha1
kind: DevBoxReleases
path: github.com/labring/sealos/controllers/devbox/api/v1alpha2
version: v1alpha2
- api:
crdVersion: v1
namespaced: true
controller: true
domain: sealos.io
group: devbox
kind: OperationRequest
path: github.com/labring/sealos/controllers/devbox/api/v1alpha1
version: v1alpha1
kind: DevBoxRelease
path: github.com/labring/sealos/controllers/devbox/api/v1alpha2
version: v1alpha2
version: "3"
61 changes: 0 additions & 61 deletions controllers/devbox/api/v1alpha1/operationrequest_types.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1
package v1alpha2

import (
corev1 "k8s.io/api/core/v1"
Expand All @@ -24,7 +24,26 @@ import (
const (
// FinalizerName is the finalizer for Devbox
FinalizerName = "devbox.sealos.io/finalizer"
DevBoxPartOf = "devbox"

// Annotate the devbox pod with the devbox init
AnnotationInit = "devbox.sealos.io/init"
// Annotate the devbox pod with the storage limit
AnnotationStorageLimit = "devbox.sealos.io/storage-limit"
// Annotate the devbox pod with the devbox part of
AnnotationContentID = "devbox.sealos.io/content-id"
// Annotate the devbox node with container filesystem threshold
AnnotationContainerFSAvailableThreshold = "devbox.sealos.io/container-fs-available-threshold"
// Annotate the devbox node with cpu request and limit ratio
AnnotationCPURequestRatio = "devbox.sealos.io/cpu-request-ratio"
AnnotationCPULimitRatio = "devbox.sealos.io/cpu-limit-ratio"
// Annotate the devbox node with memory request and limit ratio
AnnotationMemoryRequestRatio = "devbox.sealos.io/memory-request-ratio"
AnnotationMemoryLimitRatio = "devbox.sealos.io/memory-limit-ratio"

// Label the devbox pod with the devbox part of
LabelDevBoxPartOf = "devbox"
// Index for pod node name
PodNodeNameIndex = "spec.nodeName"
)

type DevboxState string
Expand All @@ -34,9 +53,11 @@ const (
DevboxStateRunning DevboxState = "Running"
// DevboxStatePending means the Devbox is pending
DevboxStatePending DevboxState = "Pending"
// DevboxStateStopped means the Devbox is stopped
// DevboxStatePaused means the Devbox is paused, pod will be released but content lv and nodeport service will be retained
DevboxStatePaused DevboxState = "Paused"
// DevboxStateStopped means the Devbox is stopped, pod and content lv will be released but nodeport service will be retained
DevboxStateStopped DevboxState = "Stopped"
// DevboxStateShutdown means the devbox is shutdown
// DevboxStateShutdown means the devbox is shutdown, pod, content lv and nodeport service will be released
DevboxStateShutdown DevboxState = "Shutdown"
)

Expand All @@ -59,7 +80,7 @@ type NetworkSpec struct {
// +kubebuilder:validation:Enum=NodePort;Tailnet
Type NetworkType `json:"type"`
// +kubebuilder:validation:Optional
ExtraPorts []corev1.ContainerPort `json:"extraPorts"`
ExtraPorts []corev1.ContainerPort `json:"extraPorts,omitempty"`
}

type Config struct {
Expand Down Expand Up @@ -106,15 +127,12 @@ type Config struct {
// DevboxSpec defines the desired state of Devbox
type DevboxSpec struct {
// +kubebuilder:validation:Required
// +kubebuilder:validation:Enum=Running;Stopped;Shutdown
// +kubebuilder:validation:Enum=Running;Paused;Stopped;Shutdown
// +kubebuilder:default=Running
State DevboxState `json:"state"`
// +kubebuilder:validation:Required
Resource corev1.ResourceList `json:"resource"`

// +kubebuilder:validation:Optional
// +kubebuilder:default=false
Squash bool `json:"squash"`

// +kubebuilder:validation:Required
Image string `json:"image"`

Expand All @@ -124,6 +142,10 @@ type DevboxSpec struct {
// +kubebuilder:validation:Required
Config Config `json:"config"`

// +kubebuilder:validation:Optional
// devbox storage limit, `storageLimit` will be used to generate the devbox pod label.
StorageLimit string `json:"storageLimit,omitempty"`

// +kubebuilder:validation:Required
NetworkSpec NetworkSpec `json:"network,omitempty"`

Expand Down Expand Up @@ -153,36 +175,23 @@ type NetworkStatus struct {
type CommitStatus string

const (
CommitStatusSuccess CommitStatus = "Success"
CommitStatusFailed CommitStatus = "Failed"
CommitStatusUnknown CommitStatus = "Unknown"
CommitStatusPending CommitStatus = "Pending"
CommitStatusSuccess CommitStatus = "Success"
CommitStatusFailed CommitStatus = "Failed"
CommitStatusPending CommitStatus = "Pending"
CommitStatusCommitting CommitStatus = "Committing"
)

type CommitHistory struct {
// Image is the image of the commit
Image string `json:"image"`
// Time is the time when the commit is created
Time metav1.Time `json:"time"`
// Pod is the pod name
Pod string `json:"pod"`
// status will be set based on expectedStatus after devbox pod delete or stop. if expectedStatus is still pending, it means the pod is not running successfully, so we need to set it to `failed`
Status CommitStatus `json:"status"`
// predicatedStatus default `pending`, will be set to `success` if pod status is running successfully.
PredicatedStatus CommitStatus `json:"predicatedStatus"`
// Node is the node name
Node string `json:"node"`
// ContainerID is the container id
ContainerID string `json:"containerID"`
}

type DevboxPhase string

const (
// DevboxPhaseRunning means Devbox is run and run success
DevboxPhaseRunning DevboxPhase = "Running"
// DevboxPhasePending means Devbox is run but not run success
DevboxPhasePending DevboxPhase = "Pending"
// DevboxPhasePaused means Devbox is paused and paused success
DevboxPhasePaused DevboxPhase = "Paused"
// DevboxPhasePausing means Devbox is pausing
DevboxPhasePausing DevboxPhase = "Pausing"
//DevboxPhaseStopped means Devbox is stop and stopped success
DevboxPhaseStopped DevboxPhase = "Stopped"
//DevboxPhaseStopping means Devbox is stopping
Expand All @@ -197,19 +206,62 @@ const (
DevboxPhaseUnknown DevboxPhase = "Unknown"
)

type CommitRecord struct {
// BaseImage is the image of the that devbox is running on
// +kubebuilder:validation:Optional
BaseImage string `json:"baseImage"`

// CommitImage is the image of the that devbox is committed to
// +kubebuilder:validation:Optional
CommitImage string `json:"commitImage"`

// Node is the node name
// +kubebuilder:validation:Optional
Node string `json:"node"`

// GenerateTime is the time when the commit is generated
// +kubebuilder:validation:Optional
GenerateTime metav1.Time `json:"generateTime"`

// ScheduleTime is the time when the commit is scheduled
// +kubebuilder:validation:Optional
ScheduleTime metav1.Time `json:"scheduleTime"`

// UpdateTime is the time when the commit is updated
// +kubebuilder:validation:Optional
UpdateTime metav1.Time `json:"updateTime"`

// CommitTime is the time when the commit is created
// +kubebuilder:validation:Optional
CommitTime metav1.Time `json:"commitTime"`

// CommitStatus is the status of the commit
// +kubebuilder:validation:Enum=Success;Failed;Pending;Committing
// +kubebuilder:default=Pending
CommitStatus CommitStatus `json:"commitStatus"`
}

// CommitRecordMap is a map of commit records, key is the commit id
type CommitRecordMap map[string]*CommitRecord

// DevboxStatus defines the observed state of Devbox
type DevboxStatus struct {
// +kubebuilder:validation:Optional
Network NetworkStatus `json:"network"`
ContentID string `json:"contentID"`
// +kubebuilder:validation:Optional
CommitHistory []*CommitHistory `json:"commitHistory"`
Node string `json:"node"`
// +kubebuilder:validation:Optional
// +kubebuilder:default=Running
State DevboxState `json:"state"`
// CommitRecords is the records of the devbox commits
CommitRecords CommitRecordMap `json:"commitRecords"`
// +kubebuilder:validation:Optional
Phase DevboxPhase `json:"phase"`

// +kubebuilder:validation:Optional
State corev1.ContainerState `json:"state"`
Network NetworkStatus `json:"network"`

// +kubebuilder:validation:Optional
LastTerminationState corev1.ContainerState `json:"lastState"`
LastContainerStatus corev1.ContainerStatus `json:"lastContainerStatus"`
}

// +kubebuilder:object:root=true
Expand All @@ -218,9 +270,11 @@ type DevboxStatus struct {
// +kubebuilder:printcolumn:name="NetworkType",type="string",JSONPath=".status.network.type"
// +kubebuilder:printcolumn:name="NodePort",type="integer",JSONPath=".status.network.nodePort"
// +kubebuilder:printcolumn:name="Phase",type="string",JSONPath=".status.phase"
// +kubebuilder:printcolumn:name="Node",type="string",JSONPath=".status.node"

// Devbox is the Schema for the devboxes API
type Devbox struct {
// +kubebuilder:validation:XValidation:rule="self.spec.state == oldSelf.spec.state || (self.status.contentID in self.status.commitRecords && self.status.commitRecords[self.status.contentID].commitStatus != 'Committing')"
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Expand Down
Loading
Loading