HostnameGenerator

Uses: Kong Mesh
Related Documentation
Minimum Version
Kong Mesh - 2.9

The HostnameGenerator resource provides:

  • A template to generate hostnames from properties of MeshServices, MeshMultiZoneService, and MeshExternalServices resources.
  • A selector that defines for which MeshServices, MeshMultiZoneService, and MeshExternalServices this generator runs.

Defaults

Kong Mesh ships with default HostnameGenerator resources based on the control plane mode and storage type.

Local MeshService in Universal zone

The following resource is automatically created on a zone control plane running in Universal mode. It creates a hostname for each MeshService created in a zone. For example, for a MeshService named redis, Kong Mesh creates a redis.svc.mesh.local hostname.

Local MeshExternalService

The following resource is automatically created on a zone control plane. It creates a hostname for each MeshExternalService created in a zone. For example, for a MeshExternalService named aurora, Kong Mesh creates a aurora.extsvc.mesh.local hostname.

Synced MeshService from Kubernetes zone

The following resources are automatically created on a global control plane and synced to all zones.

The first creates a hostname for each MeshService synced from another Kubernetes zone. For example, for a MeshService named redis with the namespace redis-system from zone east, Kong Mesh creates a redis.redis-system.svc.east.mesh.local hostname.

The second creates a hostname for each MeshService synced from another Kubernetes zone that were created from a headless Service. For example, for a Pod redis-0 with MeshService named redis, with the namespace redis-system from zone east, Kong Mesh creates a redis-0.redis.redis-system.svc.east.mesh.local hostname.

Synced MeshService from Universal zone

The following policy is automatically created on a global control plane and synced to all zones. It creates a hostname for each MeshService synced from another Universal zone. For example, for a MeshService named redis from zone west, Kong Mesh creates a redis.svc.west.mesh.local hostname.

Synced MeshMultiZoneService from a global control plane

The following policy is automatically created on a global control plane and synced to all zones. It creates a hostname for each MeshMultiZoneService synced from a global control plane. For example, for a MeshMultiZoneService named redis, Kong Mesh creates a redis.mzsvc.mesh.local hostname:

Synced MeshExternalService from a global control plane

The following policy is automatically created on a global control plane and synced to all zones. It creates a hostname for each MeshExternalService synced from a global control plane. For example, for a MeshExternalService named aurora, Kong Mesh creates a aurora.extsvc.mesh.local hostname.

Template

A template is a Golang text template. It runs with the function label to retrieve labels from the MeshService, MeshMultiZoneService, or MeshExternalService resources, as well as the following attributes:

  • .DisplayName: The name of the resource in its original zone.
  • .Namespace: The namespace of the resource in its original zone on Kubernetes
  • .Zone: The zone of the resource.
  • .Mesh: The mesh of the resource.

For example, with the following MeshService:

kind: MeshService
metadata:
  name: redis
  namespace: kuma-demo
  labels:
    kuma.io/mesh: products
    team: backend
    k8s.kuma.io/service-name: redis
    k8s.kuma.io/namespace: kuma-demo

If you use the template "{{ .DisplayName }}.{{ .Namespace }}.{{ .Mesh }}.{{ label "team" }}.mesh.local", you would get the hostname redis.kuma-demo.products.backend.mesh.local.

The generated hostname points to the first VIP known for the MeshService.

Status

Every generated hostname is recorded under the MeshService resource’s status, in the addresses field:

status:
  addresses:
    - hostname: redis.kuma-demo.svc.east.mesh.local
      origin: HostnameGenerator
      hostnameGeneratorRef:
        coreName: synced-kube-mesh-service
Something wrong?

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!