Comments (10)
I suggest to use a new workload to fit other K8s resource ,for example , use Job Workload to represent K8s Job:
apiVersion: core.oam.dev/v1alpha2
kind: Component
metadata:
name: ai-job
annotations:
version: v1.0.0
description: "A Job"
spec:
workload:
apiVersion: batch/v1
kind: Job
spec:
template:
spec:
containers:
- name: pi
image: perl
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
from oam-kubernetes-runtime.
What @allenhaozi suggests in this issue is also a way that let core workload(containerized workload) to cover more scenarios. This is also one of advantages in OAM v1alpha1, that we define 6 core workload types (Server/Task/Worker and their singletons).
In v1alpha2, we enable more extendibility but can't ignore the standard parts.
Another option is to add batch/v1.Job and some of other native workloads to OAM core workload.
from oam-kubernetes-runtime.
@allenhaozi Thank you for raising the issue.
Here is our current thinking
- We should add more types of core/standard workloads. The general rule of thumb is that if two workloads require very different specs (ie. Job vs deployment) then they are probably two different types of workloads
- To address the problem of the lack of Server/Worker/Singletons in v1alpha2 spec vs. v1alpha1. We proposed to add "policy" to a component to express runtime characteristics/requirements of this component. Please see the issue in OAM spec for a detailed explanation.
from oam-kubernetes-runtime.
I think what @allenhaozi needs is a way that can distinguish different K8s native workloads from containerized workload.
Now containerizedWorkload is translated to K8s Deployment by default, but in fact, K8s Job, Statefulset and some other native workloads are all containerized. We don't have such mechanism to let user choose.
from oam-kubernetes-runtime.
What @allenhaozi suggests in this issue is also a way that let core workload(containerized workload) to cover more scenarios. This is also one of advantages in OAM v1alpha1, that we define 6 core workload types (Server/Task/Worker and their singletons).
In v1alpha2, we enable more extendibility but can't ignore the standard parts.
Another option is to add batch/v1.Job and some of other native workloads to OAM core workload.
Yes, this is what I want to express, looking forward to a powerful OAM core workload
from oam-kubernetes-runtime.
@allenhaozi Can this conclusion solve your issue? By the way, which kind of policy way do you prefer?
from oam-kubernetes-runtime.
@allenhaozi Can this conclusion solve your issue? By the way, which kind of policy way do you prefer?
Yes, policy can cover my case,
Internally, I implemented two workloads, ServerWorkload
and TaskWorkload
// ServerWorkloadSpec defines the desired state of ServerWorkload
type ServerWorkloadSpec 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"`
// WorkLoadSubType required by this workload.
// +kubebuilder:validation:Enum=server;statefulset;daemonset
// +optional
WorkloadSubType register.WorkloadSubType `json:"subType,omitempty"`
// ReplicaCount required by this workload.
// +optional
ReplicaCount int32 `json:"replicaCount"`
// Containers of which this workload consists.
Containers []oamcorev1alpha2.Container `json:"containers"`
}
// TaskWorkloadSpec defines the desired state of TaskWorkload
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"`
}
ServerWorkload for online, TaskWorkload for offline
I am validating these two workloads
from oam-kubernetes-runtime.
Here is the policy design #33
from oam-kubernetes-runtime.
Yes, policy can cover my case,
Internally, I implemented two workloads,ServerWorkload
andTaskWorkload
I think we don't really need ServerWorkload
, the policy #33 design has an example of how to create an workload that is internet accessible. We will also introduce a ServiceTrait
which will create a Service
that applies to a certain workload
.
As for TaskWorkload
, it seems that it's mostly a copy of K8s Job
object. We actually does support user bring in native K8s resources directly to OAM via workloadDefinition
. I wonder if you see any advantage of using the TaskWorkload
instead of a native K8s Job?
from oam-kubernetes-runtime.
@allenhaozi Hi, it seems community is really interested in this feature, so we create a new issue to track it: #211
Feel free to comment/input there! Could you please close this one because of duplication?
from oam-kubernetes-runtime.
Related Issues (20)
- [BUG] 【containerized workload】 Updating the trait of application will result in all workload rebuilding HOT 2
- [BUG]Two examples of oam: flight-tracker and dependency do not authorize oam's permissions to crd, so the example will not run. HOT 2
- Trait apply should use update instead of patch HOT 27
- [Feature] Support Namespaced Scope for Defintion
- [Feature] support don't reconcile if AppConfig or Component not updated HOT 1
- observedGeneration in Component and ControllerRevision should be equal [BUG]
- Should not update workload if only revisionEnabled trait was added first time HOT 1
- [Feature] make development log setting as an argument HOT 2
- [Feature] ContainerConfigFile support subPath HOT 4
- [Feature] Add Helm chart for K8s version < 1.16 HOT 1
- [Feature] scope should include all workload instance with versioning mechanism HOT 1
- [BUG] trait CR label will be override when more than two traits exist
- [Feature] using trait type instead of hardcode word 'trait' to create trait CR HOT 2
- [BUG] not convenient to debug e2e-test locally
- [Feature] Make local development more enjoyable HOT 2
- In ScopeRef it seems like Kind and Name cause for too much configuration, name should be replaced with properties HOT 2
- [Feature] Support ALL oam-kubernetes-runtime feature in KubeVela HOT 2
- once component set command, can't remove.
- Support complex/object data type for parameterValues in ApplicationConfiguration HOT 2
- [BUG] delete component and modify appConfig's components to null array lead to panic
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oam-kubernetes-runtime.