diff --git a/apis/core.oam.dev/v1beta1/core_types.go b/apis/core.oam.dev/v1beta1/core_types.go index 82cbdde9b..84f547b2f 100644 --- a/apis/core.oam.dev/v1beta1/core_types.go +++ b/apis/core.oam.dev/v1beta1/core_types.go @@ -120,7 +120,7 @@ type TraitDefinitionSpec struct { PodDisruptive bool `json:"podDisruptive,omitempty"` // AppliesToWorkloads specifies the list of workload kinds this trait - // applies to. Workload kinds are specified in kind.group/version format, + // applies to. Workload kinds are specified in resource.group/version format, // e.g. server.core.oam.dev/v1alpha2. Traits that omit this field apply to // all workload kinds. // +optional diff --git a/charts/vela-core/crds/core.oam.dev_applicationrevisions.yaml b/charts/vela-core/crds/core.oam.dev_applicationrevisions.yaml index 1c92b99cf..09517866e 100644 --- a/charts/vela-core/crds/core.oam.dev_applicationrevisions.yaml +++ b/charts/vela-core/crds/core.oam.dev_applicationrevisions.yaml @@ -3650,7 +3650,7 @@ spec: appliesToWorkloads: description: AppliesToWorkloads specifies the list of workload kinds this trait applies to. Workload kinds are specified - in kind.group/version format, e.g. server.core.oam.dev/v1alpha2. + in resource.group/version format, e.g. server.core.oam.dev/v1alpha2. Traits that omit this field apply to all workload kinds. items: type: string diff --git a/charts/vela-core/crds/core.oam.dev_definitionrevisions.yaml b/charts/vela-core/crds/core.oam.dev_definitionrevisions.yaml index d1608bc82..b5c8b11e6 100644 --- a/charts/vela-core/crds/core.oam.dev_definitionrevisions.yaml +++ b/charts/vela-core/crds/core.oam.dev_definitionrevisions.yaml @@ -708,7 +708,7 @@ spec: appliesToWorkloads: description: AppliesToWorkloads specifies the list of workload kinds this trait applies to. Workload kinds are specified - in kind.group/version format, e.g. server.core.oam.dev/v1alpha2. + in resource.group/version format, e.g. server.core.oam.dev/v1alpha2. Traits that omit this field apply to all workload kinds. items: type: string diff --git a/charts/vela-core/crds/core.oam.dev_traitdefinitions.yaml b/charts/vela-core/crds/core.oam.dev_traitdefinitions.yaml index ff8b3c4e2..1ecdc5260 100644 --- a/charts/vela-core/crds/core.oam.dev_traitdefinitions.yaml +++ b/charts/vela-core/crds/core.oam.dev_traitdefinitions.yaml @@ -356,7 +356,7 @@ spec: properties: appliesToWorkloads: description: AppliesToWorkloads specifies the list of workload kinds - this trait applies to. Workload kinds are specified in kind.group/version + this trait applies to. Workload kinds are specified in resource.group/version format, e.g. server.core.oam.dev/v1alpha2. Traits that omit this field apply to all workload kinds. items: diff --git a/charts/vela-core/templates/defwithtemplate/affinity.yaml b/charts/vela-core/templates/defwithtemplate/affinity.yaml index 4a5790f56..3221d0347 100644 --- a/charts/vela-core/templates/defwithtemplate/affinity.yaml +++ b/charts/vela-core/templates/defwithtemplate/affinity.yaml @@ -11,7 +11,10 @@ metadata: namespace: {{ include "systemDefinitionNamespace" . }} spec: appliesToWorkloads: - - '*' + - deployments.apps + - statefulsets.apps + - daemonsets.apps + - jobs.batch podDisruptive: true schematic: cue: diff --git a/charts/vela-core/templates/defwithtemplate/annotations.yaml b/charts/vela-core/templates/defwithtemplate/annotations.yaml index 89d2a81b6..b39e984f4 100644 --- a/charts/vela-core/templates/defwithtemplate/annotations.yaml +++ b/charts/vela-core/templates/defwithtemplate/annotations.yaml @@ -4,7 +4,7 @@ apiVersion: core.oam.dev/v1beta1 kind: TraitDefinition metadata: annotations: - definition.oam.dev/description: Add annotations on K8s pod for your workload which follows the pod spec in path 'spec.template'. + definition.oam.dev/description: Add annotations on your workload. if it generates pod, add same annotations for generated pods. labels: custom.definition.oam.dev/ui-hidden: "true" name: annotations diff --git a/charts/vela-core/templates/defwithtemplate/command.yaml b/charts/vela-core/templates/defwithtemplate/command.yaml index 65697d700..ebaf7c882 100644 --- a/charts/vela-core/templates/defwithtemplate/command.yaml +++ b/charts/vela-core/templates/defwithtemplate/command.yaml @@ -11,7 +11,10 @@ metadata: namespace: {{ include "systemDefinitionNamespace" . }} spec: appliesToWorkloads: - - '*' + - deployments.apps + - statefulsets.apps + - daemonsets.apps + - jobs.batch schematic: cue: template: | diff --git a/charts/vela-core/templates/defwithtemplate/container-image.yaml b/charts/vela-core/templates/defwithtemplate/container-image.yaml index 9b5981260..c8dc22807 100644 --- a/charts/vela-core/templates/defwithtemplate/container-image.yaml +++ b/charts/vela-core/templates/defwithtemplate/container-image.yaml @@ -11,7 +11,10 @@ metadata: namespace: {{ include "systemDefinitionNamespace" . }} spec: appliesToWorkloads: - - '*' + - deployments.apps + - statefulsets.apps + - daemonsets.apps + - jobs.batch podDisruptive: true schematic: cue: diff --git a/charts/vela-core/templates/defwithtemplate/cpuscaler.yaml b/charts/vela-core/templates/defwithtemplate/cpuscaler.yaml index b9b1dcbae..30f6d73f5 100644 --- a/charts/vela-core/templates/defwithtemplate/cpuscaler.yaml +++ b/charts/vela-core/templates/defwithtemplate/cpuscaler.yaml @@ -12,6 +12,7 @@ metadata: spec: appliesToWorkloads: - deployments.apps + - statefulsets.apps schematic: cue: template: | diff --git a/charts/vela-core/templates/defwithtemplate/env.yaml b/charts/vela-core/templates/defwithtemplate/env.yaml index 8cba72f20..b30f4230e 100644 --- a/charts/vela-core/templates/defwithtemplate/env.yaml +++ b/charts/vela-core/templates/defwithtemplate/env.yaml @@ -11,7 +11,10 @@ metadata: namespace: {{ include "systemDefinitionNamespace" . }} spec: appliesToWorkloads: - - '*' + - deployments.apps + - statefulsets.apps + - daemonsets.apps + - jobs.batch schematic: cue: template: | diff --git a/charts/vela-core/templates/defwithtemplate/expose.yaml b/charts/vela-core/templates/defwithtemplate/expose.yaml index 677aacdf4..a36753eed 100644 --- a/charts/vela-core/templates/defwithtemplate/expose.yaml +++ b/charts/vela-core/templates/defwithtemplate/expose.yaml @@ -10,6 +10,9 @@ metadata: name: expose namespace: {{ include "systemDefinitionNamespace" . }} spec: + appliesToWorkloads: + - deployments.apps + - statefulsets.apps podDisruptive: false schematic: cue: diff --git a/charts/vela-core/templates/defwithtemplate/gateway.yaml b/charts/vela-core/templates/defwithtemplate/gateway.yaml index eceaba784..9576fd48c 100644 --- a/charts/vela-core/templates/defwithtemplate/gateway.yaml +++ b/charts/vela-core/templates/defwithtemplate/gateway.yaml @@ -9,7 +9,8 @@ metadata: namespace: {{ include "systemDefinitionNamespace" . }} spec: appliesToWorkloads: - - '*' + - deployments.apps + - statefulsets.apps podDisruptive: false schematic: cue: @@ -85,7 +86,7 @@ spec: // +usage=Set ingress class in '.spec.ingressClassName' instead of 'kubernetes.io/ingress.class' annotation. classInSpec: *false | bool - // +usage=Specify the secret name you want to quote. + // +usage=Specify the secret name you want to quote to use tls. secretName?: string // +usage=Specify the host of the ingress gateway, which is used to generate the endpoints when the host is empty. diff --git a/charts/vela-core/templates/defwithtemplate/hostalias.yaml b/charts/vela-core/templates/defwithtemplate/hostalias.yaml index 9b9c1782d..a28f41908 100644 --- a/charts/vela-core/templates/defwithtemplate/hostalias.yaml +++ b/charts/vela-core/templates/defwithtemplate/hostalias.yaml @@ -11,7 +11,10 @@ metadata: namespace: {{ include "systemDefinitionNamespace" . }} spec: appliesToWorkloads: - - '*' + - deployments.apps + - statefulsets.apps + - daemonsets.apps + - jobs.batch podDisruptive: false schematic: cue: diff --git a/charts/vela-core/templates/defwithtemplate/init-container.yaml b/charts/vela-core/templates/defwithtemplate/init-container.yaml index 4c5c3cfac..1a699d084 100644 --- a/charts/vela-core/templates/defwithtemplate/init-container.yaml +++ b/charts/vela-core/templates/defwithtemplate/init-container.yaml @@ -12,6 +12,9 @@ metadata: spec: appliesToWorkloads: - deployments.apps + - statefulsets.apps + - daemonsets.apps + - jobs.batch podDisruptive: true schematic: cue: diff --git a/charts/vela-core/templates/defwithtemplate/labels.yaml b/charts/vela-core/templates/defwithtemplate/labels.yaml index 745824cf4..50742ca52 100644 --- a/charts/vela-core/templates/defwithtemplate/labels.yaml +++ b/charts/vela-core/templates/defwithtemplate/labels.yaml @@ -4,7 +4,7 @@ apiVersion: core.oam.dev/v1beta1 kind: TraitDefinition metadata: annotations: - definition.oam.dev/description: Add labels on K8s pod for your workload which follows the pod spec in path 'spec.template'. + definition.oam.dev/description: Add labels on your workload. if it generates pod, add same label for generated pods. labels: custom.definition.oam.dev/ui-hidden: "true" name: labels diff --git a/charts/vela-core/templates/defwithtemplate/lifecycle.yaml b/charts/vela-core/templates/defwithtemplate/lifecycle.yaml index 3819ab880..6a8aec435 100644 --- a/charts/vela-core/templates/defwithtemplate/lifecycle.yaml +++ b/charts/vela-core/templates/defwithtemplate/lifecycle.yaml @@ -11,7 +11,10 @@ metadata: namespace: {{ include "systemDefinitionNamespace" . }} spec: appliesToWorkloads: - - '*' + - deployments.apps + - statefulsets.apps + - daemonsets.apps + - jobs.batch podDisruptive: true schematic: cue: diff --git a/charts/vela-core/templates/defwithtemplate/nocalhost.yaml b/charts/vela-core/templates/defwithtemplate/nocalhost.yaml index 64bde3427..a76e8f25d 100644 --- a/charts/vela-core/templates/defwithtemplate/nocalhost.yaml +++ b/charts/vela-core/templates/defwithtemplate/nocalhost.yaml @@ -11,7 +11,10 @@ metadata: namespace: {{ include "systemDefinitionNamespace" . }} spec: appliesToWorkloads: - - '*' + - deployments.apps + - statefulsets.apps + - daemonsets.apps + - jobs.batch podDisruptive: true schematic: cue: diff --git a/charts/vela-core/templates/defwithtemplate/pure-ingress.yaml b/charts/vela-core/templates/defwithtemplate/pure-ingress.yaml index 40d6972f3..55f680b34 100644 --- a/charts/vela-core/templates/defwithtemplate/pure-ingress.yaml +++ b/charts/vela-core/templates/defwithtemplate/pure-ingress.yaml @@ -6,11 +6,13 @@ metadata: annotations: definition.oam.dev/description: Enable public web traffic for the component without creating a Service. labels: + custom.definition.oam.dev/deprecated: "true" custom.definition.oam.dev/ui-hidden: "true" name: pure-ingress namespace: {{ include "systemDefinitionNamespace" . }} spec: - appliesToWorkloads: [] + appliesToWorkloads: + - '*' conflictsWith: [] podDisruptive: false schematic: diff --git a/charts/vela-core/templates/defwithtemplate/register-grafana-datasource.yaml b/charts/vela-core/templates/defwithtemplate/register-grafana-datasource.yaml index 98a59500b..c67e2815b 100644 --- a/charts/vela-core/templates/defwithtemplate/register-grafana-datasource.yaml +++ b/charts/vela-core/templates/defwithtemplate/register-grafana-datasource.yaml @@ -6,6 +6,7 @@ metadata: annotations: definition.oam.dev/description: Add a datasource to Grafana labels: + custom.definition.oam.dev/deprecated: "true" custom.definition.oam.dev/ui-hidden: "true" name: register-grafana-datasource namespace: {{ include "systemDefinitionNamespace" . }} diff --git a/charts/vela-core/templates/defwithtemplate/resource.yaml b/charts/vela-core/templates/defwithtemplate/resource.yaml index b66c2d907..dff9c731f 100644 --- a/charts/vela-core/templates/defwithtemplate/resource.yaml +++ b/charts/vela-core/templates/defwithtemplate/resource.yaml @@ -11,7 +11,10 @@ metadata: namespace: {{ include "systemDefinitionNamespace" . }} spec: appliesToWorkloads: - - '*' + - deployments.apps + - statefulsets.apps + - daemonsets.apps + - jobs.batch podDisruptive: true schematic: cue: diff --git a/charts/vela-core/templates/defwithtemplate/scaler.yaml b/charts/vela-core/templates/defwithtemplate/scaler.yaml index d65f1ee48..5d7aefe90 100644 --- a/charts/vela-core/templates/defwithtemplate/scaler.yaml +++ b/charts/vela-core/templates/defwithtemplate/scaler.yaml @@ -9,7 +9,8 @@ metadata: namespace: {{ include "systemDefinitionNamespace" . }} spec: appliesToWorkloads: - - '*' + - deployments.apps + - statefulsets.apps podDisruptive: false schematic: cue: diff --git a/charts/vela-core/templates/defwithtemplate/service-account.yaml b/charts/vela-core/templates/defwithtemplate/service-account.yaml index 5ece5975e..32d022ce8 100644 --- a/charts/vela-core/templates/defwithtemplate/service-account.yaml +++ b/charts/vela-core/templates/defwithtemplate/service-account.yaml @@ -9,7 +9,10 @@ metadata: namespace: {{ include "systemDefinitionNamespace" . }} spec: appliesToWorkloads: - - '*' + - deployments.apps + - statefulsets.apps + - daemonsets.apps + - jobs.batch podDisruptive: false schematic: cue: diff --git a/charts/vela-core/templates/defwithtemplate/service-binding.yaml b/charts/vela-core/templates/defwithtemplate/service-binding.yaml index 41913f558..e02438a77 100644 --- a/charts/vela-core/templates/defwithtemplate/service-binding.yaml +++ b/charts/vela-core/templates/defwithtemplate/service-binding.yaml @@ -11,7 +11,10 @@ metadata: namespace: {{ include "systemDefinitionNamespace" . }} spec: appliesToWorkloads: - - '*' + - deployments.apps + - statefulsets.apps + - daemonsets.apps + - jobs.batch schematic: cue: template: | diff --git a/charts/vela-core/templates/defwithtemplate/sidecar.yaml b/charts/vela-core/templates/defwithtemplate/sidecar.yaml index 608bcaa9d..e44d472bf 100644 --- a/charts/vela-core/templates/defwithtemplate/sidecar.yaml +++ b/charts/vela-core/templates/defwithtemplate/sidecar.yaml @@ -10,8 +10,12 @@ metadata: name: sidecar namespace: {{ include "systemDefinitionNamespace" . }} spec: - appliesToWorkloads: - - '*' + attributes: + appliesToWorkloads: + - deployments.apps + - statefulsets.apps + - daemonsets.apps + - jobs.batch podDisruptive: true schematic: cue: diff --git a/charts/vela-core/templates/defwithtemplate/storage.yaml b/charts/vela-core/templates/defwithtemplate/storage.yaml index 6c64aa924..61a2a91a9 100644 --- a/charts/vela-core/templates/defwithtemplate/storage.yaml +++ b/charts/vela-core/templates/defwithtemplate/storage.yaml @@ -10,6 +10,9 @@ metadata: spec: appliesToWorkloads: - deployments.apps + - statefulsets.apps + - daemonsets.apps + - jobs.batch podDisruptive: true schematic: cue: diff --git a/charts/vela-minimal/crds/core.oam.dev_applicationrevisions.yaml b/charts/vela-minimal/crds/core.oam.dev_applicationrevisions.yaml index 1c92b99cf..09517866e 100644 --- a/charts/vela-minimal/crds/core.oam.dev_applicationrevisions.yaml +++ b/charts/vela-minimal/crds/core.oam.dev_applicationrevisions.yaml @@ -3650,7 +3650,7 @@ spec: appliesToWorkloads: description: AppliesToWorkloads specifies the list of workload kinds this trait applies to. Workload kinds are specified - in kind.group/version format, e.g. server.core.oam.dev/v1alpha2. + in resource.group/version format, e.g. server.core.oam.dev/v1alpha2. Traits that omit this field apply to all workload kinds. items: type: string diff --git a/charts/vela-minimal/crds/core.oam.dev_definitionrevisions.yaml b/charts/vela-minimal/crds/core.oam.dev_definitionrevisions.yaml index d1608bc82..b5c8b11e6 100644 --- a/charts/vela-minimal/crds/core.oam.dev_definitionrevisions.yaml +++ b/charts/vela-minimal/crds/core.oam.dev_definitionrevisions.yaml @@ -708,7 +708,7 @@ spec: appliesToWorkloads: description: AppliesToWorkloads specifies the list of workload kinds this trait applies to. Workload kinds are specified - in kind.group/version format, e.g. server.core.oam.dev/v1alpha2. + in resource.group/version format, e.g. server.core.oam.dev/v1alpha2. Traits that omit this field apply to all workload kinds. items: type: string diff --git a/charts/vela-minimal/crds/core.oam.dev_traitdefinitions.yaml b/charts/vela-minimal/crds/core.oam.dev_traitdefinitions.yaml index ff8b3c4e2..1ecdc5260 100644 --- a/charts/vela-minimal/crds/core.oam.dev_traitdefinitions.yaml +++ b/charts/vela-minimal/crds/core.oam.dev_traitdefinitions.yaml @@ -356,7 +356,7 @@ spec: properties: appliesToWorkloads: description: AppliesToWorkloads specifies the list of workload kinds - this trait applies to. Workload kinds are specified in kind.group/version + this trait applies to. Workload kinds are specified in resource.group/version format, e.g. server.core.oam.dev/v1alpha2. Traits that omit this field apply to all workload kinds. items: diff --git a/charts/vela-minimal/templates/defwithtemplate/affinity.yaml b/charts/vela-minimal/templates/defwithtemplate/affinity.yaml index 4a5790f56..3221d0347 100644 --- a/charts/vela-minimal/templates/defwithtemplate/affinity.yaml +++ b/charts/vela-minimal/templates/defwithtemplate/affinity.yaml @@ -11,7 +11,10 @@ metadata: namespace: {{ include "systemDefinitionNamespace" . }} spec: appliesToWorkloads: - - '*' + - deployments.apps + - statefulsets.apps + - daemonsets.apps + - jobs.batch podDisruptive: true schematic: cue: diff --git a/charts/vela-minimal/templates/defwithtemplate/annotations.yaml b/charts/vela-minimal/templates/defwithtemplate/annotations.yaml index 89d2a81b6..b39e984f4 100644 --- a/charts/vela-minimal/templates/defwithtemplate/annotations.yaml +++ b/charts/vela-minimal/templates/defwithtemplate/annotations.yaml @@ -4,7 +4,7 @@ apiVersion: core.oam.dev/v1beta1 kind: TraitDefinition metadata: annotations: - definition.oam.dev/description: Add annotations on K8s pod for your workload which follows the pod spec in path 'spec.template'. + definition.oam.dev/description: Add annotations on your workload. if it generates pod, add same annotations for generated pods. labels: custom.definition.oam.dev/ui-hidden: "true" name: annotations diff --git a/charts/vela-minimal/templates/defwithtemplate/command.yaml b/charts/vela-minimal/templates/defwithtemplate/command.yaml index 65697d700..ebaf7c882 100644 --- a/charts/vela-minimal/templates/defwithtemplate/command.yaml +++ b/charts/vela-minimal/templates/defwithtemplate/command.yaml @@ -11,7 +11,10 @@ metadata: namespace: {{ include "systemDefinitionNamespace" . }} spec: appliesToWorkloads: - - '*' + - deployments.apps + - statefulsets.apps + - daemonsets.apps + - jobs.batch schematic: cue: template: | diff --git a/charts/vela-minimal/templates/defwithtemplate/container-image.yaml b/charts/vela-minimal/templates/defwithtemplate/container-image.yaml index 9b5981260..c8dc22807 100644 --- a/charts/vela-minimal/templates/defwithtemplate/container-image.yaml +++ b/charts/vela-minimal/templates/defwithtemplate/container-image.yaml @@ -11,7 +11,10 @@ metadata: namespace: {{ include "systemDefinitionNamespace" . }} spec: appliesToWorkloads: - - '*' + - deployments.apps + - statefulsets.apps + - daemonsets.apps + - jobs.batch podDisruptive: true schematic: cue: diff --git a/charts/vela-minimal/templates/defwithtemplate/cpuscaler.yaml b/charts/vela-minimal/templates/defwithtemplate/cpuscaler.yaml index b9b1dcbae..30f6d73f5 100644 --- a/charts/vela-minimal/templates/defwithtemplate/cpuscaler.yaml +++ b/charts/vela-minimal/templates/defwithtemplate/cpuscaler.yaml @@ -12,6 +12,7 @@ metadata: spec: appliesToWorkloads: - deployments.apps + - statefulsets.apps schematic: cue: template: | diff --git a/charts/vela-minimal/templates/defwithtemplate/env.yaml b/charts/vela-minimal/templates/defwithtemplate/env.yaml index 8cba72f20..b30f4230e 100644 --- a/charts/vela-minimal/templates/defwithtemplate/env.yaml +++ b/charts/vela-minimal/templates/defwithtemplate/env.yaml @@ -11,7 +11,10 @@ metadata: namespace: {{ include "systemDefinitionNamespace" . }} spec: appliesToWorkloads: - - '*' + - deployments.apps + - statefulsets.apps + - daemonsets.apps + - jobs.batch schematic: cue: template: | diff --git a/charts/vela-minimal/templates/defwithtemplate/expose.yaml b/charts/vela-minimal/templates/defwithtemplate/expose.yaml index 677aacdf4..a36753eed 100644 --- a/charts/vela-minimal/templates/defwithtemplate/expose.yaml +++ b/charts/vela-minimal/templates/defwithtemplate/expose.yaml @@ -10,6 +10,9 @@ metadata: name: expose namespace: {{ include "systemDefinitionNamespace" . }} spec: + appliesToWorkloads: + - deployments.apps + - statefulsets.apps podDisruptive: false schematic: cue: diff --git a/charts/vela-minimal/templates/defwithtemplate/gateway.yaml b/charts/vela-minimal/templates/defwithtemplate/gateway.yaml index eceaba784..9576fd48c 100644 --- a/charts/vela-minimal/templates/defwithtemplate/gateway.yaml +++ b/charts/vela-minimal/templates/defwithtemplate/gateway.yaml @@ -9,7 +9,8 @@ metadata: namespace: {{ include "systemDefinitionNamespace" . }} spec: appliesToWorkloads: - - '*' + - deployments.apps + - statefulsets.apps podDisruptive: false schematic: cue: @@ -85,7 +86,7 @@ spec: // +usage=Set ingress class in '.spec.ingressClassName' instead of 'kubernetes.io/ingress.class' annotation. classInSpec: *false | bool - // +usage=Specify the secret name you want to quote. + // +usage=Specify the secret name you want to quote to use tls. secretName?: string // +usage=Specify the host of the ingress gateway, which is used to generate the endpoints when the host is empty. diff --git a/charts/vela-minimal/templates/defwithtemplate/hostalias.yaml b/charts/vela-minimal/templates/defwithtemplate/hostalias.yaml index 9b9c1782d..a28f41908 100644 --- a/charts/vela-minimal/templates/defwithtemplate/hostalias.yaml +++ b/charts/vela-minimal/templates/defwithtemplate/hostalias.yaml @@ -11,7 +11,10 @@ metadata: namespace: {{ include "systemDefinitionNamespace" . }} spec: appliesToWorkloads: - - '*' + - deployments.apps + - statefulsets.apps + - daemonsets.apps + - jobs.batch podDisruptive: false schematic: cue: diff --git a/charts/vela-minimal/templates/defwithtemplate/init-container.yaml b/charts/vela-minimal/templates/defwithtemplate/init-container.yaml index 4c5c3cfac..1a699d084 100644 --- a/charts/vela-minimal/templates/defwithtemplate/init-container.yaml +++ b/charts/vela-minimal/templates/defwithtemplate/init-container.yaml @@ -12,6 +12,9 @@ metadata: spec: appliesToWorkloads: - deployments.apps + - statefulsets.apps + - daemonsets.apps + - jobs.batch podDisruptive: true schematic: cue: diff --git a/charts/vela-minimal/templates/defwithtemplate/labels.yaml b/charts/vela-minimal/templates/defwithtemplate/labels.yaml index 745824cf4..50742ca52 100644 --- a/charts/vela-minimal/templates/defwithtemplate/labels.yaml +++ b/charts/vela-minimal/templates/defwithtemplate/labels.yaml @@ -4,7 +4,7 @@ apiVersion: core.oam.dev/v1beta1 kind: TraitDefinition metadata: annotations: - definition.oam.dev/description: Add labels on K8s pod for your workload which follows the pod spec in path 'spec.template'. + definition.oam.dev/description: Add labels on your workload. if it generates pod, add same label for generated pods. labels: custom.definition.oam.dev/ui-hidden: "true" name: labels diff --git a/charts/vela-minimal/templates/defwithtemplate/lifecycle.yaml b/charts/vela-minimal/templates/defwithtemplate/lifecycle.yaml index 3819ab880..6a8aec435 100644 --- a/charts/vela-minimal/templates/defwithtemplate/lifecycle.yaml +++ b/charts/vela-minimal/templates/defwithtemplate/lifecycle.yaml @@ -11,7 +11,10 @@ metadata: namespace: {{ include "systemDefinitionNamespace" . }} spec: appliesToWorkloads: - - '*' + - deployments.apps + - statefulsets.apps + - daemonsets.apps + - jobs.batch podDisruptive: true schematic: cue: diff --git a/charts/vela-minimal/templates/defwithtemplate/nocalhost.yaml b/charts/vela-minimal/templates/defwithtemplate/nocalhost.yaml index 64bde3427..a76e8f25d 100644 --- a/charts/vela-minimal/templates/defwithtemplate/nocalhost.yaml +++ b/charts/vela-minimal/templates/defwithtemplate/nocalhost.yaml @@ -11,7 +11,10 @@ metadata: namespace: {{ include "systemDefinitionNamespace" . }} spec: appliesToWorkloads: - - '*' + - deployments.apps + - statefulsets.apps + - daemonsets.apps + - jobs.batch podDisruptive: true schematic: cue: diff --git a/charts/vela-minimal/templates/defwithtemplate/pure-ingress.yaml b/charts/vela-minimal/templates/defwithtemplate/pure-ingress.yaml index 40d6972f3..55f680b34 100644 --- a/charts/vela-minimal/templates/defwithtemplate/pure-ingress.yaml +++ b/charts/vela-minimal/templates/defwithtemplate/pure-ingress.yaml @@ -6,11 +6,13 @@ metadata: annotations: definition.oam.dev/description: Enable public web traffic for the component without creating a Service. labels: + custom.definition.oam.dev/deprecated: "true" custom.definition.oam.dev/ui-hidden: "true" name: pure-ingress namespace: {{ include "systemDefinitionNamespace" . }} spec: - appliesToWorkloads: [] + appliesToWorkloads: + - '*' conflictsWith: [] podDisruptive: false schematic: diff --git a/charts/vela-minimal/templates/defwithtemplate/register-grafana-datasource.yaml b/charts/vela-minimal/templates/defwithtemplate/register-grafana-datasource.yaml index 98a59500b..c67e2815b 100644 --- a/charts/vela-minimal/templates/defwithtemplate/register-grafana-datasource.yaml +++ b/charts/vela-minimal/templates/defwithtemplate/register-grafana-datasource.yaml @@ -6,6 +6,7 @@ metadata: annotations: definition.oam.dev/description: Add a datasource to Grafana labels: + custom.definition.oam.dev/deprecated: "true" custom.definition.oam.dev/ui-hidden: "true" name: register-grafana-datasource namespace: {{ include "systemDefinitionNamespace" . }} diff --git a/charts/vela-minimal/templates/defwithtemplate/resource.yaml b/charts/vela-minimal/templates/defwithtemplate/resource.yaml index b66c2d907..dff9c731f 100644 --- a/charts/vela-minimal/templates/defwithtemplate/resource.yaml +++ b/charts/vela-minimal/templates/defwithtemplate/resource.yaml @@ -11,7 +11,10 @@ metadata: namespace: {{ include "systemDefinitionNamespace" . }} spec: appliesToWorkloads: - - '*' + - deployments.apps + - statefulsets.apps + - daemonsets.apps + - jobs.batch podDisruptive: true schematic: cue: diff --git a/charts/vela-minimal/templates/defwithtemplate/scaler.yaml b/charts/vela-minimal/templates/defwithtemplate/scaler.yaml index d65f1ee48..5d7aefe90 100644 --- a/charts/vela-minimal/templates/defwithtemplate/scaler.yaml +++ b/charts/vela-minimal/templates/defwithtemplate/scaler.yaml @@ -9,7 +9,8 @@ metadata: namespace: {{ include "systemDefinitionNamespace" . }} spec: appliesToWorkloads: - - '*' + - deployments.apps + - statefulsets.apps podDisruptive: false schematic: cue: diff --git a/charts/vela-minimal/templates/defwithtemplate/service-account.yaml b/charts/vela-minimal/templates/defwithtemplate/service-account.yaml index 5ece5975e..32d022ce8 100644 --- a/charts/vela-minimal/templates/defwithtemplate/service-account.yaml +++ b/charts/vela-minimal/templates/defwithtemplate/service-account.yaml @@ -9,7 +9,10 @@ metadata: namespace: {{ include "systemDefinitionNamespace" . }} spec: appliesToWorkloads: - - '*' + - deployments.apps + - statefulsets.apps + - daemonsets.apps + - jobs.batch podDisruptive: false schematic: cue: diff --git a/charts/vela-minimal/templates/defwithtemplate/service-binding.yaml b/charts/vela-minimal/templates/defwithtemplate/service-binding.yaml index 41913f558..e02438a77 100644 --- a/charts/vela-minimal/templates/defwithtemplate/service-binding.yaml +++ b/charts/vela-minimal/templates/defwithtemplate/service-binding.yaml @@ -11,7 +11,10 @@ metadata: namespace: {{ include "systemDefinitionNamespace" . }} spec: appliesToWorkloads: - - '*' + - deployments.apps + - statefulsets.apps + - daemonsets.apps + - jobs.batch schematic: cue: template: | diff --git a/charts/vela-minimal/templates/defwithtemplate/sidecar.yaml b/charts/vela-minimal/templates/defwithtemplate/sidecar.yaml index 608bcaa9d..e44d472bf 100644 --- a/charts/vela-minimal/templates/defwithtemplate/sidecar.yaml +++ b/charts/vela-minimal/templates/defwithtemplate/sidecar.yaml @@ -10,8 +10,12 @@ metadata: name: sidecar namespace: {{ include "systemDefinitionNamespace" . }} spec: - appliesToWorkloads: - - '*' + attributes: + appliesToWorkloads: + - deployments.apps + - statefulsets.apps + - daemonsets.apps + - jobs.batch podDisruptive: true schematic: cue: diff --git a/charts/vela-minimal/templates/defwithtemplate/storage.yaml b/charts/vela-minimal/templates/defwithtemplate/storage.yaml index 6c64aa924..61a2a91a9 100644 --- a/charts/vela-minimal/templates/defwithtemplate/storage.yaml +++ b/charts/vela-minimal/templates/defwithtemplate/storage.yaml @@ -10,6 +10,9 @@ metadata: spec: appliesToWorkloads: - deployments.apps + - statefulsets.apps + - daemonsets.apps + - jobs.batch podDisruptive: true schematic: cue: diff --git a/go.mod b/go.mod index ec0add325..3a32720c6 100644 --- a/go.mod +++ b/go.mod @@ -124,6 +124,8 @@ require ( sigs.k8s.io/gateway-api v0.4.3 ) +require github.com/rogpeppe/go-internal v1.8.0 + require ( cloud.google.com/go/compute v1.7.0 // indirect github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect @@ -256,7 +258,6 @@ require ( github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/common v0.28.0 // indirect github.com/prometheus/procfs v0.6.0 // indirect - github.com/rogpeppe/go-internal v1.8.0 // indirect github.com/rubenv/sql-migrate v0.0.0-20210614095031-55d5740dbbcc // indirect github.com/russross/blackfriday v1.6.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect diff --git a/hack/docgen/def/mods/trait.go b/hack/docgen/def/mods/trait.go index 185ee2600..90ccc4143 100644 --- a/hack/docgen/def/mods/trait.go +++ b/hack/docgen/def/mods/trait.go @@ -86,7 +86,9 @@ func TraitDef(ctx context.Context, c common.Args, path, location *string, defdir }, CustomDocHeader: CustomTraitHeaderEN, } - ref.Remote = &docgen.FromCluster{Namespace: types.DefaultKubeVelaNS} + ref.Local = &docgen.FromLocal{ + Path: TraitDefDir, + } if *path != "" { ref.I18N = &docgen.En @@ -99,22 +101,24 @@ func TraitDef(ctx context.Context, c common.Args, path, location *string, defdir os.Exit(1) } fmt.Printf("trait reference docs (%s) successfully generated in %s \n", ref.I18N.Language(), *path) - } - if *location == "" || *location == "en" { - ref.I18N = &docgen.En - if err := ref.GenerateReferenceDocs(ctx, c, TraitDefRefPath); err != nil { - fmt.Println(err) - os.Exit(1) + } else { + // Generate to default path depends on language + if *location == "" || *location == "en" { + ref.I18N = &docgen.En + if err := ref.GenerateReferenceDocs(ctx, c, TraitDefRefPath); err != nil { + fmt.Println(err) + os.Exit(1) + } + fmt.Printf("trait reference docs (%s) successfully generated in %s \n", ref.I18N.Language(), TraitDefRefPath) } - fmt.Printf("trait reference docs (%s) successfully generated in %s \n", ref.I18N.Language(), TraitDefRefPath) - } - if *location == "" || *location == "zh" { - ref.I18N = &docgen.Zh - ref.CustomDocHeader = CustomTraitHeaderZH - if err := ref.GenerateReferenceDocs(ctx, c, TraitDefRefPathZh); err != nil { - fmt.Println(err) - os.Exit(1) + if *location == "" || *location == "zh" { + ref.I18N = &docgen.Zh + ref.CustomDocHeader = CustomTraitHeaderZH + if err := ref.GenerateReferenceDocs(ctx, c, TraitDefRefPathZh); err != nil { + fmt.Println(err) + os.Exit(1) + } + fmt.Printf("trait reference docs (%s) successfully generated in %s \n", ref.I18N.Language(), TraitDefRefPathZh) } - fmt.Printf("trait reference docs (%s) successfully generated in %s \n", ref.I18N.Language(), TraitDefRefPathZh) } } diff --git a/legacy/charts/vela-core-legacy/crds/core.oam.dev_applicationrevisions.yaml b/legacy/charts/vela-core-legacy/crds/core.oam.dev_applicationrevisions.yaml index 634fa148f..ce2566bb2 100644 --- a/legacy/charts/vela-core-legacy/crds/core.oam.dev_applicationrevisions.yaml +++ b/legacy/charts/vela-core-legacy/crds/core.oam.dev_applicationrevisions.yaml @@ -3650,7 +3650,7 @@ spec: appliesToWorkloads: description: AppliesToWorkloads specifies the list of workload kinds this trait applies to. Workload kinds are specified - in kind.group/version format, e.g. server.core.oam.dev/v1alpha2. + in resource.group/version format, e.g. server.core.oam.dev/v1alpha2. Traits that omit this field apply to all workload kinds. items: type: string diff --git a/legacy/charts/vela-core-legacy/crds/core.oam.dev_definitionrevisions.yaml b/legacy/charts/vela-core-legacy/crds/core.oam.dev_definitionrevisions.yaml index 287b7ed57..590ab37ae 100644 --- a/legacy/charts/vela-core-legacy/crds/core.oam.dev_definitionrevisions.yaml +++ b/legacy/charts/vela-core-legacy/crds/core.oam.dev_definitionrevisions.yaml @@ -708,7 +708,7 @@ spec: appliesToWorkloads: description: AppliesToWorkloads specifies the list of workload kinds this trait applies to. Workload kinds are specified - in kind.group/version format, e.g. server.core.oam.dev/v1alpha2. + in resource.group/version format, e.g. server.core.oam.dev/v1alpha2. Traits that omit this field apply to all workload kinds. items: type: string diff --git a/legacy/charts/vela-core-legacy/crds/core.oam.dev_traitdefinitions.yaml b/legacy/charts/vela-core-legacy/crds/core.oam.dev_traitdefinitions.yaml index 4439d4d64..387f69451 100644 --- a/legacy/charts/vela-core-legacy/crds/core.oam.dev_traitdefinitions.yaml +++ b/legacy/charts/vela-core-legacy/crds/core.oam.dev_traitdefinitions.yaml @@ -356,7 +356,7 @@ spec: properties: appliesToWorkloads: description: AppliesToWorkloads specifies the list of workload kinds - this trait applies to. Workload kinds are specified in kind.group/version + this trait applies to. Workload kinds are specified in resource.group/version format, e.g. server.core.oam.dev/v1alpha2. Traits that omit this field apply to all workload kinds. items: diff --git a/references/docgen/def-doc/trait/command.eg.md b/references/docgen/def-doc/trait/command.eg.md new file mode 100644 index 000000000..49936c7d8 --- /dev/null +++ b/references/docgen/def-doc/trait/command.eg.md @@ -0,0 +1,27 @@ +```yaml +apiVersion: core.oam.dev/v1beta1 +kind: Application +metadata: + name: busybox +spec: + components: + - name: busybox + type: webservice + properties: + image: busybox + cmd: ["sleep", "86400"] + traits: + - type: sidecar + properties: + name: sidecar-nginx + image: nginx + - type: command + properties: + # you can use command to control multiple containers by filling `containers` + # NOTE: in containers, you must set the container name for each container + containers: + - containerName: busybox + command: ["sleep", "8640000"] + - containerName: sidecar-nginx + args: ["-q"] +``` \ No newline at end of file diff --git a/references/docgen/def-doc/trait/container-image.eg.md b/references/docgen/def-doc/trait/container-image.eg.md new file mode 100644 index 000000000..d1e8e2690 --- /dev/null +++ b/references/docgen/def-doc/trait/container-image.eg.md @@ -0,0 +1,28 @@ +```yaml +apiVersion: core.oam.dev/v1beta1 +kind: Application +metadata: + name: busybox +spec: + components: + - name: busybox + type: webservice + properties: + image: busybox + cmd: ["sleep", "86400"] + traits: + - type: sidecar + properties: + name: sidecar-nginx + image: nginx + - type: container-image + properties: + # you can use container-image to control multiple containers by filling `containers` + # NOTE: in containers, you must set the container name for each container + containers: + - containerName: busybox + image: busybox-1.34.0 + imagePullPolicy: IfNotPresent + - containerName: sidecar-nginx + image: nginx-1.20 +``` \ No newline at end of file diff --git a/references/docgen/def-doc/trait/cpuscaler.eg.md b/references/docgen/def-doc/trait/cpuscaler.eg.md new file mode 100644 index 000000000..d2d34226f --- /dev/null +++ b/references/docgen/def-doc/trait/cpuscaler.eg.md @@ -0,0 +1,18 @@ +```yaml +apiVersion: core.oam.dev/v1beta1 +kind: Application +metadata: + name: website +spec: + components: + - name: frontend + type: webservice + properties: + image: nginx + traits: + - type: cpuscaler + properties: + min: 1 + max: 10 + cpuPercent: 60 +``` \ No newline at end of file diff --git a/references/docgen/def-doc/trait/env.eg.md b/references/docgen/def-doc/trait/env.eg.md new file mode 100644 index 000000000..a342401ee --- /dev/null +++ b/references/docgen/def-doc/trait/env.eg.md @@ -0,0 +1,31 @@ +```yaml +apiVersion: core.oam.dev/v1beta1 +kind: Application +metadata: + name: busybox +spec: + components: + - name: busybox + type: webservice + properties: + image: busybox + cmd: ["sleep", "86400"] + traits: + - type: sidecar + properties: + name: sidecar-nginx + image: nginx + - type: env + properties: + # you can use env to control multiple containers by filling `containers` + # NOTE: in containers, you must set the container name for each container + containers: + - containerName: busybox + env: + key_for_busybox_first: value_first + key_for_busybox_second: value_second + - containerName: sidecar-nginx + env: + key_for_nginx_first: value_first + key_for_nginx_second: value_second +``` \ No newline at end of file diff --git a/references/docgen/def-doc/trait/expose.eg.md b/references/docgen/def-doc/trait/expose.eg.md new file mode 100644 index 000000000..6b1bfe7ab --- /dev/null +++ b/references/docgen/def-doc/trait/expose.eg.md @@ -0,0 +1,16 @@ +```yaml +apiVersion: core.oam.dev/v1beta1 +kind: Application +metadata: + name: test-app +spec: + components: + - name: hello-world + type: webservice + properties: + image: crccheck/hello-world + traits: + - type: expose + properties: + port: [8000] +``` \ No newline at end of file diff --git a/references/docgen/def-doc/trait/gateway.eg.md b/references/docgen/def-doc/trait/gateway.eg.md new file mode 100644 index 000000000..918334835 --- /dev/null +++ b/references/docgen/def-doc/trait/gateway.eg.md @@ -0,0 +1,20 @@ +```yaml +# vela-app.yaml +apiVersion: core.oam.dev/v1beta1 +kind: Application +metadata: + name: first-vela-app +spec: + components: + - name: express-server + type: webservice + properties: + image: oamdev/hello-world + port: 8000 + traits: + - type: gateway + properties: + domain: testsvc.example.com + http: + "/": 8000 +``` \ No newline at end of file diff --git a/references/docgen/def-doc/trait/hostalias.eg.md b/references/docgen/def-doc/trait/hostalias.eg.md new file mode 100644 index 000000000..f75e73fb6 --- /dev/null +++ b/references/docgen/def-doc/trait/hostalias.eg.md @@ -0,0 +1,23 @@ +```yaml +apiVersion: core.oam.dev/v1beta1 +kind: Application +metadata: + name: application-with-hostalias +spec: + components: + - name: busybox-runner + type: worker + properties: + image: busybox + cmd: + - sleep + - '1000' + traits: + - type: hostalias + properties: + hostAliases: + - ip: 127.0.0.1 + hostnames: + - localname + - locals +``` \ No newline at end of file diff --git a/references/docgen/def-doc/trait/init-container.eg.md b/references/docgen/def-doc/trait/init-container.eg.md new file mode 100644 index 000000000..f8c8becdd --- /dev/null +++ b/references/docgen/def-doc/trait/init-container.eg.md @@ -0,0 +1,21 @@ +```yaml +apiVersion: core.oam.dev/v1beta1 +kind: Application +metadata: + name: busybox +spec: + components: + - name: busybox + type: webservice + properties: + image: busybox + cmd: ["sleep", "86400"] + traits: + - type: init-container + properties: + name: init-busybox + image: busybox + cmd: ["echo", "hello"] + initMountPath: /data + appMountPath: /data-initialized +``` diff --git a/references/docgen/def-doc/trait/kustomize-json-patch.eg.md b/references/docgen/def-doc/trait/kustomize-json-patch.eg.md new file mode 100644 index 000000000..9d57dd1b6 --- /dev/null +++ b/references/docgen/def-doc/trait/kustomize-json-patch.eg.md @@ -0,0 +1,23 @@ +```yaml +apiVersion: core.oam.dev/v1beta1 +kind: Application +metadata: + name: bucket-app +spec: + components: + - name: bucket-comp + type: kustomize + # ... omitted for brevity + traits: + - type: kustomize-json-patch + properties: + patchesJson: + - target: + version: v1 + kind: Deployment + name: podinfo + patch: + - op: add + path: /metadata/annotations/key + value: value +``` \ No newline at end of file diff --git a/references/docgen/def-doc/trait/kustomize-patch.eg.md b/references/docgen/def-doc/trait/kustomize-patch.eg.md new file mode 100644 index 000000000..3233691a0 --- /dev/null +++ b/references/docgen/def-doc/trait/kustomize-patch.eg.md @@ -0,0 +1,24 @@ +```yaml +apiVersion: core.oam.dev/v1beta1 +kind: Application +metadata: + name: bucket-app +spec: + components: + - name: bucket-comp + type: kustomize + # ... omitted for brevity + traits: + - type: kustomize-patch + properties: + patches: + - patch: |- + apiVersion: v1 + kind: Pod + metadata: + name: not-used + labels: + app.kubernetes.io/part-of: test-app + target: + labelSelector: "app=podinfo" +``` \ No newline at end of file diff --git a/references/docgen/def-doc/trait/kustomize-strategy-merge.eg.md b/references/docgen/def-doc/trait/kustomize-strategy-merge.eg.md new file mode 100644 index 000000000..9f046c810 --- /dev/null +++ b/references/docgen/def-doc/trait/kustomize-strategy-merge.eg.md @@ -0,0 +1,23 @@ +```yaml +apiVersion: core.oam.dev/v1beta1 +kind: Application +metadata: + name: bucket-app +spec: + components: + - name: bucket-comp + type: kustomize + # ... omitted for brevity + traits: + - type: kustomize-strategy-merge + properties: + patchesStrategicMerge: + - apiVersion: apps/v1 + kind: Deployment + metadata: + name: podinfo + spec: + template: + spec: + serviceAccount: custom-service-account +``` \ No newline at end of file diff --git a/references/docgen/def-doc/trait/lifecycle.eg.md b/references/docgen/def-doc/trait/lifecycle.eg.md new file mode 100644 index 000000000..eccfcb0a6 --- /dev/null +++ b/references/docgen/def-doc/trait/lifecycle.eg.md @@ -0,0 +1,28 @@ +```yaml +apiVersion: core.oam.dev/v1beta1 +kind: Application +metadata: + name: application-with-lifecycle +spec: + components: + - name: busybox-runner + type: worker + properties: + image: busybox + cmd: + - sleep + - '1000' + traits: + - type: lifecycle + properties: + postStart: + exec: + command: + - echo + - 'hello world' + preStop: + httpGet: + host: "www.aliyun.com" + scheme: "HTTPS" + port: 443 +``` \ No newline at end of file diff --git a/references/docgen/def-doc/trait/nocalhost.eg.md b/references/docgen/def-doc/trait/nocalhost.eg.md new file mode 100644 index 000000000..d9fc725dc --- /dev/null +++ b/references/docgen/def-doc/trait/nocalhost.eg.md @@ -0,0 +1,50 @@ +```yaml +apiVersion: core.oam.dev/v1beta1 +kind: Application +metadata: + name: bookinfo +spec: + components: + - name: productpage + type: webservice + properties: + image: nocalhost-docker.pkg.coding.net/nocalhost/bookinfo/productpage:latest + port: 9080 + traits: + - type: nocalhost + properties: + port: 9080 + gitUrl: https://github.com/nocalhost/bookinfo-productpage.git + image: nocalhost-docker.pkg.coding.net/nocalhost/dev-images/python:3.7.7-slim-productpage-with-pydevd + shell: "bash" + workDir: "/opt/work" + resources: + limits: + memory: 1Gi + cpu: "1" + requests: + memory: 512Mi + cpu: "0.5" + debug: + remoteDebugPort: 9009 + hotReload: true + sync: + type: send + filePattern: + - ./ + ignoreFilePattern: + - .git + - .idea + command: + run: + - sh + - run.sh + debug: + - sh + - debug.sh + env: + - name: "foo" + value: "bar" + portForward: + - 39080:9080 +``` \ No newline at end of file diff --git a/references/docgen/def-doc/trait/resource.eg.md b/references/docgen/def-doc/trait/resource.eg.md new file mode 100644 index 000000000..68e1a0ae8 --- /dev/null +++ b/references/docgen/def-doc/trait/resource.eg.md @@ -0,0 +1,25 @@ +```yaml +apiVersion: core.oam.dev/v1beta1 +kind: Application +metadata: + name: resource-app +spec: + components: + - name: express-server + type: webservice + properties: + image: crccheck/hello-world + ports: + - port: 8000 + traits: + - type: resource + properties: + cpu: 2 + memory: 2Gi + requests: + cpu: 2 + memory: 2Gi + limits: + cpu: 4 + memory: 4Gi +``` \ No newline at end of file diff --git a/references/docgen/def-doc/trait/service-binding.eg.md b/references/docgen/def-doc/trait/service-binding.eg.md new file mode 100644 index 000000000..ea56905ca --- /dev/null +++ b/references/docgen/def-doc/trait/service-binding.eg.md @@ -0,0 +1,85 @@ +1. Prepare a Kubernetes Secret + +The secret can be manually created, or generated by other component or external system. + +For example, we have a secret `db-conn-example` whose data is as below: + +```yaml +endpoint: https://xxx.com +password: 123 +username: myname +``` + +2. Bind the Secret into your component by `service-binding` trait + +For example, we have a webservice component who needs to consume a database. The database connection string should be set +to Pod environments: `endpoint`, `username` and `DB_PASSWORD`. + +We can set the properties for envMappings as below. For each environment, `secret` represents the secret name, and `key` +represents the key of the secret. + +Here is the complete properties for the trait. + +```yaml +traits: +- type: service-binding + properties: + envMappings: + DB_PASSWORD: + secret: db-conn-example + key: password + endpoint: + secret: db-conn-example + key: endpoint + username: + secret: db-conn-example + key: username +``` + +In particular, if the environment name, like `endpoint`, is same to the `key` of the secret, we can omit the `key`. +So we can simplify the properties as below. + +```yaml +traits: +- type: service-binding + properties: + envMappings: + DB_PASSWORD: + secret: db-conn-example + key: password + endpoint: + secret: db-conn-example + username: + secret: db-conn-example +``` + +We can finally prepare an Application for the business component `binding-test-comp` to consume the secret, which is a +representative of a database cloud resource. + +```yaml +apiVersion: core.oam.dev/v1beta1 +kind: Application +metadata: + name: webapp +spec: + components: + - name: binding-test-comp + type: webservice + properties: + image: zzxwill/flask-web-application:v0.3.1-crossplane + ports: 80 + traits: + - type: service-binding + properties: + envMappings: + # environments refer to db-conn secret + DB_PASSWORD: + secret: db-conn-example + key: password + endpoint: + secret: db-conn-example + username: + secret: db-conn-example +``` + +Deploy this YAML and the Secret `db-conn-example` will be binding into environment of workload. diff --git a/references/docgen/def-doc/trait/storage.eg.md b/references/docgen/def-doc/trait/storage.eg.md new file mode 100644 index 000000000..a7efc252a --- /dev/null +++ b/references/docgen/def-doc/trait/storage.eg.md @@ -0,0 +1,48 @@ +```yaml +# sample.yaml +apiVersion: core.oam.dev/v1beta1 +kind: Application +metadata: + name: storage-app +spec: + components: + - name: express-server + type: webservice + properties: + image: oamdev/hello-world + ports: + - port: 8000 + traits: + - type: storage + properties: + # PVC type storage + pvc: + - name: test1 + mountPath: /test/mount/pvc + # EmptyDir type storage + emptyDir: + - name: test1 + mountPath: /test/mount/emptydir + # ConfigMap type storage + configMap: + - name: test1 + mountPath: /test/mount/cm + # Mount ConfigMap to Env + mountToEnv: + envName: TEST_ENV + configMapKey: key1 + data: + key1: value1 + key2: value2 + # Secret type storage + secret: + - name: test1 + mountPath: /test/mount/secret + # Mount Secret to Env + mountToEnv: + envName: TEST_SECRET + secretKey: key1 + data: + key1: dmFsdWUx + key2: dmFsdWUy +``` \ No newline at end of file diff --git a/references/docgen/markdown.go b/references/docgen/markdown.go index a774d5536..15f803d83 100644 --- a/references/docgen/markdown.go +++ b/references/docgen/markdown.go @@ -35,6 +35,9 @@ import ( "github.com/oam-dev/kubevela/pkg/utils/common" ) +// AllComponentTypes means trait can be applied to all component types +const AllComponentTypes = "*" + // MarkdownReference is the struct for capability information in type MarkdownReference struct { Filter func(types.Capability) bool @@ -213,13 +216,21 @@ func (ref *MarkdownReference) GenerateMarkdownForCap(ctx context.Context, c type if c.Type == types.TypeTrait { + if c.Labels[types.LabelDefinitionHidden] == "true" { + description += "\n\n> " + lang.Get("For now this trait is hidden from the VelaUX. Available when using CLI.") + } description += "\n\n### " + lang.Get("Apply To Component Types") + "\n\n" var applyto string - for _, ap := range c.AppliesTo { - applyto += "- " + ap + "\n" + if len(c.AppliesTo) == 1 && c.AppliesTo[0] == AllComponentTypes { + applyto += lang.Get("All Component Types.") + } else { + applyto += lang.Get("Component based on the following kinds of resources:") + "\n" + for _, ap := range c.AppliesTo { + applyto += "- " + ap + "\n" + } } if applyto == "" { - applyto = "- All/*" + applyto = lang.Get("All Component Types.") } description += applyto + "\n" } diff --git a/references/docgen/parser.go b/references/docgen/parser.go index b72904ec5..0458f5984 100644 --- a/references/docgen/parser.go +++ b/references/docgen/parser.go @@ -20,7 +20,9 @@ import ( "context" "encoding/json" "fmt" + "io/fs" "os" + "path/filepath" "sort" "strconv" "strings" @@ -30,6 +32,7 @@ import ( "github.com/getkin/kin-openapi/openapi3" "github.com/olekukonko/tablewriter" "github.com/pkg/errors" + "github.com/rogpeppe/go-internal/modfile" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/klog/v2" @@ -65,11 +68,13 @@ func (ref *ParseReference) getCapabilities(ctx context.Context, c common.Args) ( ) switch { case ref.Local != nil: - lcap, err := ParseLocalFile(ref.Local.Path, c) + lcaps, err := ParseLocalFiles(ref.Local.Path, c) if err != nil { return nil, fmt.Errorf("failed to get capability from local file %s: %w", ref.DefinitionName, err) } - caps = append(caps, *lcap) + for _, lcap := range lcaps { + caps = append(caps, *lcap) + } case ref.Remote != nil: config, err := c.GetConfig() if err != nil { @@ -113,7 +118,7 @@ func (ref *ParseReference) prettySentence(s string) string { return ref.I18N.Get(s) + ref.I18N.Get(".") } func (ref *ParseReference) formatTableString(s string) string { - return strings.ReplaceAll(s, "|", `\|`) + return strings.ReplaceAll(s, "|", `|`) } // prepareConsoleParameter prepares the table content for each property @@ -263,7 +268,8 @@ func (ref *ParseReference) parseParameters(capName string, paraValue cue.Value, } default: var param ReferenceParameter - param.Name = "-" + // TODO better composition type handling, see command trait. + param.Name = "--" param.Usage = "Composition type" param.PrintableType = extractTypeFromError(paraValue) params = append(params, param) @@ -306,7 +312,7 @@ func extractTypeFromError(paraValue cue.Value) string { return str } str = sll[1] - sll = strings.Split(str, ") (type") + sll = strings.Split(str, " (type") return sll[0] } @@ -485,6 +491,41 @@ func (ref *ParseReference) parseTerraformCapabilityParameters(capability types.C return tables, outputsTables, nil } +// ParseLocalFiles parse the local files in directory and get name, configuration from local ComponentDefinition file +func ParseLocalFiles(localFilePath string, c common.Args) ([]*types.Capability, error) { + lcaps := make([]*types.Capability, 0) + if modfile.IsDirectoryPath(localFilePath) { + // walk the dir and get files + err := filepath.WalkDir(localFilePath, func(path string, info fs.DirEntry, err error) error { + if err != nil { + return err + } + if info.IsDir() { + return nil + } + if !strings.HasSuffix(info.Name(), ".yaml") && !strings.HasSuffix(info.Name(), ".cue") { + return nil + } + lcap, err := ParseLocalFile(path, c) + if err != nil { + return err + } + lcaps = append(lcaps, lcap) + return nil + }) + if err != nil { + return nil, err + } + } else { + lcap, err := ParseLocalFile(localFilePath, c) + if err != nil { + return nil, err + } + lcaps = append(lcaps, lcap) + } + return lcaps, nil +} + // ParseLocalFile parse the local file and get name, configuration from local ComponentDefinition file func ParseLocalFile(localFilePath string, c common.Args) (*types.Capability, error) { data, err := pkgUtils.ReadRemoteOrLocalPath(localFilePath, false) @@ -537,6 +578,7 @@ func ParseLocalFile(localFilePath string, c common.Args) (*types.Capability, err return nil, errors.Wrapf(err, "fail to parse definition to capability") } return &lcap, nil + } // WalkParameterSchema will extract properties from *openapi3.Schema diff --git a/vela-templates/definitions/internal/trait/affinity.cue b/vela-templates/definitions/internal/trait/affinity.cue index fc3b715f9..f9756be41 100644 --- a/vela-templates/definitions/internal/trait/affinity.cue +++ b/vela-templates/definitions/internal/trait/affinity.cue @@ -6,7 +6,7 @@ } description: "Affinity specifies affinity and toleration K8s pod for your workload which follows the pod spec in path 'spec.template'." attributes: { - appliesToWorkloads: ["*"] + appliesToWorkloads: ["deployments.apps", "statefulsets.apps", "daemonsets.apps", "jobs.batch"] podDisruptive: true } } diff --git a/vela-templates/definitions/internal/trait/annotations.cue b/vela-templates/definitions/internal/trait/annotations.cue index e12c28ff0..22a1f0c43 100644 --- a/vela-templates/definitions/internal/trait/annotations.cue +++ b/vela-templates/definitions/internal/trait/annotations.cue @@ -4,7 +4,7 @@ annotations: { labels: { "ui-hidden": "true" } - description: "Add annotations on K8s pod for your workload which follows the pod spec in path 'spec.template'." + description: "Add annotations on your workload. if it generates pod, add same annotations for generated pods." attributes: { podDisruptive: true appliesToWorkloads: ["*"] diff --git a/vela-templates/definitions/internal/trait/command.cue b/vela-templates/definitions/internal/trait/command.cue index 2ab4e5856..91944d9ab 100644 --- a/vela-templates/definitions/internal/trait/command.cue +++ b/vela-templates/definitions/internal/trait/command.cue @@ -5,7 +5,9 @@ command: { "ui-hidden": "true" } description: "Add command on K8s pod for your workload which follows the pod spec in path 'spec.template'" - attributes: appliesToWorkloads: ["*"] + attributes: { + appliesToWorkloads: ["deployments.apps", "statefulsets.apps", "daemonsets.apps", "jobs.batch"] + } } template: { #PatchParams: { diff --git a/vela-templates/definitions/internal/trait/container-image.cue b/vela-templates/definitions/internal/trait/container-image.cue index ac584116b..d6c986be7 100644 --- a/vela-templates/definitions/internal/trait/container-image.cue +++ b/vela-templates/definitions/internal/trait/container-image.cue @@ -7,7 +7,7 @@ description: "Set the image of the container." attributes: { podDisruptive: true - appliesToWorkloads: ["*"] + appliesToWorkloads: ["deployments.apps", "statefulsets.apps", "daemonsets.apps", "jobs.batch"] } } template: { diff --git a/vela-templates/definitions/internal/trait/cpuscaler.cue b/vela-templates/definitions/internal/trait/cpuscaler.cue index 74e5c84b2..d28b990d9 100644 --- a/vela-templates/definitions/internal/trait/cpuscaler.cue +++ b/vela-templates/definitions/internal/trait/cpuscaler.cue @@ -5,7 +5,9 @@ cpuscaler: { "ui-hidden": "true" } description: "Automatically scale the component based on CPU usage." - attributes: appliesToWorkloads: ["deployments.apps"] + attributes: { + appliesToWorkloads: ["deployments.apps", "statefulsets.apps"] + } } template: { diff --git a/vela-templates/definitions/internal/trait/env.cue b/vela-templates/definitions/internal/trait/env.cue index 69e93f590..ffe1d9a1a 100644 --- a/vela-templates/definitions/internal/trait/env.cue +++ b/vela-templates/definitions/internal/trait/env.cue @@ -5,7 +5,9 @@ env: { "ui-hidden": "true" } description: "Add env on K8s pod for your workload which follows the pod spec in path 'spec.template'" - attributes: appliesToWorkloads: ["*"] + attributes: { + appliesToWorkloads: ["deployments.apps", "statefulsets.apps", "daemonsets.apps", "jobs.batch"] + } } template: { #PatchParams: { diff --git a/vela-templates/definitions/internal/trait/expose.cue b/vela-templates/definitions/internal/trait/expose.cue index 2ced548f5..4ae7a5c2a 100644 --- a/vela-templates/definitions/internal/trait/expose.cue +++ b/vela-templates/definitions/internal/trait/expose.cue @@ -11,6 +11,7 @@ expose: { description: "Expose port to enable web traffic for your component." attributes: { podDisruptive: false + appliesToWorkloads: ["deployments.apps", "statefulsets.apps"] status: { customStatus: #""" message: *"" | string diff --git a/vela-templates/definitions/internal/trait/gateway.cue b/vela-templates/definitions/internal/trait/gateway.cue index ae23b79a3..7ce6403fe 100644 --- a/vela-templates/definitions/internal/trait/gateway.cue +++ b/vela-templates/definitions/internal/trait/gateway.cue @@ -5,7 +5,8 @@ gateway: { description: "Enable public web traffic for the component, the ingress API matches K8s v1.20+." attributes: { podDisruptive: false - appliesToWorkloads: ["*"] + appliesToWorkloads: ["deployments.apps", "statefulsets.apps"] + status: { customStatus: #""" let igs = context.outputs.ingress.status.loadBalancer.ingress @@ -111,7 +112,7 @@ template: { // +usage=Set ingress class in '.spec.ingressClassName' instead of 'kubernetes.io/ingress.class' annotation. classInSpec: *false | bool - // +usage=Specify the secret name you want to quote. + // +usage=Specify the secret name you want to quote to use tls. secretName?: string // +usage=Specify the host of the ingress gateway, which is used to generate the endpoints when the host is empty. diff --git a/vela-templates/definitions/internal/trait/hostalias.cue b/vela-templates/definitions/internal/trait/hostalias.cue index fde89735c..6a17a41bd 100644 --- a/vela-templates/definitions/internal/trait/hostalias.cue +++ b/vela-templates/definitions/internal/trait/hostalias.cue @@ -7,7 +7,7 @@ hostalias: { description: "Add host aliases on K8s pod for your workload which follows the pod spec in path 'spec.template'." attributes: { podDisruptive: false - appliesToWorkloads: ["*"] + appliesToWorkloads: ["deployments.apps", "statefulsets.apps", "daemonsets.apps", "jobs.batch"] } } template: { diff --git a/vela-templates/definitions/internal/trait/init-container.cue b/vela-templates/definitions/internal/trait/init-container.cue index af000805f..40d5f5250 100644 --- a/vela-templates/definitions/internal/trait/init-container.cue +++ b/vela-templates/definitions/internal/trait/init-container.cue @@ -7,7 +7,7 @@ description: "add an init container and use shared volume with pod" attributes: { podDisruptive: true - appliesToWorkloads: ["deployments.apps"] + appliesToWorkloads: ["deployments.apps", "statefulsets.apps", "daemonsets.apps", "jobs.batch"] } } template: { diff --git a/vela-templates/definitions/internal/trait/labels.cue b/vela-templates/definitions/internal/trait/labels.cue index fae833600..7c84d55f0 100644 --- a/vela-templates/definitions/internal/trait/labels.cue +++ b/vela-templates/definitions/internal/trait/labels.cue @@ -4,7 +4,7 @@ labels: { labels: { "ui-hidden": "true" } - description: "Add labels on K8s pod for your workload which follows the pod spec in path 'spec.template'." + description: "Add labels on your workload. if it generates pod, add same label for generated pods." attributes: { podDisruptive: true appliesToWorkloads: ["*"] diff --git a/vela-templates/definitions/internal/trait/lifecycle.cue b/vela-templates/definitions/internal/trait/lifecycle.cue index 06d2c2126..5ef835aa8 100644 --- a/vela-templates/definitions/internal/trait/lifecycle.cue +++ b/vela-templates/definitions/internal/trait/lifecycle.cue @@ -7,7 +7,7 @@ lifecycle: { description: "Add lifecycle hooks for every container of K8s pod for your workload which follows the pod spec in path 'spec.template'." attributes: { podDisruptive: true - appliesToWorkloads: ["*"] + appliesToWorkloads: ["deployments.apps", "statefulsets.apps", "daemonsets.apps", "jobs.batch"] } } template: { diff --git a/vela-templates/definitions/internal/trait/nocalhost.cue b/vela-templates/definitions/internal/trait/nocalhost.cue index 409d6b1f6..2b52aee9b 100644 --- a/vela-templates/definitions/internal/trait/nocalhost.cue +++ b/vela-templates/definitions/internal/trait/nocalhost.cue @@ -11,7 +11,7 @@ nocalhost: { description: "nocalhost develop configuration." attributes: { podDisruptive: true - appliesToWorkloads: ["*"] + appliesToWorkloads: ["deployments.apps", "statefulsets.apps", "daemonsets.apps", "jobs.batch"] } } diff --git a/vela-templates/definitions/internal/trait/pure-ingress.cue b/vela-templates/definitions/internal/trait/pure-ingress.cue index 9e9e5f4f8..adc710b40 100644 --- a/vela-templates/definitions/internal/trait/pure-ingress.cue +++ b/vela-templates/definitions/internal/trait/pure-ingress.cue @@ -1,7 +1,6 @@ "pure-ingress": { - annotations: {} attributes: { - appliesToWorkloads: [] + appliesToWorkloads: ["*"] conflictsWith: [] podDisruptive: false status: { @@ -24,7 +23,8 @@ } description: "Enable public web traffic for the component without creating a Service." labels: { - "ui-hidden": "true" + "ui-hidden": "true" + "deprecated": "true" } type: "trait" } diff --git a/vela-templates/definitions/internal/trait/register-grafana-datasource.cue b/vela-templates/definitions/internal/trait/register-grafana-datasource.cue index e6a2985a4..7be7ff071 100644 --- a/vela-templates/definitions/internal/trait/register-grafana-datasource.cue +++ b/vela-templates/definitions/internal/trait/register-grafana-datasource.cue @@ -8,7 +8,8 @@ } description: "Add a datasource to Grafana" labels: { - "ui-hidden": "true" + "ui-hidden": "true" + "deprecated": "true" } type: "trait" } diff --git a/vela-templates/definitions/internal/trait/resource.cue b/vela-templates/definitions/internal/trait/resource.cue index 023b789e2..cf8dc4a44 100644 --- a/vela-templates/definitions/internal/trait/resource.cue +++ b/vela-templates/definitions/internal/trait/resource.cue @@ -7,7 +7,7 @@ resource: { description: "Add resource requests and limits on K8s pod for your workload which follows the pod spec in path 'spec.template.'" attributes: { podDisruptive: true - appliesToWorkloads: ["*"] + appliesToWorkloads: ["deployments.apps", "statefulsets.apps", "daemonsets.apps", "jobs.batch"] } } template: { diff --git a/vela-templates/definitions/internal/trait/scaler.cue b/vela-templates/definitions/internal/trait/scaler.cue index 261962fc6..90be15f79 100644 --- a/vela-templates/definitions/internal/trait/scaler.cue +++ b/vela-templates/definitions/internal/trait/scaler.cue @@ -5,7 +5,7 @@ scaler: { description: "Manually scale K8s pod for your workload which follows the pod spec in path 'spec.template'." attributes: { podDisruptive: false - appliesToWorkloads: ["*"] + appliesToWorkloads: ["deployments.apps", "statefulsets.apps"] } } template: { diff --git a/vela-templates/definitions/internal/trait/service-account.cue b/vela-templates/definitions/internal/trait/service-account.cue index ff1ed80e1..a5c0ffd3e 100644 --- a/vela-templates/definitions/internal/trait/service-account.cue +++ b/vela-templates/definitions/internal/trait/service-account.cue @@ -5,7 +5,7 @@ description: "Specify serviceAccount for your workload which follows the pod spec in path 'spec.template'." attributes: { podDisruptive: false - appliesToWorkloads: ["*"] + appliesToWorkloads: ["deployments.apps", "statefulsets.apps", "daemonsets.apps", "jobs.batch"] } } template: { diff --git a/vela-templates/definitions/internal/trait/service-binding.cue b/vela-templates/definitions/internal/trait/service-binding.cue index 304b0801a..d5fe843d3 100644 --- a/vela-templates/definitions/internal/trait/service-binding.cue +++ b/vela-templates/definitions/internal/trait/service-binding.cue @@ -5,7 +5,9 @@ "ui-hidden": "true" } description: "Binding secrets of cloud resources to component env. This definition is DEPRECATED, please use 'storage' instead." - attributes: appliesToWorkloads: ["*"] + attributes: { + appliesToWorkloads: ["deployments.apps", "statefulsets.apps", "daemonsets.apps", "jobs.batch"] + } } template: { patch: spec: template: spec: { diff --git a/vela-templates/definitions/internal/trait/sidecar.cue b/vela-templates/definitions/internal/trait/sidecar.cue index a020ed979..3579c7931 100644 --- a/vela-templates/definitions/internal/trait/sidecar.cue +++ b/vela-templates/definitions/internal/trait/sidecar.cue @@ -7,7 +7,9 @@ sidecar: { description: "Inject a sidecar container to K8s pod for your workload which follows the pod spec in path 'spec.template'." attributes: { podDisruptive: true - appliesToWorkloads: ["*"] + attributes: { + appliesToWorkloads: ["deployments.apps", "statefulsets.apps", "daemonsets.apps", "jobs.batch"] + } } } template: { diff --git a/vela-templates/definitions/internal/trait/storage.cue b/vela-templates/definitions/internal/trait/storage.cue index 8af92d4fb..34bac7f0f 100644 --- a/vela-templates/definitions/internal/trait/storage.cue +++ b/vela-templates/definitions/internal/trait/storage.cue @@ -4,7 +4,7 @@ storage: { labels: {} description: "Add storages on K8s pod for your workload which follows the pod spec in path 'spec.template'." attributes: { - appliesToWorkloads: ["deployments.apps"] + appliesToWorkloads: ["deployments.apps", "statefulsets.apps", "daemonsets.apps", "jobs.batch"] podDisruptive: true } }