crossplane / oam-kubernetes-runtime

A set of libraries for building OAM runtimes
Apache License 2.0
278 stars 80 forks source link

Support Cron Trait #60

Open wonderflow opened 4 years ago

wonderflow commented 4 years ago

We used to discuss it in Rudr https://github.com/oam-dev/rudr/issues/40 I think this is really a common trait which can be core/standard trait candidate.

This is an issue from https://github.com/crossplane/addon-oam-kubernetes-local/issues/13.

We'll continue discuss here.

negz commented 4 years ago

Per https://github.com/crossplane/oam-kubernetes-runtime/issues/55 we're centralising all things OAM into one repo, and oam-kubernetes-runtime seems like the most likely place. I'm going to move this issue there.

allenhaozi commented 4 years ago

Internally we are discussing how to support Job, CronJob based on Workload and trait design, The current conclusion is that we prefer to use workload support to pull up a Job or CronJob rather than a trait

The Spec :

type TaskWorkloadSpec struct {
    // OperatingSystem required by this workload.
    // +kubebuilder:validation:Enum=linux;windows
    // +optional
    OperatingSystem *oamcorev1alpha2.OperatingSystem `json:"osType,omitempty"`

    // CPUArchitecture required by this workload.
    // +kubebuilder:validation:Enum=i386;amd64;arm;arm64
    // +optional
    CPUArchitecture *oamcorev1alpha2.CPUArchitecture `json:"arch,omitempty"`

    // Specifies the maximum desired number of pods the job should
    // run at any given time. The actual number of pods running in steady state will
    // be less than this number when ((.spec.completions - .status.successful) < .spec.parallelism),
    // i.e. when the work left to do is less than max parallelism.
    // More info: https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/
    // +optional
    Parallelism *int32 `json:"parallelism,omitempty"`

    // Specifies the desired number of successfully finished pods the
    // job should be run with.  Setting to nil means that the success of any
    // pod signals the success of all pods, and allows parallelism to have any positive
    // value.  Setting to 1 means that parallelism is limited to 1 and the success of that
    // pod signals the success of the job.
    // More info: https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/
    // +optional
    Completions *int32 `json:"completions,omitempty"`

    // The schedule in Cron format, see https://en.wikipedia.org/wiki/Cron.
    // +kubebuilder:validation:MinLength=0
    // +optional
    Schedule string `json:"schedule,omitempty"`

    // Containers of which this workload consists.
    Containers []oamcorev1alpha2.Container `json:"containers"`

        // initContainers
    // +optional
    InitContainers []oamcorev1alpha2.Container `json:"initContainers,omitempty"`

    // dns policy
    // +optional
    DNSPolicy corev1.DNSPolicy `json:"dnsPolicy,omitempty"`

    // node selector
    // +optional
    NodeSelector map[string]string `json:"nodeSelector,omitempty"`
}

cc @wonderflow

wonderflow commented 4 years ago

Cool, would you like to contribute these workload into our catalog?