From 2c68c0e6d4ca833907d0ea1f18b5a3e9944c41fa Mon Sep 17 00:00:00 2001 From: yangsoon Date: Fri, 26 Mar 2021 19:14:07 +0800 Subject: [PATCH] fix docs example (#1316) --- docs/examples/app-with-status/template.yaml | 12 +- docs/examples/application/Demo.md | 138 +++++++------ docs/examples/application/README.md | 190 +++++++++--------- .../application/application-sample.yaml | 4 +- docs/examples/application/template.yaml | 168 ++++++++-------- docs/examples/blog-extension/mydeploy.yaml | 61 +++--- .../webservice-definition.yaml | 10 +- .../dry-run/definitions/myingress.yaml | 2 +- .../dry-run/definitions/myworker.yaml | 10 +- .../helm-module/virtual-group-td.yaml | 2 +- .../examples/helm-module/webapp-chart-wd.yaml | 2 +- docs/examples/kubecondemo/README.md | 3 + docs/examples/registry/autoscale.yaml | 137 ++++++------- docs/examples/registry/dynamic-sa.yaml | 50 ++--- docs/examples/registry/for-loop.yaml | 49 ++--- docs/examples/registry/initcontainer.yaml | 81 ++++---- docs/examples/registry/kautoscale.yaml | 34 ++-- docs/examples/registry/metrics.yaml | 50 ++--- docs/examples/registry/node-affinity.yaml | 63 +++--- docs/examples/registry/patch-replica.yaml | 26 +-- docs/examples/registry/patch-scaler.yaml | 18 -- docs/examples/registry/podenv.yaml | 46 ++--- docs/examples/registry/rollout.yaml | 82 ++++---- docs/examples/registry/route.yaml | 70 +++---- docs/examples/registry/virtualgroup.yaml | 40 ++-- docs/examples/registry/webserver.yaml | 159 ++++++++------- pkg/appfile/config/configmap.go | 8 +- references/appfile/api/appfile_test.go | 4 + 28 files changed, 786 insertions(+), 733 deletions(-) delete mode 100644 docs/examples/registry/patch-scaler.yaml diff --git a/docs/examples/app-with-status/template.yaml b/docs/examples/app-with-status/template.yaml index 273c071ba..4d27bff97 100644 --- a/docs/examples/app-with-status/template.yaml +++ b/docs/examples/app-with-status/template.yaml @@ -1,12 +1,14 @@ -apiVersion: core.oam.dev/v1alpha2 -kind: WorkloadDefinition +apiVersion: core.oam.dev/v1beta1 +kind: ComponentDefinition metadata: name: nworker annotations: definition.oam.dev/description: "Describes long-running, scalable, containerized services that running at backend. They do NOT have network endpoint to receive external network traffic." spec: - definitionRef: - name: deployments.apps + workload: + definition: + apiVersion: apps/v1 + kind: Deployment status: healthPolicy: | isHealth: (context.output.status.readyReplicas > 0) && (context.output.status.readyReplicas == context.output.status.replicas) @@ -68,7 +70,7 @@ spec: --- -apiVersion: core.oam.dev/v1alpha2 +apiVersion: core.oam.dev/v1beta1 kind: TraitDefinition metadata: name: ingress diff --git a/docs/examples/application/Demo.md b/docs/examples/application/Demo.md index 4d15bbf4e..3634913c1 100644 --- a/docs/examples/application/Demo.md +++ b/docs/examples/application/Demo.md @@ -1,11 +1,11 @@ # Application Example -In this Demo, Application application-sample will be converted to appconfig and component +In this Demo, Application application-sample will be converted to appcontext and component The fields in the application spec come from the parametes defined in the definition template , so we must install Definition at first -Step 1: Install Workload Definition & Trait Definition +Step 1: Install ComponentDefinition & Trait Definition ``` kubectl apply -f template.yaml ``` @@ -18,87 +18,99 @@ Step 3: View the application status kubectl get -f application-sample.yaml -oyaml // You can see the following -apiVersion: core.oam.dev/v1alpha2 +apiVersion: core.oam.dev/v1beta1 kind: Application metadata: annotations: kubectl.kubernetes.io/last-applied-configuration: | - {"apiVersion":"core.oam.dev/v1alpha2","kind":"Application","metadata":{"annotations":{},"name":"application-sample","namespace":"oam-test"},"spec":{"template":"services:\n myweb:\n type: worker\n image: \"busybox\"\n cmd:\n - sleep\n - \"1000\"\n scaler:\n replicas: 10"}} - name: application-sample - namespace: oam-test + {"apiVersion":"core.oam.dev/v1beta1","kind":"Application","metadata":{"annotations":{},"name":"application-sample","namespace":"default"},"spec":{"components":[{"name":"myweb","properties":{"cmd":["sleep","1000"],"image":"busybox"},"traits":[{"properties":{"replicas":10},"type":"scaler"},{"properties":{"image":"nginx","name":"sidecar-test"},"type":"sidecar"},{"properties":{"http":{"server":80}},"type":"kservice"}],"type":"worker"}]}} + ... spec: components: - - name: myweb - type: worker - settings: - image: "busybox" - cmd: - - sleep - - "1000" - traits: - - name: scaler - properties: - replicas: 10 - - name: sidercar - properties: - name: "sidecar-test" - image: "nginx" - - name: kservice - properties: - http: - server: 80 + - name: myweb + properties: + cmd: + - sleep + - "1000" + image: busybox + traits: + - properties: + replicas: 10 + type: scaler + - properties: + image: nginx + name: sidecar-test + type: sidecar + - properties: + http: + server: 80 + type: kservice + type: worker status: + batchRollingState: "" + components: + - apiVersion: core.oam.dev/v1alpha2 + kind: Component + name: myweb conditions: - - lastTransitionTime: "2020-12-02T12:12:52Z" - reason: Available + - reason: Available status: "True" type: Parsed - - lastTransitionTime: "2020-12-02T12:12:52Z" - reason: Available + - reason: Available status: "True" type: Built - - lastTransitionTime: "2020-12-02T12:12:52Z" - reason: Available + - reason: Available status: "True" type: Applied status: running - + ... ``` Step 4: View the oam CR generated by application ``` -kubectl get appconfig/application-sample -oyaml +kubectl get appcontext/application-sample -oyaml // appconfig is as follows apiVersion: core.oam.dev/v1alpha2 -kind: ApplicationConfiguration +kind: ApplicationContext metadata: + annotations: + kubectl.kubernetes.io/last-applied-configuration: | + {"apiVersion":"core.oam.dev/v1beta1","kind":"Application","metadata":{"annotations":{},"name":"application-sample","namespace":"default"},"spec":{"components":[{"name":"myweb","properties":{"cmd":["sleep","1000"],"image":"busybox"},"traits":[{"properties":{"replicas":10},"type":"scaler"},{"properties":{"image":"nginx","name":"sidecar-test"},"type":"sidecar"},{"properties":{"http":{"server":80}},"type":"kservice"}],"type":"worker"}]}} + generation: 1 labels: - application.oam.dev: application-sample + app.oam.dev/app-revision-hash: 99749f6e7a78024b name: application-sample - namespace: oam-test + namespace: default ownerReferences: - - apiVersion: core.oam.dev/v1alpha2 + - apiVersion: core.oam.dev/v1beta1 controller: true kind: Application name: application-sample - uid: dca7acc3-664c-422b-aa52-4fe012e37974 -spec: - components: - - componentName: myweb + ... +spec: + applicationRevisionName: application-sample-v1 +status: + conditions: + - reason: ReconcileSuccess + status: "True" + type: Synced + dependency: {} + observedGeneration: 0 + workloads: + - appliedComponentRevision: myweb-v1 + componentName: myweb + componentRevisionName: myweb-v1 traits: - - trait: + - traitRef: apiVersion: v1 kind: Service - metadata: - name: myweb - spec: - ports: - - port: 80 - targetPort: 80 - selector: - app: myweb + name: myweb + workloadRef: + apiVersion: apps/v1 + kind: Deployment + name: myweb-v1 kubectl get component/myweb -oyaml @@ -106,20 +118,26 @@ kubectl get component/myweb -oyaml apiVersion: core.oam.dev/v1alpha2 kind: Component metadata: + generation: 1 labels: - application.oam.dev: application-sample + app.oam.dev/name: application-sample name: myweb - namespace: oam-test + namespace: default ownerReferences: - - apiVersion: core.oam.dev/v1alpha2 + - apiVersion: core.oam.dev/v1beta1 controller: true kind: Application name: application-sample - uid: dca7acc3-664c-422b-aa52-4fe012e37974 + ... spec: workload: apiVersion: apps/v1 kind: Deployment + metadata: + labels: + app.oam.dev/component: myweb + app.oam.dev/name: application-sample + workload.oam.dev/type: worker spec: replicas: 10 selector: @@ -137,10 +155,12 @@ spec: - "1000" image: busybox name: myweb - - command: - - sleep - - "1000" - image: busybox - name: test-sidecar + - image: nginx + name: sidecar-test +status: + latestRevision: + name: myweb-v1 + revision: 1 + observedGeneration: 1 ``` diff --git a/docs/examples/application/README.md b/docs/examples/application/README.md index 8469857e7..9caa6b163 100644 --- a/docs/examples/application/README.md +++ b/docs/examples/application/README.md @@ -55,59 +55,62 @@ containers: [{ ### output Generate a new cr, which is generally associated with workload cr -## Workload Definition -The following workload definition is to generate a deployment +## ComponentDefinition +The following ComponentDefinition is to generate a deployment ``` -apiVersion: core.oam.dev/v1alpha2 -kind: WorkloadDefinition +apiVersion: core.oam.dev/v1beta1 +kind: ComponentDefinition metadata: name: worker annotations: definition.oam.dev/description: "Long-running scalable backend worker without network endpoint" spec: - definitionRef: - name: deployments.apps - extension: - template: | - output: { - apiVersion: "apps/v1" - kind: "Deployment" - spec: { - selector: matchLabels: { - "app.oam.dev/component": context.name - } + workload: + definition: + apiVersion: apps/v1 + kind: Deployment + schematic: + 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 - } + template: { + metadata: labels: { + "app.oam.dev/component": context.name + } - spec: { - containers: [{ - name: context.name - image: parameter.image + spec: { + containers: [{ + name: context.name + image: parameter.image - if parameter["cmd"] != _|_ { - command: parameter.cmd - } - }] - } - } - } - } + if parameter["cmd"] != _|_ { + command: parameter.cmd + } + }] + } + } + } + } - parameter: { - // +usage=Which image would you like to use for your service - // +short=i - image: string + parameter: { + // +usage=Which image would you like to use for your service + // +short=i + image: string - cmd?: [...string] - } + cmd?: [...string] + } ``` If defined an application as follows ``` -apiVersion: core.oam.dev/v1alpha2 +apiVersion: core.oam.dev/v1beta1 kind: Application metadata: name: application-sample @@ -115,7 +118,7 @@ spec: components: - name: myweb type: worker - settings: + properties: image: "busybox" cmd: - sleep @@ -145,7 +148,7 @@ spec: Define a trait Definition that appends service to workload(worker) , as shown below ``` -apiVersion: core.oam.dev/v1alpha2 +apiVersion: core.oam.dev/v1beta1 kind: TraitDefinition metadata: annotations: @@ -155,31 +158,32 @@ spec: appliesToWorkloads: - webservice - worker - extension: - template: |- - patch: {spec: template: metadata: labels: app: context.name} - outputs: service: { - apiVersion: "v1" - kind: "Service" - metadata: name: context.name - spec: { - selector: app: context.name - ports: [ - for k, v in parameter.http { - port: v - targetPort: v - } - ] + schematic: + cue: + template: |- + patch: {spec: template: metadata: labels: app: context.name} + outputs: service: { + apiVersion: "v1" + kind: "Service" + metadata: name: context.name + spec: { + selector: app: context.name + ports: [ + for k, v in parameter.http { + port: v + targetPort: v + } + ] + } + } + parameter: { + http: [string]: int } - } - parameter: { - http: [string]: int - } ``` If add service capability to the application, as follows ``` -apiVersion: core.oam.dev/v1alpha2 +apiVersion: core.oam.dev/v1beta1 kind: Application metadata: name: application-sample @@ -187,13 +191,13 @@ spec: components: - name: myweb type: worker - settings: + properties: image: "busybox" cmd: - sleep - "1000" traits: - - name: kservice + - type: kservice properties: http: server: 80 @@ -238,7 +242,7 @@ spec: Define a trait Definition that scale workload(worker) replicas ``` -apiVersion: core.oam.dev/v1alpha2 +apiVersion: core.oam.dev/v1beta1 kind: TraitDefinition metadata: annotations: @@ -248,32 +252,33 @@ spec: appliesToWorkloads: - webservice - worker - extension: - template: |- - patch: { - spec: replicas: parameter.replicas - } - parameter: { - //+short=r - replicas: *1 | int - } + schematic: + cue: + template: |- + patch: { + spec: replicas: parameter.replicas + } + parameter: { + //+short=r + replicas: *1 | int + } ``` If add scaler capability to the application, as follows ``` components: - name: myweb type: worker - settings: + properties: image: "busybox" cmd: - sleep - "1000" traits: - - name: kservice + - type: kservice properties: http: server: 80 - - name: scaler + - type: scaler properties: replicas: 10 ``` @@ -307,7 +312,7 @@ spec: Define a trait Definition that append containers to workload(worker) ``` -apiVersion: core.oam.dev/v1alpha2 +apiVersion: core.oam.dev/v1beta1 kind: TraitDefinition metadata: annotations: @@ -317,22 +322,23 @@ spec: appliesToWorkloads: - webservice - worker - extension: - template: |- - patch: { - // +patchKey=name - spec: template: spec: containers: [parameter] - } - parameter: { - name: string - image: string - command?: [...string] - } + schematic: + cue: + template: |- + patch: { + // +patchKey=name + spec: template: spec: containers: [parameter] + } + parameter: { + name: string + image: string + command?: [...string] + } ``` If add sidercar capability to the application, as follows ``` -apiVersion: core.oam.dev/v1alpha2 +apiVersion: core.oam.dev/v1beta1 kind: Application metadata: name: application-sample @@ -340,20 +346,20 @@ spec: components: - name: myweb type: worker - settings: + properties: image: "busybox" cmd: - sleep - "1000" traits: - - name: scaler + - type: scaler properties: replicas: 10 - - name: sidercar + - type: sidecar properties: name: "sidecar-test" image: "nginx" - - name: kservice + - type: kservice properties: http: server: 80 diff --git a/docs/examples/application/application-sample.yaml b/docs/examples/application/application-sample.yaml index 6caccc058..b69b114cd 100644 --- a/docs/examples/application/application-sample.yaml +++ b/docs/examples/application/application-sample.yaml @@ -15,11 +15,11 @@ spec: - type: scaler properties: replicas: 10 - - kind: sidecar + - type: sidecar properties: name: "sidecar-test" image: "nginx" - - kind: kservice + - type: kservice properties: http: server: 80 \ No newline at end of file diff --git a/docs/examples/application/template.yaml b/docs/examples/application/template.yaml index c50afd63d..f6bc0a843 100644 --- a/docs/examples/application/template.yaml +++ b/docs/examples/application/template.yaml @@ -1,54 +1,57 @@ -apiVersion: core.oam.dev/v1alpha2 -kind: WorkloadDefinition +apiVersion: core.oam.dev/v1beta1 +kind: ComponentDefinition metadata: name: worker annotations: definition.oam.dev/description: "Long-running scalable backend worker without network endpoint" spec: - definitionRef: - name: deployments.apps - extension: - template: | - output: { - apiVersion: "apps/v1" - kind: "Deployment" - spec: { - selector: matchLabels: { - "app.oam.dev/component": context.name - } + workload: + definition: + apiVersion: apps/v1 + kind: Deployment + schematic: + 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 - } + template: { + metadata: labels: { + "app.oam.dev/component": context.name + } - spec: { - containers: [{ - name: context.name - image: parameter.image + spec: { + containers: [{ + name: context.name + image: parameter.image - if parameter["cmd"] != _|_ { - command: parameter.cmd - } - }] - } - } + if parameter["cmd"] != _|_ { + command: parameter.cmd + } + }] + } + } - selector: - matchLabels: - "app.oam.dev/component": context.name - } - } + selector: + matchLabels: + "app.oam.dev/component": context.name + } + } - parameter: { - // +usage=Which image would you like to use for your service - // +short=i - image: string + parameter: { + // +usage=Which image would you like to use for your service + // +short=i + image: string - cmd?: [...string] - } + cmd?: [...string] + } --- -apiVersion: core.oam.dev/v1alpha2 +apiVersion: core.oam.dev/v1beta1 kind: TraitDefinition metadata: annotations: @@ -58,17 +61,18 @@ spec: appliesToWorkloads: - webservice - worker - extension: - template: |- - patch: { - spec: replicas: parameter.replicas - } - parameter: { - //+short=r - replicas: *1 | int - } + schematic: + cue: + template: |- + patch: { + spec: replicas: parameter.replicas + } + parameter: { + //+short=r + replicas: *1 | int + } --- -apiVersion: core.oam.dev/v1alpha2 +apiVersion: core.oam.dev/v1beta1 kind: TraitDefinition metadata: annotations: @@ -78,19 +82,20 @@ spec: appliesToWorkloads: - webservice - worker - extension: - template: |- - patch: { - // +patchKey=name - spec: template: spec: containers: [parameter] - } - parameter: { - name: string - image: string - command?: [...string] - } + schematic: + cue: + template: |- + patch: { + // +patchKey=name + spec: template: spec: containers: [parameter] + } + parameter: { + name: string + image: string + command?: [...string] + } --- -apiVersion: core.oam.dev/v1alpha2 +apiVersion: core.oam.dev/v1beta1 kind: TraitDefinition metadata: annotations: @@ -100,28 +105,29 @@ spec: appliesToWorkloads: - webservice - worker - extension: - template: |- - patch: {spec: template: metadata: labels: app: context.name} - outputs: service: { - apiVersion: "v1" - kind: "Service" - metadata: name: context.name - spec: { - selector: app: context.name - ports: [ - for k, v in parameter.http { - port: v - targetPort: v - } - ] + schematic: + cue: + template: |- + patch: {spec: template: metadata: labels: app: context.name} + outputs: service: { + apiVersion: "v1" + kind: "Service" + metadata: name: context.name + spec: { + selector: app: context.name + ports: [ + for k, v in parameter.http { + port: v + targetPort: v + } + ] + } + } + parameter: { + http: [string]: int } - } - parameter: { - http: [string]: int - } --- -apiVersion: core.oam.dev/v1alpha2 +apiVersion: core.oam.dev/v1beta1 kind: TraitDefinition metadata: name: services diff --git a/docs/examples/blog-extension/mydeploy.yaml b/docs/examples/blog-extension/mydeploy.yaml index cafa15bbf..2bfa3c3f4 100644 --- a/docs/examples/blog-extension/mydeploy.yaml +++ b/docs/examples/blog-extension/mydeploy.yaml @@ -1,31 +1,36 @@ -apiVersion: core.oam.dev/v1alpha2 -kind: WorkloadDefinition +apiVersion: core.oam.dev/v1beta1 +kind: ComponentDefinition metadata: name: mydeploy spec: - definitionRef: - name: deployments.apps - extension: - template: | - parameter: { - name: string - image: string - } - output: { - apiVersion: "apps/v1" - kind: "Deployment" - spec: { - selector: matchLabels: { - "app.oam.dev/component": parameter.name - } - template: { - metadata: labels: { - "app.oam.dev/component": parameter.name - } - spec: { - containers: [{ - name: parameter.name - image: parameter.image - }] - }}} - } \ No newline at end of file + workload: + definition: + apiVersion: apps/v1 + kind: Deployment + schematic: + cue: + template: |- + parameter: { + name: string + image: string + } + output: { + apiVersion: "apps/v1" + kind: "Deployment" + spec: { + selector: matchLabels: { + "app.oam.dev/component": parameter.name + } + template: { + metadata: labels: { + "app.oam.dev/component": parameter.name + } + spec: { + containers: [{ + name: parameter.name + image: parameter.image + }] + } + } + } + } \ No newline at end of file diff --git a/docs/examples/deployment-rollout/webservice-definition.yaml b/docs/examples/deployment-rollout/webservice-definition.yaml index 2d50714b3..168db19be 100644 --- a/docs/examples/deployment-rollout/webservice-definition.yaml +++ b/docs/examples/deployment-rollout/webservice-definition.yaml @@ -1,13 +1,15 @@ # Code generated by KubeVela templates. DO NOT EDIT. -apiVersion: core.oam.dev/v1alpha2 -kind: WorkloadDefinition +apiVersion: core.oam.dev/v1beta1 +kind: ComponentDefinition metadata: name: webservice annotations: definition.oam.dev/description: "Describes long-running, scalable, containerized services that have a stable network endpoint to receive external network traffic from customers." spec: - definitionRef: - name: deployments.apps + workload: + definition: + apiVersion: apps/v1 + kind: Deployment schematic: cue: template: | diff --git a/docs/examples/dry-run/definitions/myingress.yaml b/docs/examples/dry-run/definitions/myingress.yaml index e1e59bf1d..1a3e983c6 100644 --- a/docs/examples/dry-run/definitions/myingress.yaml +++ b/docs/examples/dry-run/definitions/myingress.yaml @@ -1,4 +1,4 @@ -apiVersion: core.oam.dev/v1alpha2 +apiVersion: core.oam.dev/v1beta1 kind: TraitDefinition metadata: name: myingress diff --git a/docs/examples/dry-run/definitions/myworker.yaml b/docs/examples/dry-run/definitions/myworker.yaml index 26b927919..1e374f7c0 100644 --- a/docs/examples/dry-run/definitions/myworker.yaml +++ b/docs/examples/dry-run/definitions/myworker.yaml @@ -1,10 +1,12 @@ -apiVersion: core.oam.dev/v1alpha2 -kind: WorkloadDefinition +apiVersion: core.oam.dev/v1beta1 +kind: ComponentDefinition metadata: name: myworker spec: - definitionRef: - name: deployments.apps + workload: + definition: + apiVersion: apps/v1 + kind: Deployment schematic: cue: template: | diff --git a/docs/examples/helm-module/virtual-group-td.yaml b/docs/examples/helm-module/virtual-group-td.yaml index 1010aad19..d6dc466c1 100644 --- a/docs/examples/helm-module/virtual-group-td.yaml +++ b/docs/examples/helm-module/virtual-group-td.yaml @@ -1,4 +1,4 @@ -apiVersion: core.oam.dev/v1alpha2 +apiVersion: core.oam.dev/v1beta1 kind: TraitDefinition metadata: annotations: diff --git a/docs/examples/helm-module/webapp-chart-wd.yaml b/docs/examples/helm-module/webapp-chart-wd.yaml index d7e23be4e..9d2485709 100644 --- a/docs/examples/helm-module/webapp-chart-wd.yaml +++ b/docs/examples/helm-module/webapp-chart-wd.yaml @@ -1,4 +1,4 @@ -apiVersion: core.oam.dev/v1alpha2 +apiVersion: core.oam.dev/v1beta1 kind: WorkloadDefinition metadata: name: webapp-chart diff --git a/docs/examples/kubecondemo/README.md b/docs/examples/kubecondemo/README.md index 635106f24..c7a15d1d2 100644 --- a/docs/examples/kubecondemo/README.md +++ b/docs/examples/kubecondemo/README.md @@ -1,5 +1,8 @@ # Kubecon 2020 NA Kubevela Tutorial +> :warning: This is an outdated tutorial only applies to the old version of kubevela. +Before you read, you need to know what you are doing. + ## Pre-requisites * Kubernetes cluster version >1.16 diff --git a/docs/examples/registry/autoscale.yaml b/docs/examples/registry/autoscale.yaml index 671abbe10..313b0e8b1 100644 --- a/docs/examples/registry/autoscale.yaml +++ b/docs/examples/registry/autoscale.yaml @@ -1,8 +1,8 @@ -# Code generated by KubeVela templates. DO NOT EDIT. -apiVersion: core.oam.dev/v1alpha2 +apiVersion: core.oam.dev/v1beta1 kind: TraitDefinition metadata: name: autoscale + namespace: vela-system annotations: definition.oam.dev/description: "Automatically scales workloads by resource utilization metrics or cron triggers." spec: @@ -19,71 +19,68 @@ spec: name: keda url: https://kedacore.github.io/charts version: 2.0.0-rc3 - template: | - import "strconv" - - outputs: autoscaler: { - apiVersion: "standard.oam.dev/v1alpha1" - kind: "Autoscaler" - spec: { - minReplicas: parameter.min - maxReplicas: parameter.max - if parameter["cpuPercent"] != _|_ && parameter["cron"] != _|_ { - triggers: [cpuScaler, cronScaler] - } - if parameter["cpuPercent"] != _|_ && parameter["cron"] == _|_ { - triggers: [cpuScaler] - } - if parameter["cpuPercent"] == _|_ && parameter["cron"] != _|_ { - triggers: [cronScaler] - } - } - } - - cpuScaler: { - type: "cpu" - condition: { - type: "Utilization" - if parameter["cpuPercent"] != _|_ { - // Temporarily use `strconv` for type converting. This bug will be fixed in kubevela#585 - value: strconv.FormatInt(parameter.cpuPercent, 10) - } - } - } - - cronScaler: { - type: "cron" - if parameter["cron"] != _|_ && parameter.cron["replicas"] != _|_ { - condition: { - startAt: parameter.cron.startAt - duration: parameter.cron.duration - days: parameter.cron.days - replicas: strconv.FormatInt(parameter.cron.replicas, 10) - timezone: parameter.cron.timezone - } - } - } - - parameter: { - // +usage=Minimal replicas of the workload - min: int - // +usage=Maximal replicas of the workload - max: int - // +usage=Specify the value for CPU utilization, like 80, which means 80% - // +alias=cpu-percent - cpuPercent?: int - // +usage=Cron type auto-scaling. Just for `appfile`, not available for Cli usage - cron?: { - // +usage=The time to start scaling, like `08:00` - startAt: string - // +usage=For how long the scaling will last - duration: string - // +usage=Several workdays or weekends, like "Monday, Tuesday" - days: string - // +usage=The target replicas to be scaled to - replicas: int - // +usage=Timezone, like "America/Los_Angeles" - timezone: string - } - } - + schematic: + cue: + template: | + import "strconv" + outputs: autoscaler: {{ + apiVersion: "standard.oam.dev/v1alpha1" + kind: "Autoscaler" + spec: { + minReplicas: parameter.min + maxReplicas: parameter.max + if parameter["cpuPercent"] != _|_ && parameter["cron"] != _|_ { + triggers: [cpuScaler, cronScaler] + } + if parameter["cpuPercent"] != _|_ && parameter["cron"] == _|_ { + triggers: [cpuScaler] + } + if parameter["cpuPercent"] == _|_ && parameter["cron"] != _|_ { + triggers: [cronScaler] + } + } + }} + cpuScaler: { + type: "cpu" + condition: { + type: "Utilization" + if parameter["cpuPercent"] != _|_ { + // Temporarily use `strconv` for type converting. This bug will be fixed in kubevela#585 + value: strconv.FormatInt(parameter.cpuPercent, 10) + } + } + } + cronScaler: { + type: "cron" + if parameter["cron"] != _|_ && parameter.cron["replicas"] != _|_ { + condition: { + startAt: parameter.cron.startAt + duration: parameter.cron.duration + days: parameter.cron.days + replicas: strconv.FormatInt(parameter.cron.replicas, 10) + timezone: parameter.cron.timezone + } + } + } + parameter: { + // +usage=Minimal replicas of the workload + min: int + // +usage=Maximal replicas of the workload + max: int + // +usage=Specify the value for CPU utilization, like 80, which means 80% + // +alias=cpu-percent + cpuPercent?: int + // +usage=Cron type auto-scaling. Just for `appfile`, not available for Cli usage + cron?: { + // +usage=The time to start scaling, like `08:00` + startAt: string + // +usage=For how long the scaling will last + duration: string + // +usage=Several workdays or weekends, like "Monday, Tuesday" + days: string + // +usage=The target replicas to be scaled to + replicas: int + // +usage=Timezone, like "America/Los_Angeles" + timezone: string + } + } \ No newline at end of file diff --git a/docs/examples/registry/dynamic-sa.yaml b/docs/examples/registry/dynamic-sa.yaml index a771e421e..f4fdc6b6f 100644 --- a/docs/examples/registry/dynamic-sa.yaml +++ b/docs/examples/registry/dynamic-sa.yaml @@ -1,4 +1,4 @@ -apiVersion: core.oam.dev/v1alpha2 +apiVersion: core.oam.dev/v1beta1 kind: TraitDefinition metadata: annotations: @@ -8,27 +8,27 @@ spec: appliesToWorkloads: - webservice - worker - extension: - template: |- - processing: { - output: { - credentials?: string - } - http: { - method: *"GET" | string - url: parameter.serviceURL - request: { - header: { - "authorization.token": parameter.uidtoken - } - } - } - } - patch: { - spec: template: spec: serviceAccountName: processing.output.credentials - } - - parameter: { - uidtoken: string - serviceURL: string - } + schematic: + cue: + template: |- + processing: { + output: { + credentials?: string + } + http: { + method: *"GET" | string + url: parameter.serviceURL + request: { + header: { + "authorization.token": parameter.uidtoken + } + } + } + } + patch: { + spec: template: spec: serviceAccountName: processing.output.credentials + } + parameter: { + uidtoken: string + serviceURL: string + } \ No newline at end of file diff --git a/docs/examples/registry/for-loop.yaml b/docs/examples/registry/for-loop.yaml index cfeaf9a0c..10ce79c99 100644 --- a/docs/examples/registry/for-loop.yaml +++ b/docs/examples/registry/for-loop.yaml @@ -1,28 +1,29 @@ -apiVersion: core.oam.dev/v1alpha2 +apiVersion: core.oam.dev/v1beta1 kind: TraitDefinition metadata: name: expose + namespace: vela-system spec: - extension: - template: | - parameter: { - domain: string - http: [string]: int - } - - outputs: { - for k, v in parameter.http { - "\(k)": { - apiVersion: "v1" - kind: "Service" - spec: { - selector: - app: context.name - ports: [{ - port: v - targetPort: v - }] - } - } - } - } \ No newline at end of file + schematic: + cue: + template: |- + parameter: { + domain: string + http: [string]: int + } + outputs: { + for k, v in parameter.http { + "\(k)": { + apiVersion: "v1" + kind: "Service" + spec: { + selector: + app: context.name + ports: [{ + port: v + targetPort: v + }] + } + } + } + } \ No newline at end of file diff --git a/docs/examples/registry/initcontainer.yaml b/docs/examples/registry/initcontainer.yaml index dabbd599f..6e27de73c 100644 --- a/docs/examples/registry/initcontainer.yaml +++ b/docs/examples/registry/initcontainer.yaml @@ -1,49 +1,50 @@ -apiVersion: core.oam.dev/v1alpha2 +apiVersion: core.oam.dev/v1beta1 kind: TraitDefinition metadata: annotations: definition.oam.dev/description: "add an init container and use shared volume with pod" name: init-container + namespace: vela-system spec: appliesToWorkloads: - webservice - worker - extension: - template: |- - patch: { - spec: template: spec: { - // +patchKey=name - containers: [{ - name: context.name - // +patchKey=name - volumeMounts: [{ - name: parameter.mountName - mountPath: parameter.appMountPath - }] - }] - initContainers: [{ - name: parameter.name - image: parameter.image - command: parameter.command - // +patchKey=name - volumeMounts: [{ - name: parameter.mountName - mountPath: parameter.initMountPath - }] - }] - // +patchKey=name - volumes: [{ - name: parameter.mountName - emptyDir: {} - }] - } - } - - parameter: { - name: string - image: string - command?: [...string] - mountName: *"workdir" | string - appMountPath: string - initMountPath: string - } + schematic: + cue: + template: |- + patch: { + spec: template: spec: { + // +patchKey=name + containers: [{ + name: context.name + // +patchKey=name + volumeMounts: [{ + name: parameter.mountName + mountPath: parameter.appMountPath + }] + }] + initContainers: [{ + name: parameter.name + image: parameter.image + command: parameter.command + // +patchKey=name + volumeMounts: [{ + name: parameter.mountName + mountPath: parameter.initMountPath + }] + }] + // +patchKey=name + volumes: [{ + name: parameter.mountName + emptyDir: {} + }] + } + } + parameter: { + name: string + image: string + command?: [...string] + mountName: *"workdir" | string + appMountPath: string + initMountPath: string + } \ No newline at end of file diff --git a/docs/examples/registry/kautoscale.yaml b/docs/examples/registry/kautoscale.yaml index 08e0cc786..a46e3eda4 100644 --- a/docs/examples/registry/kautoscale.yaml +++ b/docs/examples/registry/kautoscale.yaml @@ -1,24 +1,26 @@ -apiVersion: core.oam.dev/v1alpha2 +apiVersion: core.oam.dev/v1beta1 kind: TraitDefinition metadata: annotations: definition.oam.dev/description: "Specify auto scale by annotation" name: kautoscale + namespace: vela-system spec: appliesToWorkloads: - webservice # this should be some knative like workload - extension: - template: |- - import "encoding/json" - patch: { - metadata: annotations: { - "my.autoscale.ann": json.Marshal({ - "minReplicas": parameter.min - "maxReplicas": parameter.max - }) - } - } - parameter: { - min: *1 | int - max: *3 | int - } \ No newline at end of file + schematic: + cue: + template: |- + import "encoding/json" + patch: { + metadata: annotations: { + "my.autoscale.ann": json.Marshal({ + "minReplicas": parameter.min + "maxReplicas": parameter.max + }) + } + } + parameter: { + min: *1 | int + max: *3 | int + } \ No newline at end of file diff --git a/docs/examples/registry/metrics.yaml b/docs/examples/registry/metrics.yaml index 8110b1022..ab78e3c6c 100644 --- a/docs/examples/registry/metrics.yaml +++ b/docs/examples/registry/metrics.yaml @@ -1,8 +1,8 @@ -# Code generated by KubeVela templates. DO NOT EDIT. -apiVersion: core.oam.dev/v1alpha2 +apiVersion: core.oam.dev/v1beta1 kind: TraitDefinition metadata: name: metrics + namespace: vela-system annotations: definition.oam.dev/description: "Configures monitoring metrics for your service." spec: @@ -21,26 +21,28 @@ spec: namespace: monitoring url: https://prometheus-community.github.io/helm-charts version: 9.4.4 - template: |- - outputs: metrics: { - apiVersion: "standard.oam.dev/v1alpha1" - kind: "MetricsTrait" - spec: { - scrapeService: parameter - } - } - parameter: { - // +usage=Format of the metrics, default as prometheus - // +short=f - format: *"prometheus" | string - // +usage=The metrics path of the service - path: *"/metrics" | string - // +usage=The way to retrieve data which can take the values `http` or `https` - scheme: *"http" | string - enabled: *true | bool - // +usage=The port for metrics, will discovery automatically by default - port: *0 | >=1024 & <=65535 & int - // +usage=The label selector for the pods, will discovery automatically by default - selector?: [string]: string - } + schematic: + cue: + template: |- + outputs: metrics: { + apiVersion: "standard.oam.dev/v1alpha1" + kind: "MetricsTrait" + spec: { + scrapeService: parameter + } + } + parameter: { + // +usage=Format of the metrics, default as prometheus + // +short=f + format: *"prometheus" | string + // +usage=The metrics path of the service + path: *"/metrics" | string + // +usage=The way to retrieve data which can take the values `http` or `https` + scheme: *"http" | string + enabled: *true | bool + // +usage=The port for metrics, will discovery automatically by default + port: *0 | >=1024 & <=65535 & int + // +usage=The label selector for the pods, will discovery automatically by default + selector?: [string]: string + } diff --git a/docs/examples/registry/node-affinity.yaml b/docs/examples/registry/node-affinity.yaml index c86a037f5..577bca3c1 100644 --- a/docs/examples/registry/node-affinity.yaml +++ b/docs/examples/registry/node-affinity.yaml @@ -1,40 +1,41 @@ -apiVersion: core.oam.dev/v1alpha2 +apiVersion: core.oam.dev/v1beta1 kind: TraitDefinition metadata: annotations: definition.oam.dev/description: "affinity specify node affinity and toleration" name: node-affinity + namespace: vela-system 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 - } + schematic: + cue: + 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 + } \ No newline at end of file diff --git a/docs/examples/registry/patch-replica.yaml b/docs/examples/registry/patch-replica.yaml index d0a9d2d54..bc7c13469 100644 --- a/docs/examples/registry/patch-replica.yaml +++ b/docs/examples/registry/patch-replica.yaml @@ -1,19 +1,21 @@ -apiVersion: core.oam.dev/v1alpha2 +apiVersion: core.oam.dev/v1beta1 kind: TraitDefinition metadata: annotations: - definition.oam.dev/description: "Manually scale the app" - name: scaler + definition.oam.dev/description: "patch replica to the app" + name: patch-replica + namespace: vela-system spec: appliesToWorkloads: - webservice - worker - extension: - template: |- - patch: { - spec: replicas: parameter.replicas - } - parameter: { - //+short=r - replicas: *1 | int - } \ No newline at end of file + schematic: + cue: + template: |- + patch: { + spec: replicas: parameter.replicas + } + parameter: { + //+short=r + replicas: *1 | int + } \ No newline at end of file diff --git a/docs/examples/registry/patch-scaler.yaml b/docs/examples/registry/patch-scaler.yaml deleted file mode 100644 index e7775e00e..000000000 --- a/docs/examples/registry/patch-scaler.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: core.oam.dev/v1alpha2 -kind: TraitDefinition -metadata: - annotations: - definition.oam.dev/description: "Manually scale the app" - name: patch-scaler -spec: - appliesToWorkloads: - - webservice - - worker - extension: - template: |- - patch: { - spec: replicas: parameter.replicas - } - parameter: { - replicas: *1 | int - } \ No newline at end of file diff --git a/docs/examples/registry/podenv.yaml b/docs/examples/registry/podenv.yaml index 8f507bf7c..1e0c87e25 100644 --- a/docs/examples/registry/podenv.yaml +++ b/docs/examples/registry/podenv.yaml @@ -1,32 +1,32 @@ -apiVersion: core.oam.dev/v1alpha2 +apiVersion: core.oam.dev/v1beta1 kind: TraitDefinition metadata: annotations: definition.oam.dev/description: "add env into your pods" name: env + namespace: vela-system spec: appliesToWorkloads: - webservice - worker - extension: - template: |- - patch: { - spec: template: spec: { - // +patchKey=name - containers: [{ - name: context.name - // +patchKey=name - env: [ - for k, v in parameter.env { - name: k - value: v - }, - ] - }] - } - } - - parameter: { - env: [string]: string - } - + schematic: + cue: + template: |- + patch: { + spec: template: spec: { + // +patchKey=name + containers: [{ + name: context.name + // +patchKey=name + env: [ + for k, v in parameter.env { + name: k + value: v + }, + ] + }] + } + } + parameter: { + env: [string]: string + } \ No newline at end of file diff --git a/docs/examples/registry/rollout.yaml b/docs/examples/registry/rollout.yaml index 301d34e70..c76c78bea 100644 --- a/docs/examples/registry/rollout.yaml +++ b/docs/examples/registry/rollout.yaml @@ -1,8 +1,8 @@ -# Code generated by KubeVela templates. DO NOT EDIT. -apiVersion: core.oam.dev/v1alpha2 +apiVersion: core.oam.dev/v1beta1 kind: TraitDefinition metadata: name: rollout + namespace: vela-system annotations: definition.oam.dev/description: "Configures Canary deployment strategy for your application." spec: @@ -20,41 +20,43 @@ spec: namespace: vela-system url: https://oam.dev/flagger/archives/ version: 1.1.0 - template: |- - outputs: canary: { - apiVersion: "flagger.app/v1beta1" - kind: "Canary" - spec: { - provider: "smi" - progressDeadlineSeconds: 60 - service: { - // Currently Traffic route is not supported, but this is required field for flagger CRD - port: 80 - // Currently Traffic route is not supported, but this is required field for flagger CRD - targetPort: 8080 - } - analysis: { - interval: parameter.interval - // max number of failed metric checks before rollback - threshold: 10 - // max traffic percentage routed to canary - // percentage (0-100) - maxWeight: 50 - // canary increment step - // percentage (0-100) - stepWeight: parameter.stepWeight - // max replicas scale up to canary - maxReplicas: parameter.replicas - } - } - } - parameter: { - // +usage=Total replicas of the workload - replicas: *2 | int - // +alias=step-weight - // +usage=Weight percent of every step in rolling update - stepWeight: *50 | int - // +usage=Schedule interval time - interval: *"30s" | string - } - + schematic: + cue: + template: |- + outputs: rollout: {{ + apiVersion: "flagger.app/v1beta1" + kind: "Canary" + spec: { + provider: "smi" + progressDeadlineSeconds: 60 + service: { + // Currently Traffic route is not supported, but this is required field for flagger CRD + port: 80 + // Currently Traffic route is not supported, but this is required field for flagger CRD + targetPort: 8080 + } + analysis: { + interval: parameter.interval + // max number of failed metric checks before rollback + threshold: 10 + // max traffic percentage routed to canary + // percentage (0-100) + maxWeight: 50 + // canary increment step + // percentage (0-100) + stepWeight: parameter.stepWeight + // max replicas scale up to canary + maxReplicas: parameter.replicas + } + } + }} + parameter: { + // +usage=Total replicas of the workload + replicas: *2 | int + // +alias=step-weight + // +usage=Weight percent of every step in rolling update + stepWeight: *50 | int + // +usage=Schedule interval time + interval: *"30s" | string + } + \ No newline at end of file diff --git a/docs/examples/registry/route.yaml b/docs/examples/registry/route.yaml index 03579bd39..b809b938a 100644 --- a/docs/examples/registry/route.yaml +++ b/docs/examples/registry/route.yaml @@ -1,5 +1,5 @@ # Code generated by KubeVela templates. DO NOT EDIT. -apiVersion: core.oam.dev/v1alpha2 +apiVersion: core.oam.dev/v1beta1 kind: TraitDefinition metadata: name: route @@ -18,37 +18,39 @@ spec: name: nginx-ingress url: https://kubernetes-charts.storage.googleapis.com/ version: 1.41.2 - template: | - outputs: route: { - apiVersion: "standard.oam.dev/v1alpha1" - kind: "Route" - spec: { - host: parameter.domain - - if parameter.issuer != "" { - tls: { - issuerName: parameter.issuer - } - } - - if parameter["rules"] != _|_ { - rules: parameter.rules - } - - provider: *"nginx" | parameter.provider - ingressClass: *"nginx" | parameter.ingressClass - } - } - parameter: { - // +usage= Domain name - domain: *"" | string - - issuer: *"" | string - rules?: [...{ - path: string - rewriteTarget: *"" | string - }] - provider?: string - ingressClass?: string - } + schematic: + cue: + template: |- + outputs: route: { + apiVersion: "standard.oam.dev/v1alpha1" + kind: "Route" + spec: { + host: parameter.domain + + if parameter.issuer != "" { + tls: { + issuerName: parameter.issuer + } + } + + if parameter["rules"] != _|_ { + rules: parameter.rules + } + + provider: *"nginx" | parameter.provider + ingressClass: *"nginx" | parameter.ingressClass + } + } + parameter: { + // +usage= Domain name + domain: *"" | string + + issuer: *"" | string + rules?: [...{ + path: string + rewriteTarget: *"" | string + }] + provider?: string + ingressClass?: string + } diff --git a/docs/examples/registry/virtualgroup.yaml b/docs/examples/registry/virtualgroup.yaml index 214cb3f66..dc9ea7a08 100644 --- a/docs/examples/registry/virtualgroup.yaml +++ b/docs/examples/registry/virtualgroup.yaml @@ -1,28 +1,30 @@ -apiVersion: core.oam.dev/v1alpha2 +apiVersion: core.oam.dev/v1beta1 kind: TraitDefinition metadata: annotations: definition.oam.dev/description: "Add virtual group labels" name: virtualgroup + namespace: vela-system spec: appliesToWorkloads: - webservice - worker - extension: - template: |- - patch: { - spec: template: { - metadata: labels: { - if parameter.type == "namespace" { - "app.namespace.virtual.group": parameter.group - } - if parameter.type == "cluster" { - "app.cluster.virtual.group": parameter.group - } - } - } - } - parameter: { - group: *"default" | string - type: *"namespace" | string - } + schematic: + cue: + template: |- + patch: { + spec: template: { + metadata: labels: { + if parameter.type == "namespace" { + "app.namespace.virtual.group": parameter.group + } + if parameter.type == "cluster" { + "app.cluster.virtual.group": parameter.group + } + } + } + } + parameter: { + group: *"default" | string + type: *"namespace" | string + } \ No newline at end of file diff --git a/docs/examples/registry/webserver.yaml b/docs/examples/registry/webserver.yaml index 0666cda58..b69858d09 100644 --- a/docs/examples/registry/webserver.yaml +++ b/docs/examples/registry/webserver.yaml @@ -1,89 +1,92 @@ -apiVersion: core.oam.dev/v1alpha2 -kind: WorkloadDefinition +apiVersion: core.oam.dev/v1beta1 +kind: ComponentDefinition metadata: name: webserver annotations: definition.oam.dev/description: "webserver was composed by deployment and service" spec: - definitionRef: - name: deployments.apps - extension: - 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 + workload: + definition: + apiVersion: apps/v1 + kind: Deployment + schematic: + 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 - } + if parameter["cmd"] != _|_ { + command: parameter.cmd + } - if parameter["env"] != _|_ { - env: parameter.env - } + if parameter["env"] != _|_ { + env: parameter.env + } - if context["config"] != _|_ { - env: context.config - } + if context["config"] != _|_ { + env: context.config + } - ports: [{ - containerPort: parameter.port - }] + ports: [{ + containerPort: parameter.port + }] - if parameter["cpu"] != _|_ { - resources: { - limits: - cpu: parameter.cpu - requests: - cpu: parameter.cpu - } - } - }] - } - } - } - } - // workload can have extra object composition by using 'outputs' keyword - outputs: service: { - apiVersion: "v1" - kind: "Service" - spec: { - selector: { - "app.oam.dev/component": context.name - } - ports: [ - { - port: parameter.port - targetPort: parameter.port - }, - ] - } - } - parameter: { - image: string - cmd?: [...string] - port: *80 | int - env?: [...{ - name: string - value?: string - valueFrom?: { - secretKeyRef: { - name: string - key: string - } - } - }] - cpu?: string - } + if parameter["cpu"] != _|_ { + resources: { + limits: + cpu: parameter.cpu + requests: + cpu: parameter.cpu + } + } + }] + } + } + } + } + // workload can have extra object composition by using 'outputs' keyword + outputs: service: { + apiVersion: "v1" + kind: "Service" + spec: { + selector: { + "app.oam.dev/component": context.name + } + ports: [ + { + port: parameter.port + targetPort: parameter.port + }, + ] + } + } + parameter: { + image: string + cmd?: [...string] + port: *80 | int + env?: [...{ + name: string + value?: string + valueFrom?: { + secretKeyRef: { + name: string + key: string + } + } + }] + cpu?: string + } diff --git a/pkg/appfile/config/configmap.go b/pkg/appfile/config/configmap.go index 9ab058783..38560082c 100644 --- a/pkg/appfile/config/configmap.go +++ b/pkg/appfile/config/configmap.go @@ -21,6 +21,7 @@ import ( "strings" v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -39,7 +40,12 @@ func ToConfigMap(s Store, name, envName string, configData map[string]string) (* if err != nil { return nil, err } - var cm v1.ConfigMap + var cm = v1.ConfigMap{ + TypeMeta: metav1.TypeMeta{ + APIVersion: "v1", + Kind: "ConfigMap", + }, + } cm.SetName(name) cm.SetNamespace(namespace) cm.Data = configData diff --git a/references/appfile/api/appfile_test.go b/references/appfile/api/appfile_test.go index e17f7d1da..59b6742a0 100644 --- a/references/appfile/api/appfile_test.go +++ b/references/appfile/api/appfile_test.go @@ -330,6 +330,10 @@ outputs: ingress: { }} ac3cm := &v12.ConfigMap{ + TypeMeta: metav1.TypeMeta{ + APIVersion: "v1", + Kind: "ConfigMap", + }, Data: map[string]string{ "test": "test-value", },