Skip to content

Commit

Permalink
change runtime and runtime class to namespace scope, improve devbox c… (
Browse files Browse the repository at this point in the history
labring#5024)

* change runtime and runtime class to namespace scope, improve devbox create logic, add container configs to runtime and devbox crd.

* fix lint.

* fix format.

* fix deploy yaml.
  • Loading branch information
lingdie authored and zjy365 committed Sep 3, 2024
1 parent a0f40e0 commit 462d939
Show file tree
Hide file tree
Showing 13 changed files with 9,490 additions and 248 deletions.
43 changes: 29 additions & 14 deletions controllers/devbox/api/v1alpha1/devbox_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,6 @@ type RuntimeRef struct {
// +kubebuilder:validation:Required
Name string `json:"name"`
}
type RunSpec struct {
// +kubebuilder:validation:Optional
Env []corev1.EnvVar `json:"env"`
}

type ScheduleSpec struct {
// +kubebuilder:validation:Optional
Tolerations []corev1.Toleration
// +kubebuilder:validation:Optional
Affinity corev1.Affinity
}

type NetworkSpec struct {
// +kubebuilder:validation:Required
Expand All @@ -82,17 +71,43 @@ type DevboxSpec struct {
State DevboxState `json:"state"`
// +kubebuilder:validation:Required
Resource ResourceList `json:"resource"`

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

// +kubebuilder:validation:Required
RuntimeRef RuntimeRef `json:"runtimeRef"`

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

// todo add rewrite labels and annotations...
// +kubebuilder:validation:Optional
ExtraLabels map[string]string `json:"extraLabels,omitempty"`
// +kubebuilder:validation:Optional
ExtraAnnotations map[string]string `json:"extraAnnotations,omitempty"`

// +kubebuilder:validation:Optional
Command []string `json:"command,omitempty"`
// +kubebuilder:validation:Optional
Args []string `json:"args,omitempty"`
// +kubebuilder:validation:Optional
WorkingDir string `json:"workingDir,omitempty"`
// todo add rewrite env...
// +kubebuilder:validation:Optional
ExtraEnvs []corev1.EnvVar `json:"extraEnvs"`

// todo add rewrite volumes and volume mounts..
// +kubebuilder:validation:Optional
ExtraVolumes []corev1.Volume `json:"extraVolumes,omitempty"`
// +kubebuilder:validation:Optional
ExtraVolumeMounts []corev1.VolumeMount `json:"extraVolumeMounts,omitempty"`

// +kubebuilder:validation:Optional
RunSpec RunSpec `json:"run"`
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
// +kubebuilder:validation:Optional
ScheduleSpec ScheduleSpec `json:"schedule"`
Affinity *corev1.Affinity `json:"affinity,omitempty"`
}

type NetworkStatus struct {
Expand Down
43 changes: 38 additions & 5 deletions controllers/devbox/api/v1alpha1/runtime_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,55 @@ limitations under the License.
package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type Config struct {
// +kubebuilder:validation:Optional
// +kubebuilder:default=sealos
User string `json:"user"`

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

// +kubebuilder:validation:Optional
Labels map[string]string `json:"labels,omitempty"`
// +kubebuilder:validation:Optional
Annotations map[string]string `json:"annotations,omitempty"`

// +kubebuilder:validation:Optional
Command []string `json:"command,omitempty"`
// kubebuilder:validation:Optional
Args []string `json:"args,omitempty"`
// +kubebuilder:validation:Optional
WorkingDir string `json:"workingDir,omitempty"`
// +kubebuilder:validation:Optional
Env []corev1.EnvVar `json:"env,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:default={{name:"devbox-ssh-port",containerPort:22,protocol:TCP}}
Ports []corev1.ContainerPort `json:"ports,omitempty"`

// +kubebuilder:validation:Optional
VolumeMounts []corev1.VolumeMount `json:"volumeMounts,omitempty"`
// +kubebuilder:validation:Optional
Volumes []corev1.Volume `json:"volumes,omitempty"`
}

// RuntimeSpec defines the desired state of Runtime
type RuntimeSpec struct {
// +kubebuilder:validation:Required
Title string `json:"title"`
// +kubebuilder:validation:Optional
Category []string `json:"category"`
Category []string `json:"category,omitempty"`
// +kubebuilder:validation:Required
ClassRef string `json:"classRef"`
// +kubebuilder:validation:Required
Image string `json:"image"`
// +kube:validation:Optional
Description string `json:"description"`
Description string `json:"description,omitempty"`

// +kubebuilder:validation:Required
Config Config `json:"config"`
}

// RuntimeStatus defines the observed state of Runtime
Expand All @@ -42,7 +76,6 @@ type RuntimeStatus struct {

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster

// Runtime is the Schema for the runtimes API
type Runtime struct {
Expand Down
1 change: 0 additions & 1 deletion controllers/devbox/api/v1alpha1/runtimeclass_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ type RuntimeClassStatus struct {

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster

// RuntimeClass is the Schema for the runtimeclasses API
type RuntimeClass struct {
Expand Down
123 changes: 123 additions & 0 deletions controllers/devbox/api/v1alpha1/zz_generated.deepcopy.go

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

Loading

0 comments on commit 462d939

Please sign in to comment.