MeshExternalService

Uses: Kong Mesh

MeshExternalService makes a destination outside the mesh into a resource the mesh understands. A policy can name it in spec.to[].targetRef, a route can send traffic to it in backendRefs, and the mesh can originate TLS to it, so an external API or database is governed by the same timeouts, retries and circuit breakers as anything inside the mesh.

On Kubernetes, this resource is accepted only in the system namespace.

Traffic to a MeshExternalService always goes through a mesh-scoped zone egress in the client’s zone. The client’s sidecar sends the request to the egress over mesh mTLS, and the egress connects to the endpoints. This path requires the following:

  • A zone egress for the mesh in the client’s zone, selected by an initialized MeshIdentity. Without one, the destination has no endpoints.
  • A MeshIdentity that selects the client proxies. A client without an identity gets no route to the destination, and the request fails locally with a 503.
  • A MeshTrafficPermission on the egress that allows the caller.
  • The MeshExternalService in the client’s reachableBackends (the kuma.io/reachable-backends annotation on Kubernetes). A proxy doesn’t get an outbound for a destination it doesn’t list, unless the control plane sets KUMA_DEFAULTS_RESTRICT_OUTBOUND=false.

Reach an external API over TLS

The following example makes api.example.com reachable from the mesh as external-api. Clients send plain HTTP to the generated hostname on port 443, and the zone egress originates TLS 1.2 or later to api.example.com:443, verifying the server certificate against that name:

Traffic matching

spec.match describes the traffic that should be routed through this resource.

Field

Value

type HostnameGenerator, the only value and the default. A hostname is generated for the service and the VIP answers on it.
port The port a client dials, 1 to 65535.
protocol tcp (default), http, http2, or grpc.

protocol decides which policies can apply. An HTTP-based value is what lets MeshHTTPRoute and the L7 parts of MeshTimeout and MeshRetry reach this destination.

There is no tls protocol value here. If the zone egress should originate TLS, set protocol to what the application speaks and turn on spec.tls. For more information, see Originating TLS.

Endpoints

spec.endpoints[] is where the traffic actually goes. Each takes an address (an IP or a hostname) and a port.

priority enables failover: lower wins, 0 is primary, and traffic moves to the next level when the endpoints above it are unhealthy.

endpoints:
  - address: api.example.com
    port: 443
    priority: 0
  - address: api-dr.example.com
    port: 443
    priority: 1

Originating TLS

spec.tls.enabled makes the zone egress originate TLS to the endpoints, which lets an application speak plaintext to a destination that requires TLS. The client’s sidecar sends the request to the egress over mesh mTLS.

Field

Value

version.min / version.max Bound the negotiated version, from TLS10 to TLS13, or TLSAuto to leave that end to Envoy.
allowRenegotiation Permit TLS renegotiation. Off by default.
verification.mode Secured, the default, verifies both the CA and the SAN. SkipSAN, SkipCA and SkipAll each drop part or all of that. With SkipAll or SkipCA, the egress accepts any certificate the endpoint presents
verification.serverName Overrides the SNI the egress sends. Must be a valid DNS name. Defaults to the first endpoint’s address when it is a hostname.
verification.subjectAltNames Names to verify in the certificate, each Exact or Prefix.
verification.caCert The CA to verify the endpoint against, as a secure data source.
verification.clientCert / clientKey A client certificate and key for mutual TLS to the endpoint. Each requires the other.

The three data source fields accept type: Secret or type: InsecureInline only.

Status

status.vip.ip is the address the generated hostname resolves to, and status.addresses lists the hostnames themselves with the generator that produced each. status.hostnameGenerators carries per-generator status.

Extensions

spec.extension hands configuration to a named extension, and in its presence endpoints and tls are no longer required, the extension validates its own configuration instead. An extension with an empty type is rejected.

Schema

FAQs

MeshPassthrough lets a proxy reach an address the mesh knows nothing about, without giving it a name. Nothing can target that traffic: no policy applies to it, and the mesh doesn’t originate TLS.

A MeshExternalService gives the destination an identity in the mesh, a VIP and a hostname, so policies and routes can name it. Use it for the dependencies that matter enough to govern, and MeshPassthrough for everything else.

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!