You are browsing documentation for an older version. See the latest documentation here.
HostnameGenerator
This resource is experimental!
A HostnameGenerator
provides
- a template to generate hostnames from properties of
MeshServices
,MeshMultiZoneService
, andMeshExternalServices
- a selector that defines for which
MeshServices
,MeshMultiZoneService
, andMeshExternalServices
this generator runs
Defaults
Kong Mesh ships with default HostnameGenerators depending on the control plane mode and storage type.
Local MeshService in Universal zone
The following policy is automatically created on a zone control plane running in the Universal mode.
It creates a hostname for each MeshService
created in a zone.
For example, MeshService
of name redis
would obtain redis.svc.mesh.local
hostname.
type: HostnameGenerator
name: local-universal-mesh-service
spec:
selector:
meshService:
matchLabels:
kuma.io/origin: zone
template: "{{ .DisplayName }}.svc.mesh.local"
Local MeshExternalService
The following policy is automatically created on a zone control plane.
It creates a hostname for each MeshExternalService
created in a zone.
For example, MeshExternalService
of name aurora
would obtain aurora.extsvc.mesh.local
hostname.
Synced MeshService from Kubernetes zone
The following policies 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, MeshService
of name redis
and namespace redis-system
from zone east
would obtain redis.redis-system.svc.east.mesh.local
The second creates a hostname for each MeshService
synced from another Kubernetes zone that were created from a headless Service
.
For example, instance redis-0
of MeshService
of name redis
and namespace redis-system
from zone east
would obtain redis-0.redis.redis-system.svc.east.mesh.local
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, MeshService
of name redis
from zone west
would obtain redis.svc.west.mesh.local
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, MeshMultiZoneService
of name redis
would obtain redis.mzsvc.mesh.local
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, MeshExternalService
of name aurora
would obtain aurora.extsvc.mesh.local
Template
A template is a golang text template.
It is run with the function label
to retrieve labels of the MeshService
, MeshMultiZoneService
or MeshExternalService
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, if kubernetes -
.Zone
: the zone of the resource -
.Mesh
: the mesh of the resource
For example, given:
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
and
template: "{{ .DisplayName }}.{{ .Namespace }}.{{ .Mesh }}.{{ label "team" }}.mesh.local"
the generated hostname would be:
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 on the MeshService
status in addresses
:
status:
addresses:
- hostname: redis.kuma-demo.svc.east.mesh.local
origin: HostnameGenerator
hostnameGeneratorRef:
coreName: synced-kube-mesh-service