Version: v1.0

How-to

In this section, it will introduce how to declare Helm charts as app components via ComponentDefinition.

Before reading this part, please make sure you’ve learned the definition and template concepts.

Prerequisite

Declare ComponentDefinition

Here is an example ComponentDefinition about how to use Helm as schematic module.

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: ComponentDefinition
  3. metadata:
  4. name: webapp-chart
  5. annotations:
  6. definition.oam.dev/description: helm chart for webapp
  7. spec:
  8. workload:
  9. definition:
  10. apiVersion: apps/v1
  11. kind: Deployment
  12. schematic:
  13. helm:
  14. release:
  15. chart:
  16. spec:
  17. chart: "podinfo"
  18. version: "5.1.4"
  19. repository:
  20. url: "http://oam.dev/catalog/"

In detail:

  • .spec.workload is required to indicate the workload type of this Helm based component. Please also check for Known Limitations if you have multiple workloads packaged in one chart.
  • .spec.schematic.helm contains information of Helm release and repository which leverages fluxcd/flux2.

Declare an Application

Here is an example Application.

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: myapp
  5. namespace: default
  6. spec:
  7. components:
  8. - name: demo-podinfo
  9. type: webapp-chart
  10. properties:
  11. image:
  12. tag: "5.1.2"

The component properties is exactly the overlay values of the Helm chart.

Deploy the application and after several minutes (it may take time to fetch Helm chart), you can check the Helm release is installed.

  1. $ helm ls -A
  2. myapp-demo-podinfo default 1 2021-03-05 02:02:18.692317102 +0000 UTC deployed podinfo-5.1.4 5.1.4

Check the workload defined in the chart has been created successfully.

  1. $ kubectl get deploy
  2. NAME READY UP-TO-DATE AVAILABLE AGE
  3. myapp-demo-podinfo 1/1 1 1 66m

Check the values (image.tag = 5.1.2) from application’s properties are assigned to the chart.

  1. $ kubectl get deployment myapp-demo-podinfo -o json | jq '.spec.template.spec.containers[0].image'
  2. "ghcr.io/stefanprodan/podinfo:5.1.2"

Generate Form from Helm Based Components

KubeVela will automatically generate OpenAPI v3 JSON schema based on values.schema.json in the Helm chart, and store it in a ConfigMap in the same namespace with the definition object. Furthermore, if values.schema.json is not provided by the chart author, KubeVela will generate OpenAPI v3 JSON schema based on its values.yaml file automatically.

Please check the Generate Forms from Definitions guide for more detail of using this schema to render GUI forms.