mirror of
https://github.com/kubevela/kubevela.git
synced 2026-05-06 01:17:09 +00:00
41 lines
1017 B
YAML
41 lines
1017 B
YAML
apiVersion: core.oam.dev/v1alpha2
|
|
kind: TraitDefinition
|
|
metadata:
|
|
annotations:
|
|
definition.oam.dev/description: "affinity specify node affinity and toleration"
|
|
name: node-affinity
|
|
spec:
|
|
appliesToWorkloads:
|
|
- webservice
|
|
- worker
|
|
extension:
|
|
template: |-
|
|
patch: {
|
|
spec: template: spec: {
|
|
if parameter.affinity != _|_ {
|
|
affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: [{
|
|
matchExpressions: [
|
|
for k, v in parameter.affinity {
|
|
key: k
|
|
operator: "In"
|
|
values: v
|
|
},
|
|
]}]
|
|
}
|
|
if parameter.tolerations != _|_ {
|
|
tolerations: [
|
|
for k, v in parameter.tolerations {
|
|
effect: "NoSchedule"
|
|
key: k
|
|
operator: "Equal"
|
|
value: v
|
|
}]
|
|
}
|
|
}
|
|
}
|
|
|
|
parameter: {
|
|
affinity?: [string]: [...string]
|
|
tolerations?: [string]: string
|
|
}
|