Skip to content

Commit

Permalink
step2: change pod create logic from devbox config.
Browse files Browse the repository at this point in the history
  • Loading branch information
lingdie committed Nov 13, 2024
1 parent fae93d8 commit 0f32acf
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 2,656 deletions.
56 changes: 43 additions & 13 deletions controllers/devbox/api/v1alpha1/devbox_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,6 @@ const (

type ResourceList map[ResourceName]resource.Quantity

type RuntimeRef struct {
// +kubebuilder:validation:Required
Name string `json:"name"`
// +kubebuilder:validation:Optional
Namespace string `json:"namespace,omitempty"`
}

type NetworkSpec struct {
// +kubebuilder:validation:Required
// +kubebuilder:validation:Enum=NodePort;Tailnet
Expand All @@ -69,6 +62,47 @@ type NetworkSpec struct {
ExtraPorts []corev1.ContainerPort `json:"extraPorts"`
}

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

// +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
// +kubebuilder:default=/home/sealos/project
WorkingDir string `json:"workingDir,omitempty"`
// +kubebuilder:validation:Optional
Env []corev1.EnvVar `json:"env,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:default={/bin/bash,-c}
ReleaseCommand []string `json:"releaseCommand,omitempty"`
// +kubebuilder:validation:Optional
// +kubebuilder:default={/home/sealos/project/entrypoint.sh}
ReleaseArgs []string `json:"releaseArgs,omitempty"`

// TODO: in v1alpha2 api we need fix the port and app port into one field and create a new type for it.
// +kubebuilder:validation:Optional
// +kubebuilder:default={{name:"devbox-ssh-port",containerPort:22,protocol:TCP}}
Ports []corev1.ContainerPort `json:"ports,omitempty"`
// +kubebuilder:validation:Optional
// +kubebuilder:default={{name:"devbox-app-port",port:8080,protocol:TCP}}
AppPorts []corev1.ServicePort `json:"appPorts,omitempty"`

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

// DevboxSpec defines the desired state of Devbox
type DevboxSpec struct {
// +kubebuilder:validation:Required
Expand All @@ -81,13 +115,10 @@ type DevboxSpec struct {
// +kubebuilder:default=false
Squash bool `json:"squash"`

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

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

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

// +kubebuilder:validation:Required
Expand Down Expand Up @@ -173,7 +204,6 @@ type DevboxStatus struct {
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="State",type="string",JSONPath=".spec.state"
// +kubebuilder:printcolumn:name="RuntimeRef",type="string",JSONPath=".spec.runtimeRef.name"
// +kubebuilder:printcolumn:name="PodPhase",type="string",JSONPath=".status.podPhase"
// +kubebuilder:printcolumn:name="NetworkType",type="string",JSONPath=".status.network.type"
// +kubebuilder:printcolumn:name="NodePort",type="integer",JSONPath=".status.network.nodePort"
Expand Down
140 changes: 0 additions & 140 deletions controllers/devbox/api/v1alpha1/runtime_types.go

This file was deleted.

71 changes: 0 additions & 71 deletions controllers/devbox/api/v1alpha1/runtimeclass_types.go

This file was deleted.

Loading

0 comments on commit 0f32acf

Please sign in to comment.