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 0d84948
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 2,705 deletions.
57 changes: 42 additions & 15 deletions controllers/devbox/api/v1alpha1/devbox_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,51 @@ 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
Type NetworkType `json:"type"`
}

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
ExtraPorts []corev1.ContainerPort `json:"extraPorts"`
VolumeMounts []corev1.VolumeMount `json:"volumeMounts,omitempty"`
// +kubebuilder:validation:Optional
Volumes []corev1.Volume `json:"volumes,omitempty"`
}

// DevboxSpec defines the desired state of Devbox
Expand All @@ -81,13 +113,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,8 +202,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"
// +kubebuilder:printcolumn:name="Phase",type="string",JSONPath=".status.phase"
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 0d84948

Please sign in to comment.