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
- fluxcd/flux2, make sure you have installed the flux2 in the installation guide.
Declare ComponentDefinition
Here is an example ComponentDefinition
about how to use Helm as schematic module.
apiVersion: core.oam.dev/v1beta1
kind: ComponentDefinition
metadata:
name: webapp-chart
annotations:
definition.oam.dev/description: helm chart for webapp
spec:
workload:
definition:
apiVersion: apps/v1
kind: Deployment
schematic:
helm:
release:
chart:
spec:
chart: "podinfo"
version: "5.1.4"
repository:
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 Helmrelease
andrepository
which leveragesfluxcd/flux2
.- i.e. the pec of
release
aligns withHelmReleaseSpec
and spec ofrepository
aligns withHelmRepositorySpec
.
- i.e. the pec of
Declare an Application
Here is an example Application
.
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: myapp
namespace: default
spec:
components:
- name: demo-podinfo
type: webapp-chart
properties:
image:
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.
$ helm ls -A
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.
$ kubectl get deploy
NAME READY UP-TO-DATE AVAILABLE AGE
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.
$ kubectl get deployment myapp-demo-podinfo -o json | jq '.spec.template.spec.containers[0].image'
"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.