-
Notifications
You must be signed in to change notification settings - Fork 865
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade template out from extension of Definition Spec #976
Comments
@wonderflow still have several issues, for example, there will be more module types soon, your design should be extensible enough to avoid breaking change in the future. One option: apiVersion: core.oam.dev/v1alpha2
kind: WorkloadDefinition
metadata:
name: worker
annotations:
definition.oam.dev/description: "Long-running scalable backend worker without network endpoint"
spec:
definitionRef: # this also means you can directly use CRD as a "module"
apiVersion: apps/v1
kind: Deployment
module:
cue:
template: |
output: {
apiVersion: "apps/v1"
kind: "Deployment"
spec: {
selector: matchLabels: {
"app.oam.dev/component": context.name
}
template: {
metadata: labels: {
"app.oam.dev/component": context.name
}
spec: {
containers: [{
name: context.name
image: parameter.image
if parameter["cmd"] != _|_ {
command: parameter.cmd
}
}]
}
}
selector:
matchLabels:
"app.oam.dev/component": context.name
}
}
parameter: {
// +usage=Which image would you like to use for your service
// +short=i
image: string
cmd?: [...string]
}
helm:
# helm specific fields
terraform:
# terraform hcl specific fields
json-schema:
# plain json-schema
raw-resource:
# old school cr template + parameter |
@resouer helm , terraform and json-schema can have new field with template, for example:
|
@wonderflow it doesn't make sense to me ... what is the type of template field then? Also, cue, helm chart, terraform etc are modules rather than templates. It's a good timing to fix this name. |
Split current WorkloadDefinition into two parts:
and
|
@wonderflow, I am in favor of having We can generate For example: # mutable
apiVersion: core.oam.dev/v1alpha2
kind: ComponentDefinition
metadata:
name: worker
annotations:
definition.oam.dev/description: "Long-running scalable backend worker without network endpoint"
spec:
definitionRef:
apiVersion: apps/v1
kind: Deployment
module:
cue:
# template data
# other per ComponentDefinition fields ...
status:
currentWorkloadDefRevision: deployments.apps It will generate immutable # latest immutable workload type object
apiVersion: core.oam.dev/v1alpha2
kind: WorkloadDefinition
metadata:
name: deployments.apps # this name is generated from ComponentDefinition.definitionRef
spec:
definitionRef:
apiVersion: apps/v1
kind: Deployment
module:
cue:
# template data of latest revision
---
# history immutable workload type object
apiVersion: core.oam.dev/v1alpha2
kind: WorkloadDefinition
metadata:
name: deployments.apps-v1-{timestamp} # this name is generated from ComponentDefinition.definitionRef
spec:
definitionRef:
apiVersion: apps/v1
kind: Deployment
module:
cue:
# template data of {timestamp} revision /cc @ryanzhang-oss, please review if this solves your request for #1064
|
I love this idea |
@wonderflow I updated the design a bit, because I think in implementation we should ensure the latest workload def always have a fixed name (e.g. deployments.apps), this is the key for workload type discovery. |
will align with oam-dev/spec#443 |
Before:
After:
The text was updated successfully, but these errors were encountered: