Skip to content

TargetGroup

A TargetGroup is a logical binding between a Vm and a LoadBalancer. It uses label selectors rather than server IDs — the VM is tagged with a label at creation time, and the load balancer discovers it via the label selector. On AWS this maps to a Target Group, on Hetzner and DigitalOcean to LB target label selectors. GCP does not support TargetGroup — use managed instance groups instead.

Property Type Required Description
name string yes Unique resource name
id string no Explicit ID (auto-generated UUID if omitted)
provider string no Provider label for multi-provider configs
tags Record<string, string> no Arbitrary key-value metadata
port number yes Target port for traffic
label string no Label selector (defaults to kyku-tg=<id>)
vm Vm | string yes Target VM reference
lb LoadBalancer | string yes Parent LoadBalancer reference
import { Vpc, Vm, LoadBalancer, TargetGroup } from '@kykucloud/types'
const myVpc = new Vpc({ name: 'my-vpc', cidr: '10.0.0.0/16', region: 'eu-central' })
const server = new Vm({
name: 'web',
instanceType: 'small',
image: 'ubuntu-24.04',
network: myVpc,
})
const lb = new LoadBalancer({
name: 'web-lb',
lbType: 'application',
vpc: myVpc,
listeners: [{ port: 80, protocol: 'http', targets: [] }],
})
const tg = new TargetGroup({
name: 'web-tg',
port: 8080,
vm: server,
lb: lb,
})
Provider Supported Backend
AWS Target Group (ALB/NLB)
GCP Not supported — use managed instance groups
Hetzner LB target with label selector
DigitalOcean LB target with label selector
  • Label selectors: The label property defaults to kyku-tg=<resource-id>. The VM’s labels are set from its tags at creation time. The LB target uses label_selector: { selector: "kyku-tg=<id>" } to discover the VM.
  • GCP: TargetGroup throws UnsupportedFeatureError. Use managed instance groups for GCP traffic distribution.
  • Hetzner: Do not set use_private_ip: true when using label selectors — the API returns an error.
  • AWS: Target Groups are a separate resource with health check configuration. The LB listener targets array should reference the TargetGroup or use the label selector pattern.
  • Circular dependencies: Avoid TargetGroup ↔ LoadBalancer cycles by making only one direction reference the other.