⚠️ Work in Progress
Kure is currently under active development and has not been released yet. APIs and features are subject to change.

Working with Generators

Working with Generators

Generators provide a type-safe way to create application workloads from configuration. They implement the ApplicationConfig interface and are identified by GroupVersionKind (GVK) strings.

The GVK System

Each generator is registered with a GVK identifier that uniquely identifies its type:

GVKGeneratorOutput
generators/AppWorkloadAppWorkloadDeployment, Service, ConfigMap
generators/FluxHelmFluxHelmHelmRelease, HelmRepository
generators/KurelPackageKurelPackageKurel package reference

Using Generators

From Code

import "github.com/go-kure/kure/pkg/stack/generators"

// Look up generator by GVK
factory, err := generators.GetGenerator("generators/AppWorkload")

// Create config from YAML data
config, err := factory.FromConfig(yamlData)

// Use in the domain model
app := stack.NewApplication("my-app", "default", config)

From YAML Configuration

Generators can be configured via YAML files:

apiVersion: generators/v1
kind: AppWorkload
metadata:
  name: web-frontend
spec:
  image: nginx:1.25
  replicas: 3
  ports:
    - containerPort: 80
      servicePort: 80
  env:
    - name: LOG_LEVEL
      value: info

Listing Available Generators

// List all registered generator GVKs
gvks := generators.ListRegistered()

Built-in Generators

AppWorkload

Generates a complete application deployment:

  • Deployment with configurable replicas, image, resource limits
  • Service with port mappings
  • Optional ConfigMap for configuration data
  • Optional ServiceAccount

FluxHelm

Generates Flux HelmRelease resources:

  • HelmRelease with chart reference and values
  • HelmRepository source (when needed)

KurelPackage

References kurel packages within the stack hierarchy, enabling package-based deployments alongside code-generated resources.

Custom Generators

Register your own generators:

generators.Register("mycompany/CustomApp", &MyGeneratorFactory{})

The factory must implement the generator interface, providing a FromConfig method that returns an ApplicationConfig.

Further Reading