Feat: add several policy definition (#4409)

Signed-off-by: Somefive <yd219913@alibaba-inc.com>
This commit is contained in:
Somefive 2022-07-19 15:47:01 +08:00 committed by GitHub
parent 16dfc1bf8a
commit fd784e291c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 249 additions and 0 deletions

View File

@ -0,0 +1,44 @@
# Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file.
# Definition source cue file: vela-templates/definitions/internal/apply-once.cue
apiVersion: core.oam.dev/v1beta1
kind: PolicyDefinition
metadata:
annotations:
definition.oam.dev/description: Configure the behaviour of preventing configuration drift.
name: apply-once
namespace: {{ include "systemDefinitionNamespace" . }}
spec:
schematic:
cue:
template: |
#ApplyOnceStrategy: {
// +usage=Specify the path of the resource that allow configuration drift
path: [...string]
}
#ApplyOncePolicyRule: {
// +usage=Specify how to select the targets of the rule
selector?: #ResourcePolicyRuleSelector
// +usage=Specify the strategy for configuring the resource level configuration drift behaviour
strategy: #ApplyOnceStrategy
}
#ResourcePolicyRuleSelector: {
// +usage=Select resources by component names
componentNames?: [...string]
// +usage=Select resources by component types
componentTypes?: [...string]
// +usage=Select resources by oamTypes (COMPONENT or TRAIT)
oamTypes?: [...string]
// +usage=Select resources by trait types
traitTypes?: [...string]
// +usage=Select resources by resource types (like Deployment)
resourceTypes?: [...string]
// +usage=Select resources by their names
resourceNames?: [...string]
}
parameter: {
// +usage=Whether to enable apply-once for the whole application
enable: *false | bool
// +usage=Specify the rules for configuring apply-once policy in resource level
rules?: [...#ApplyOncePolicyRule]
}

View File

@ -0,0 +1,40 @@
# Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file.
# Definition source cue file: vela-templates/definitions/internal/garbage-collect.cue
apiVersion: core.oam.dev/v1beta1
kind: PolicyDefinition
metadata:
annotations:
definition.oam.dev/description: Configure the garbage collect behaviour for the application.
name: garbage-collect
namespace: {{ include "systemDefinitionNamespace" . }}
spec:
schematic:
cue:
template: |
#GarbageCollectPolicyRule: {
// +usage=Specify how to select the targets of the rule
selector: [...#ResourcePolicyRuleSelector]
// +usage=Specify the strategy for target resource to recycle
strategy: *"onAppUpdate" | "onAppDelete" | "never"
}
#ResourcePolicyRuleSelector: {
// +usage=Select resources by component names
componentNames?: [...string]
// +usage=Select resources by component types
componentTypes?: [...string]
// +usage=Select resources by oamTypes (COMPONENT or TRAIT)
oamTypes?: [...string]
// +usage=Select resources by trait types
traitTypes?: [...string]
// +usage=Select resources by resource types (like Deployment)
resourceTypes?: [...string]
// +usage=Select resources by their names
resourceNames?: [...string]
}
parameter: {
// +usage=If is set, outdated versioned resourcetracker will not be recycled automatically, outdated resources will be kept until resourcetracker be deleted manually
keepLegacyResource: *false | bool
// +usage=Specify the list of rules to control gc strategy at resource level, if one resource is controlled by multiple rules, first rule will be used
rules?: [...#GarbageCollectPolicyRule]
}

View File

@ -0,0 +1,44 @@
# Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file.
# Definition source cue file: vela-templates/definitions/internal/apply-once.cue
apiVersion: core.oam.dev/v1beta1
kind: PolicyDefinition
metadata:
annotations:
definition.oam.dev/description: Configure the behaviour of preventing configuration drift.
name: apply-once
namespace: {{ include "systemDefinitionNamespace" . }}
spec:
schematic:
cue:
template: |
#ApplyOnceStrategy: {
// +usage=Specify the path of the resource that allow configuration drift
path: [...string]
}
#ApplyOncePolicyRule: {
// +usage=Specify how to select the targets of the rule
selector?: #ResourcePolicyRuleSelector
// +usage=Specify the strategy for configuring the resource level configuration drift behaviour
strategy: #ApplyOnceStrategy
}
#ResourcePolicyRuleSelector: {
// +usage=Select resources by component names
componentNames?: [...string]
// +usage=Select resources by component types
componentTypes?: [...string]
// +usage=Select resources by oamTypes (COMPONENT or TRAIT)
oamTypes?: [...string]
// +usage=Select resources by trait types
traitTypes?: [...string]
// +usage=Select resources by resource types (like Deployment)
resourceTypes?: [...string]
// +usage=Select resources by their names
resourceNames?: [...string]
}
parameter: {
// +usage=Whether to enable apply-once for the whole application
enable: *false | bool
// +usage=Specify the rules for configuring apply-once policy in resource level
rules?: [...#ApplyOncePolicyRule]
}

View File

@ -0,0 +1,40 @@
# Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file.
# Definition source cue file: vela-templates/definitions/internal/garbage-collect.cue
apiVersion: core.oam.dev/v1beta1
kind: PolicyDefinition
metadata:
annotations:
definition.oam.dev/description: Configure the garbage collect behaviour for the application.
name: garbage-collect
namespace: {{ include "systemDefinitionNamespace" . }}
spec:
schematic:
cue:
template: |
#GarbageCollectPolicyRule: {
// +usage=Specify how to select the targets of the rule
selector: [...#ResourcePolicyRuleSelector]
// +usage=Specify the strategy for target resource to recycle
strategy: *"onAppUpdate" | "onAppDelete" | "never"
}
#ResourcePolicyRuleSelector: {
// +usage=Select resources by component names
componentNames?: [...string]
// +usage=Select resources by component types
componentTypes?: [...string]
// +usage=Select resources by oamTypes (COMPONENT or TRAIT)
oamTypes?: [...string]
// +usage=Select resources by trait types
traitTypes?: [...string]
// +usage=Select resources by resource types (like Deployment)
resourceTypes?: [...string]
// +usage=Select resources by their names
resourceNames?: [...string]
}
parameter: {
// +usage=If is set, outdated versioned resourcetracker will not be recycled automatically, outdated resources will be kept until resourcetracker be deleted manually
keepLegacyResource: *false | bool
// +usage=Specify the list of rules to control gc strategy at resource level, if one resource is controlled by multiple rules, first rule will be used
rules?: [...#GarbageCollectPolicyRule]
}

View File

@ -0,0 +1,43 @@
"apply-once": {
annotations: {}
description: "Configure the behaviour of preventing configuration drift."
labels: {}
attributes: {}
type: "policy"
}
template: {
#ApplyOnceStrategy: {
// +usage=Specify the path of the resource that allow configuration drift
path: [...string]
}
#ApplyOncePolicyRule: {
// +usage=Specify how to select the targets of the rule
selector?: #ResourcePolicyRuleSelector
// +usage=Specify the strategy for configuring the resource level configuration drift behaviour
strategy: #ApplyOnceStrategy
}
#ResourcePolicyRuleSelector: {
// +usage=Select resources by component names
componentNames?: [...string]
// +usage=Select resources by component types
componentTypes?: [...string]
// +usage=Select resources by oamTypes (COMPONENT or TRAIT)
oamTypes?: [...string]
// +usage=Select resources by trait types
traitTypes?: [...string]
// +usage=Select resources by resource types (like Deployment)
resourceTypes?: [...string]
// +usage=Select resources by their names
resourceNames?: [...string]
}
parameter: {
// +usage=Whether to enable apply-once for the whole application
enable: *false | bool
// +usage=Specify the rules for configuring apply-once policy in resource level
rules?: [...#ApplyOncePolicyRule]
}
}

