Make Your Own Addon
Here's a blog introduces how to build addon from scratch using redis operator as example, you can read it as an end to end tutorial!
If you want to create an addon using an existing helm chart, you can refer to this section to quickly get started without going through a detailed introduction.
Quick start
We provided the vela CLI tool to help you quickly create an addon structure with examples. Optionally, it can be based on existing Helm Charts or online resources using reference objects.
For instance, to create an addon using version 12.1.6 of the MongoDB helm chart from the repository https://marketplace.azurecr.io/helm/v1/repo, use the following command:
vela addon init mongodb --helm-repo https://marketplace.azurecr.io/helm/v1/repo --chart mongodb --chart-version 12.1.16
Running this command will generate a basic addon directory in your local path:
$ ls mongodb
NOTES.cue README.md definitions metadata.yaml parameter.cue resources schemas template.cue views
You can still use this CLI tool to create an addon from a helm chart stored in an OCI registry. Here's an example:
vela addon init podinfo --helmrepo oci://ghcr.io/stefanprodan/charts --chart podinfo --chart-version 6.1.*
You can also base your addon on Kubernetes objects from remote URLs. For example, you can directly include multiple CRDs in this way:
vela addon init my-addon --url https://domain.com/crd1.yaml --url https://domain.com/crd2.yaml
The commands we introduced above can also be used together, e.g., you can base your addon on both Helm Charts and reference objects.
Basic Concept
A KubeVela addon is a collection that can contain the following three types of files;
Basic information file
that containsmetadata.yaml
andREADME.md
.OAM module file
that defines KubeVela extensibility points, including Definitions, UI-Schema or topology-rules.Application description file
that defines a KubeVela application. Typically, aDefinition
of addon should be supported by a Kubernetes operator. The Kubernetes objects of this operator should be defined in a KubeVela application. After the addon is enabled, these resources will be dispatched to the clusters by KubeVela application controller.
The picture below shows what KubeVela does when an addon is enabled. There are mainly three process:
- Addon Registry store addons which can be used to share and distribute addons anywhere, it can be any git repo or helm chart repository.
- When an addon is enabled through UX/CLI, it will pull these resource files from the Addon Registry, assemble them into a KubeVela application and apply it.
- Finally, the KubeVela controller take care the rest things and deliver the addon as a normal application to the clusters.
To make an addon, you should follow some basic rules. You need to create an addon directory to place addon resource files.
Typically, the directory hierarchy is as follows:
├── resources/
│ ├── xxx.cue
│ └── xxx.yaml
├── definitions/
├── schemas/
├── config-templates/