Integration
defkit integrates with the KubeVela ecosystem through well-defined extension points. Each definition type maps to a Kubernetes CRD managed by the KubeVela controller.
Definition Types
| Definition Type | API Group | Purpose |
|---|---|---|
ComponentDefinition | core.oam.dev/v1beta1 | Defines a workload type. Maps Go template to Kubernetes resources (Deployment, StatefulSet, Job, etc.). End users reference by name in Application YAML. |
TraitDefinition | core.oam.dev/v1beta1 | Patches or augments a workload. Uses CUE patch semantics to modify the primary output (e.g., inject env vars, set replica count, add sidecars). |
PolicyDefinition | core.oam.dev/v1alpha1 | Controls deployment topology and behavior. Used for multi-cluster override, garbage collection rules, and apply-once semantics. |
WorkflowStepDefinition | core.oam.dev/v1beta1 | Defines automation steps for the application workflow engine. Steps run sequentially or in parallel as part of Application deployment. |
go.mod Setup
Add defkit as a dependency using the KubeVela module:
go get command
go get github.com/oam-dev/kubevela/pkg/definition/defkit
Example go.mod
module my-platform
go 1.23.8
require (
github.com/oam-dev/kubevela v1.11.0
)
Package Structure
Organize definitions by type in separate packages. Each package registers its definitions via init():
Module directory layout
my-platform/
├── module.yaml # Module metadata (name, description, version)
├── go.mod
├── go.sum
├── cmd/register/main.go # Registry entry point — imports all packages
├── components/
│ ├── webservice.go # ComponentDefinition — Deployment workload
│ ├── worker.go # ComponentDefinition — background worker
│ └── statefulset.go # ComponentDefinition — StatefulSet workload
├── traits/