This section explains how to use Istio APIs to route outbound HTTP traffic via a gateway installed with gateway injection.
Create a namespace named curl
by executing the following command:
Enable sidecar injection for the namespace. If your setup uses the InPlace
upgrade strategy, run this command:
If you are using the RevisionBased
upgrade strategy, execute these commands:
To discover your <revision-name>
, run the following:
Sample output:
Label the namespace using the revision name to enable sidecar injection:
Deploy the curl
application by running this command:
Initialize and export a CURL_POD
environment variable containing the name of the curl pod:
Create a YAML file with the name http-se.yaml
to direct traffic from the mesh toward an external service. The example below defines a ServiceEntry
for a specific URL.
Example configuration
Apply this YAML file by executing the command:
Confirm that the ServiceEntry
configuration has been applied successfully. Send an HTTP request to the host specified in the previous step by running this command:
This command should yield HTTP status codes like 302
(redirect) or 200
(success), which confirms the connection is working.
Create a YAML file named http-egress-gw.yaml
that establishes an egress Gateway
and routes traffic from the mesh to the host defined for the external service.
Example configuration
Apply the YAML file by executing the command:
Create a YAML file with the name http-egress-vs.yaml
to configure a VirtualService
that will manage traffic flow from application sidecars, through the egress gateway, and to the external host.
Example configuration
Apply this YAML file by running the following command:
Reissue the HTTP request to the URL:
The terminal output should be similar to what is shown below:
Example output
Confirm that the request was routed via the gateway by running this command:
Access logging must be active for this verification step to function correctly. You can enable it by creating the following Telemetry
resource.
Your terminal should display information similar to this output:
Example output