Skip to content

Commit

Permalink
add extraEnv toleration affinity
Browse files Browse the repository at this point in the history
  • Loading branch information
bearslyricattack committed Sep 2, 2024
1 parent 69ba3fd commit dd165fc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
16 changes: 16 additions & 0 deletions controllers/devbox/api/v1alpha1/devbox_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ type NetworkSpec struct {
ExtraPorts []corev1.ContainerPort `json:"extraPorts"`
}

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
}

// DevboxSpec defines the desired state of Devbox
type DevboxSpec struct {
// +kubebuilder:validation:Required
Expand All @@ -78,6 +90,10 @@ type DevboxSpec struct {
RuntimeRef RuntimeRef `json:"runtimeRef"`
// +kubebuilder:validation:Required
NetworkSpec NetworkSpec `json:"network"`
// +kubebuilder:validation:Optional
RunSpec RunSpec `json:"run"`
// +kubebuilder:validation:Optional
ScheduleSpec ScheduleSpec `json:"schedule"`
}

type NetworkStatus struct {
Expand Down
4 changes: 3 additions & 1 deletion controllers/devbox/internal/controller/devbox_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ func (r *DevboxReconciler) generateDevboxPod(ctx context.Context, devbox *devbox
},
},
}

envs = append(envs, devbox.Spec.RunSpec.Env...)
//get image name
imageName, err := r.getLastSuccessCommitImageName(ctx, devbox)
if err != nil {
Expand Down Expand Up @@ -445,6 +445,8 @@ func (r *DevboxReconciler) generateDevboxPod(ctx context.Context, devbox *devbox
Volumes: volume,
TerminationGracePeriodSeconds: ptr.To(int64(terminationGracePeriodSeconds)),
AutomountServiceAccountToken: ptr.To(automountServiceAccountToken),
Tolerations: devbox.Spec.ScheduleSpec.Tolerations,
Affinity: &devbox.Spec.ScheduleSpec.Affinity,
},
}
if err = controllerutil.SetControllerReference(devbox, expectPod, r.Scheme); err != nil {
Expand Down

0 comments on commit dd165fc

Please sign in to comment.