Installing a gateway via gateway injection
This procedure explains how to install a gateway by using gateway injection.
The following procedure applies to both ingress and egress gateway deployments.
TOC
Prerequisites
- Alauda Service Mesh v2 Operator is installed.
- An Istio control plane is deployed.
- Confirm Linux kernel compatibility.
- Confirm Namespace requirements.
Procedure
-
Create a namespace for the gateway:
NOTEInstall the gateway and the Istio control plane in different namespaces.
You can install the gateway in a dedicated gateway namespace. This approach allows the gateway to be shared by many applications operating in different namespaces. Alternatively, you can install the gateway in an application namespace. In this approach, the gateway acts as a dedicated gateway for the application in that namespace.
-
Create a YAML file named
secret-reader.yamlthat defines the service account, role, and role binding for the gateway deployment. These settings enable the gateway to read the secrets, which is required for obtaining TLS credentials.secret-reader.yaml -
Apply the YAML file by running the following command:
-
Create a YAML file named
gateway-deployment.yamlthat defines the KubernetesDeploymentobject for the gateway.gateway-deployment.yaml- Indicates that the Istio control plane uses the gateway injection template instead of the default sidecar template.
- Ensure that a unique label is set for the gateway deployment.
A unique label is required so that Istio
Gatewayresources can select gateway workloads. - Enables gateway injection by setting the
sidecar.istio.io/injectlabel totrue. If the name of the Istio resource is not default you must use theistio.io/rev: <istio_revision>label instead, where the revision represents the active revision of the Istio resource. - Sets the image field to
autoso that the image automatically updates each time the pod starts. - Sets the
serviceAccountNameto the name of theServiceAccountcreated previously. - (Optional) Sets node selectors to schedule the gateway pods on Infra Nodes.
- (Optional) Sets tolerations to allow the gateway pods to be scheduled on Infra Nodes.
-
Apply the YAML file by running the following command:
-
Verify that the gateway
Deploymentrollout was successful by running the following command:You should see output similar to the following:
Example output
-
Create a YAML file named
gateway-service.yamlthat contains the KubernetesServiceobject for the gateway.gateway-service.yaml- When you set
spec.typetoClusterIPthe gatewayServiceobject can be accessed only from within the cluster. If the gateway has to handle ingress traffic from outside the cluster, setspec.typetoLoadBalancer. - Set the
selectorto the unique label or set of labels specified in the pod template of the gateway deployment that you previously created.
- When you set
-
Apply the YAML file by running the following command:
-
Verify that the gateway service is targeting the endpoint of the gateway pods by running the following command:
You should see output similar to the following example:
Example output
-
Optional : Create a YAML file named
gateway-hpa.yamlthat defines a horizontal pod autoscaler for the gateway. The following example sets the minimum replicas to2and the maximum replicas to5and scales the replicas up when average CPU utilization exceeds 80% of the CPU resource limit. This limit is specified in the pod template of the deployment for the gateway.gateway-hpa.yaml- Set
spec.scaleTargetRef.nameto the name of the gateway deployment previously created.
- Set
-
Optional : Apply the YAML file by running the following command:
-
Optional : Create a YAML file named
gateway-pdb.yamlthat defines a pod disruption budget for the gateway. The following example allows gateway pods to be evicted only when at least1healthy gateway pod will remain on the cluster after the eviction.gateway-pdb.yaml- Set the
spec.selector.matchLabelsto the unique label or set of labels specified in the pod template of the gateway deployment previously created.
- Set the
-
Optional : Apply the YAML file by running the following command: