feat(defkit): experimental addon to install DefKit definition modules

Merged
BR
1mo ago
+2174-0

Description of your changes

A new experimental addon for installing DefKit definition modules (Go modules of X-Definitions, such as vela-go-definitions) as Applications, so a cluster can take its definitions from a module and keep them in step with it.

Each module is an Application whose workflow renders, waits for review, then applies:

workflow:
  steps:
    - name: render
      type: defkit-render
      properties:
        git: https://github.com/kubevela/vela-go-definitions
        version: main
        prefix: dk-
        types: [trait]
      outputs:
        - name: rendered
          valueFrom: configMap
    - name: review
      type: suspend
    - name: apply
      type: defkit-apply
      inputs:
        - from: rendered
          parameterKey: configMap
  • defkit-render runs a Job that loads the module the way vela def apply-module does and writes what it generates to a ConfigMap. It runs in its own vela-defkit namespace, under an account that may only write ConfigMaps there.
  • defkit-apply applies the rendered definitions as the Application's resources, so it tracks them and garbage collects any a new version drops.

The render tool and its Dockerfile are in render/ (it builds against KubeVela v1.11.0). Its image, oamdev/defkit-render:v0.1.0, isn't published yet: could a maintainer build and push it? It's multi-arch:

docker buildx build --platform linux/amd64,linux/arm64 -t oamdev/defkit-render:v0.1.0 experimental/addons/defkit/render/

The image parameter takes another image in the meantime.

How has this code been tested?

On k3d with KubeVela v1.10.1, with the image built from render/ and loaded into the cluster:

  • The addon enables, and its Application runs; both WorkflowStepDefinitions are installed.
  • examples/vela-definitions-traits.yaml renders vela-go-definitions at main, then suspends for review.
  • After vela workflow resume, the Application is running and all 29 traits are applied as dk-*.

Summary by cubic

Adds an experimental defkit addon that installs DefKit definition modules (Go modules of X-Definitions) as Applications. Each module is an Application whose workflow renders it in a Job, waits for review, then applies its definitions, which the Application tracks and garbage collects when a new version drops them.

The render Job runs in the vela-defkit namespace. The module's code runs in a tokenless container; only a separate write container mounts the account token, which may write config maps there and nothing else. Renders are scoped per module namespace and redact Git credentials from output and step messages. The apply step fails, applying nothing, when the render can't be read, is missing definitions.json, or produced errors.

Rollout

  • oamdev/defkit-render:v0.1.0 is not published yet; a maintainer must build and push it, or set the image parameter to a locally built image.