Routing egress traffic via a gateway with the Kubernetes Gateway API
This section describes how to use the Kubernetes Gateway API to route outbound HTTP traffic through an egress gateway.
Prerequisites
- Alauda Service Mesh v2 Operator is installed.
- An Istio control plane is deployed.
- Confirm Linux kernel compatibility.
Procedure
-
Create a namespace named
egress-gatewaywith the following command: -
Create a YAML file named
egress-gateway-cr.yamlthat defines the egress gateway.Example egress gateway CR file
Apply this YAML file by executing the following command:
-
Check the status of the gateway configuration by running this command:
The desired output is confirmed when the value in the
PROGRAMMEDcolumn isTrue.Example output
-
Optional : Deploy the gateway to Infra Nodes:
Click to expand
PrerequisitesAlauda Container Platform 4.2.0 or later, or upgrade Gateway API CRDs to the latest version.
a. Create a ConfigMap named
asm-kube-gateway-optionsin the same namespace where you plan to deploy your Gateway:- Specifies the configmap's name.
- Specifies the configmap's namespace same as the gateway.
- Sets node selectors and tolerations to schedule the gateway pods on Infra Nodes.
b. Reference the ConfigMap in your Gateway resource by adding the
infrastructure.parametersReffield:- Specifies the gateway's name.
- Specifies the gateway's namespace.
Verification
-
Create a namespace named
curlby executing the following command: -
Enable sidecar injection for the namespace. If your setup uses the
InPlaceupgrade strategy, run this command:NOTEIf you are using the
RevisionBasedupgrade 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
curlapplication by running this command: -
Initialize and export a
CURL_PODenvironment variable containing the name of the curl pod: -
Using the
curlclient, confirm that you can reachhttpbin.orgvia the egress gateway by entering this command:The desired output will show a response from
httpbin.org, which indicates that the egress traffic is being routed through the configured gateway.Example output