A Service Entry adds an entry to the internal service registry of Istio so that services in the mesh can access or route traffic to these manually specified services. A Service Entry describes the properties of a service, such as its DNS name, virtual IP addresses (VIPs), ports, protocol, and endpoints. These services can be external to the mesh, such as a web API, or internal services that are not part of the cluster's service registry. You can also use the workloadSelector field to dynamically select the endpoints for a Service Entry. These endpoints can be workloads declared using WorkloadEntry objects or Kubernetes pods. This topic provides configuration examples and field descriptions for a Service Entry.
Configuration examples
Example 1: Access an external API over HTTPS from an internal application
The following example shows how an internal application can access external APIs over HTTPS. The sidecar inspects the Server Name Indication (SNI) value in the ClientHello message to route traffic to the appropriate external service.
Example 2: Use a service entry with TLS routing in a virtual service
The following example shows how to use a service entry with TLS routing in a virtual service to route traffic to an internal egress firewall based on the SNI value.
Example 3: Forward all traffic for external services through a dedicated egress gateway
The following example shows how to forward all traffic for external services through a dedicated egress gateway. The exportTo field controls the visibility of the Service Entry to other namespaces in the mesh. By default, the service is exported to all namespaces. The following example restricts visibility to the current namespace, which is represented by `.`, preventing other namespaces from using it.
Example 4: Use a wildcard character in the host of an external service
The following example shows how to use a wildcard character in the host of an external service. If the connection must be routed to the IP address requested by the application (that is, the application resolves the DNS and attempts to connect to a specific IP), you must set the resolution mode to NONE.
Example 5: Obtain a service through a Unix domain socket on the client host
The following example shows how to access a service through a Unix domain socket on the client host. To use a Unix address endpoint, you must set resolution to STATIC.
Example 6: Create a VirtualService for an HTTP service backed by multiple DNS-addressable endpoints
For HTTP-based services, you can create a VirtualService backed by multiple DNS-addressable endpoints. In this case, the application can use the HTTP_PROXY environment variable to transparently reroute API calls for the VirtualService to a selected backend. For example, the following configuration creates a non-existent external service named foo.bar.com that is backed by three domain names: us.foo.bar.com:8080, uk.foo.bar.com:9080, and in.foo.bar.com:7080. When HTTP_PROXY=http://localhost/, application calls to http://foo.bar.com are load balanced across the three domains. For example, a call to http://foo.bar.com/baz might be converted to http://uk.foo.bar.com/baz.
Example 7: ServiceEntry with a SPIFFE-compliant subject alternative name
Field descriptions
ServiceEntry
A ServiceEntry adds service records to the internal service registry of Service Mesh.
Field | Type | Required | Description |
hosts | string[] | Yes | The hosts associated with the ServiceEntry. DNS names with a wildcard prefix are supported.
Note the following about this field:
|
addresses | string[] | No | The virtual IP addresses or CIDR prefixes associated with the service. This field does not support Unix domain socket addresses. For HTTP traffic, the generated routing configuration includes HTTP routing domains for the values in the addresses and hosts fields, and identifies the destination based on the HTTP Host and Authority headers.
|
ports | Yes | The ports associated with the ServiceEntry. If endpoints is a Unix domain socket address, only one port can be configured. | |
location | No | Specifies whether the service is considered external to the mesh or part of the mesh. | |
resolution | Yes | The service resolution mode for the hosts. When the resolution mode is set to NONE, traffic to any IP on a TCP port that does not have an associated IP address is allowed (for example, 0.0.0.0:<port>). | |
endpoints | No | One or more endpoints associated with the service. You can specify either endpoints or workloadSelector, but not both. | |
workloadSelector | No | Applies only to MESH_INTERNAL services. You can specify either endpoints or workloadSelector, but not both. Selects one or more Kubernetes pods based on their labels. | |
exportTo | string[] | No | A list of namespaces to which this service is exported. Exporting a service allows it to be used by sidecars, gateways, and virtual services defined in other namespaces. This feature provides a mechanism for service owners and mesh administrators to control service visibility across namespace boundaries.
For a Kubernetes Service, you can achieve the same effect by setting the |
subjectAltNames | string[] | No | If specified, the proxy verifies that the server certificate's subject alternative names match one of the specified values. |
ServicePort
ServicePort describes the properties of a specific port of a service.
Field | Type | Required | Description |
number | uint32 | Yes | A valid non-negative integer port number. |
protocol | string | Yes | The protocol exposed on the port. Valid values are HTTP, HTTPS, GRPC, HTTP2, MONGO, TCP, or TLS. TLS indicates that the connection is routed to the destination based on the SNI header without terminating the TLS connection. |
name | string | Yes | A label assigned to the port. |
targetPort | uint32 | No | The port number on the endpoint that receives the traffic. If not set, this defaults to the value of number. |
ServiceEntry.Location
Location specifies whether the service is internal or external to the Service Mesh. The features of the Service Mesh, such as mutual TLS (mTLS) authentication and policy enforcement, differ for services inside and outside the mesh. When communicating with services outside the mesh, mTLS authentication is disabled, and policy enforcement is performed on the client side instead of the server side.
Field | Description |
MESH_EXTERNAL | Indicates that the service is outside the mesh. This is typically used for external services accessed through an API. |
MESH_INTERNAL | Indicates that the service is part of the mesh. This is used to indicate that the service is added to the mesh but is not a service provided by Kubernetes. |
ServiceEntry.Resolution
Resolution determines how the proxy resolves the IP addresses of the network endpoints associated with the service to route requests to one of them. The resolution mode specified here does not affect how the application resolves the IP address associated with the service. The application may still need to use DNS to resolve the service to an IP address so that the outbound traffic can be captured by the proxy. For HTTP services, the application can communicate with the service defined in the hosts field by communicating directly with the proxy, for example, by setting HTTP_PROXY.
Field | Description |
NONE | Assumes that the incoming connection is already resolved to a specific destination IP address. Such connections are typically routed through the proxy using mechanisms like IP Table REDIRECT or eBPF. After performing any routing-related transformations, the proxy forwards the connection to the IP address to which the connection is bound. |
STATIC | Uses the static IP addresses specified in the endpoints as the backend instances associated with the service. |
DNS | Attempts to resolve the IP address by asynchronously querying the environment's DNS. DNS resolution cannot be used with Unix domain socket endpoints.
|
DNS_ROUND_ROBIN | Attempts to resolve the IP address by asynchronously querying the environment's DNS. Unlike DNS, DNS_ROUND_ROBIN uses only the first IP address returned when a new connection needs to be initiated, without relying on the full result of the DNS resolution. Connections to the host are preserved even if DNS records change frequently, which eliminates connection pool exhaustion and connection looping issues. This method is suitable for large, web-scale services that must be accessed through DNS. If no wildcard character is used, the proxy resolves the DNS address specified in the hosts field. DNS resolution cannot be used with Unix domain socket endpoints. |