View File

@ -0,0 +1,38 @@
"garbage-collect": {
annotations: {}
description: "Configure the garbage collect behaviour for the application."
labels: {}
attributes: {}
type: "policy"
}
template: {
#GarbageCollectPolicyRule: {
// +usage=Specify how to select the targets of the rule
selector: [...#ResourcePolicyRuleSelector]
// +usage=Specify the strategy for target resource to recycle
strategy: *"onAppUpdate" | "onAppDelete" | "never"
}
#ResourcePolicyRuleSelector: {
// +usage=Select resources by component names
componentNames?: [...string]
// +usage=Select resources by component types
componentTypes?: [...string]
// +usage=Select resources by oamTypes (COMPONENT or TRAIT)
oamTypes?: [...string]
// +usage=Select resources by trait types
traitTypes?: [...string]
// +usage=Select resources by resource types (like Deployment)
resourceTypes?: [...string]
// +usage=Select resources by their names
resourceNames?: [...string]
}
parameter: {
// +usage=If is set, outdated versioned resourcetracker will not be recycled automatically, outdated resources will be kept until resourcetracker be deleted manually
keepLegacyResource: *false | bool
// +usage=Specify the list of rules to control gc strategy at resource level, if one resource is controlled by multiple rules, first rule will be used
rules?: [...#GarbageCollectPolicyRule]
}
}