YAML based Addon Application

Make Your Own Addon introduces the basic structure of an addon, and illustrate that any Kubernetes operator to be installed of an addon should be defined in a KubeVela application. This doc will guide you with all the details of writing the application description file with YAML.

Application description files contain two parts: application template file and resource files (files under the resources/ folder).

Application template file (template.yaml)

The YAML typed application template file only accepts a KubeVela application that can contain components, policies or workflow. A simple example is as follows:

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: velaux
  5. namespace: vela-system
  6. spec:
  7. components:
  8. - name: namespace
  9. type: k8s-objects
  10. properties:
  11. objects:
  12. - apiVersion: v1
  13. kind: Namespace
  14. metadata:
  15. name: my-namespace

In this example, we define the skeleton of an application. This application contains a k8s-objects typed component that contains one namespace typed resource. After the addon is enabled, this namespace will be applied to the clusters by KubeVela.

Resource files (YAML files in resources/ folder)

In case your template file is too large, you can split the entire content of the application into multiple files under the resources/ folder.

YAML file inresources/ folder must be Kubernetes objects, you can define many objects one by one in a file. These objects will be directly added to the application as a K8s-objects typed component during rendering. An example as follows:

  1. apiVersion: v1
  2. kind: ServiceAccount
  3. metadata:
  4. name: my-service-account
  5. namespace: default
  6. secrets:
  7. - name: my-secret

In this example, we define a ServiceAccount resource. The rendering result is:

  1. kind: Application
  2. metadata:
  3. name: example
  4. namespace: vela-system
  5. spec:
  6. components:
  7. -
  8. # ...
  9. # other contents defined in template file
  10. # ...
  11. - name: namespace
  12. type: k8s-objects
  13. components:
  14. objects:
  15. - apiVersion: v1
  16. kind: ServiceAccount
  17. metadata:
  18. name: my-service-account
  19. namespace: default
  20. secrets:
  21. - name: my-secret

We just use namespace and serviceAccount resources as an example here, other resources of an operator can also be defined in KubeVela application in the same way.

Example

An example is OCM. All files included in this addon are all YAML coded.