Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Ingress-Gateway mithilfe eines externen Load-Balancers verfügbar machen
Übersicht
Mit Cloud Service Mesh können Sie Ingress-Gateways als Teil Ihres Service Mesh bereitstellen und verwalten. Sie können das Load Balancing für Ihren Cluster weiter mit Cloud Service Mesh konfigurieren. Dazu verwenden Sie externe Load Balancer (physische oder Software-Load Balancer außerhalb des Clusters), um Traffic an das Ingress-Gateway zu senden.
Zum Ausführen der Schritte in diesem Dokument benötigen Sie die folgenden Ressourcen:
Einen Kubernetes-Cluster mit installiertem Cloud Service Mesh.
Einen externen Load Balancer, der auf die Knoten zugreifen kann, auf denen Ihr Cluster ausgeführt wird. Sie konfigurieren diesen externen Load Balancer so, dass das Ingress-Gateway Ihres Clusters über External IP Address verbunden wird.
Umgebung einrichten
Führen Sie die folgenden Befehle über eine Workstation aus, die auf den Cluster zugreifen kann, den Sie verwenden möchten. Achten Sie darauf, dass das kubectl-Tool so konfiguriert ist, dass es den für Ihren Cluster spezifischen Clusterkontext verwendet.
INGRESSGATEWAY_NODE_IP sind die Knoten in Ihrem Kubernetes-Cluster, die das Ingress-Gateway hosten. Führen Sie diesen kubectl-Befehl für so viele Ingress-Knoten aus, wie Sie haben.
Ingress-Gateway erstellen
Erstellen Sie den Namespace. Dieser Namespace wird zum Bereitstellen des Ingress-Gateways verwendet.
Aktivieren Sie den Namespace für die Injection: Die Schritte hängen vom Cloud Service Mesh-Typ ab (entweder verwaltet oder im Cluster).
Verwaltet
Verwenden Sie folgenden Befehl, um die verfügbaren Release-Kanäle zu finden:
kubectl -n istio-system get controlplanerevision
Die Ausgabe sieht etwa so aus:
NAME AGE
asm-managed 6d7h
asm-managed-rapid 6d7h
In der Ausgabe ist der Wert in der NAME-Spalte das Überarbeitungslabel, das dem verfügbaren Release-Kanal für die Cloud Service Mesh-Version entspricht.
Wenden Sie das Überarbeitungslabel auf den Namespace an.
Verwenden Sie den folgenden Befehl, um das Überarbeitungslabel für istiod zu finden:
kubectl get deploy -n istio-system -l app=istiod -o \
jsonpath={.items[*].metadata.labels.'istio\.io\/rev'}'{"\n"}'
Wenden Sie das Überarbeitungslabel auf den Namespace an. Im folgenden Befehl ist REVISION der Wert des Überarbeitungslabels istiod, den Sie im vorherigen Schritt notiert haben.
serviceaccount/asm-ingressgateway created
role.rbac.authorization.k8s.io/asm-ingressgateway created
rolebinding.rbac.authorization.k8s.io/asm-ingressgateway created
deployment.apps/asm-ingressgateway created
service/asm-ingressgateway created
poddisruptionbudget.policy/asm-ingressgateway created
horizontalpodautoscaler.autoscaling/asm-ingressgateway created
Patchen Sie den Dienst ingressgateway mit der IP-Adresse des externen Load-Balancers.
Verwenden Sie die im vorherigen Schritt angezeigten NodePorts, um die Verbindung zwischen dem externen Load Balancer und dem Ingress-Gateway zu konfigurieren.
Konfigurieren Sie die Systemdiagnose in der Load-Balancer-Konfiguration.
CLUSTER_NODE_IP ist die IP-Adresse der Knoten in Ihrem Kubernetes-Cluster, auf denen das Ingress-Gateway gehostet wird. Diese IP-Adresse muss von Ihrem externen Load Balancer aus erreichbar sein. Möglicherweise müssen Sie diese Konfiguration mehrmals einrichten, einmal pro Clusterknoten.
STATUS_PORT ist der NodePort, über den die Systemdiagnose-API des Ingress-Gateways bereitgestellt wird. Sie können diese Informationen aus dem vorherigen Schritt kopieren. Sie ist für jeden Knoten im Cluster gleich.
Konfigurieren Sie Knotenpools in Ihrem Load Balancer für das Routing von HTTP- und HTTPS-Traffic. Verwenden Sie die folgende IP:PORT-Konfiguration für Traffic über Port 80 (HTTP) und Port 443 (HTTPS).
CLUSTER_NODE_IP ist die IP-Adresse der Knoten in Ihrem Kubernetes-Cluster, auf denen das Ingress-Gateway gehostet wird. Diese IP-Adresse muss von Ihrem externen Load Balancer aus erreichbar sein. Möglicherweise müssen Sie diese Konfiguration mehrmals einrichten, einmal pro Clusterknoten.
HTTP_INGRESS_PORT ist der NodePort, über den der HTTP-Traffic des Ingress-Gateways bereitgestellt wird. Sie können diese Informationen aus dem vorherigen Schritt kopieren. Sie ist für jeden Knoten im Cluster gleich.
HTTPS_INGRESS_PORT ist der NodePort, über den der HTTPS-Traffic des Ingress-Gateways bereitgestellt wird. Sie können diese Informationen aus dem vorherigen Schritt kopieren. Sie ist für jeden Knoten im Cluster gleich.
Prüfen Sie, ob die Systemdiagnosen auf Ihrem Load Balancer erfolgreich sind.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-02 (UTC)."],[],[],null,["Expose an ingress gateway using an external load balancer\n\nOverview\n\nWith Cloud Service Mesh you can deploy and manage ingress gateways as part of your\nservice mesh. You can further configure load balancing for your cluster with\nCloud Service Mesh by using external load balancers (physical or software load\nbalancers outside of the cluster) to send traffic to the ingress gateway.\n\nThis page shows you how to configure an external load balancer with Cloud Service Mesh.\nAlternatively, you can\n[set up ingress with multiple backend configs](https://github.com/GoogleCloudPlatform/gke-networking-recipes/tree/main/ingress/single-cluster/ingress-asm-multi-backendconfig).\n\nBefore you begin\n\nTo complete the steps in this document you need the following resources:\n\n- A Kubernetes cluster with Cloud Service Mesh installed.\n\n- An external load balancer that can access the nodes where your cluster is\n running. You will configure this external load balancer to front the ingress\n gateway of your cluster via the `External IP Address`.\n\nSet up your environment\n\nRun the following commands from a workstation that can access the cluster you\nintend to use. Make sure that the `kubectl` tool is configured to use the\ncluster context specific to your cluster.\n\n1. Set the environment variables.\n\n export ASM_INGRESSGATEWAY_NAMESPACE=asm-ingressgateway\n export ASM_INGRESSGATEWAY_DEPLOYMENT_NAME=asm-ingressgateway\n export ASM_INGRESSGATEWAY_SERVICE_NAME=asm-ingressgateway\n export ASM_INGRESSGATEWAY_NODE_LABEL=asm-ingressgateway\n\n2. Set the `IP address` of the external load balancer.\n\n export EXTERNAL_LB_IP_ADDRESS=\u003cvar translate=\"no\"\u003eEXTERNAL_LB_IP_ADDRESS\u003c/var\u003e\n\n3. \\[Optional\\] Label the ingress gateway nodes. This ensures that the gateway\n gets deployed to specific nodes in the cluster.\n\n kubectl label nodes \u003cvar translate=\"no\"\u003eINGRESSGATEWAY_NODE_IP\u003c/var\u003e ${ASM_INGRESSGATEWAY_NODE_LABEL}=\n\n - \u003cvar translate=\"no\"\u003eINGRESSGATEWAY_NODE_IP\u003c/var\u003e: is the node(s) in your Kubernetes cluster that hosts the ingress gateway. Run this `kubectl` command for as many ingress nodes you have.\n\nCreate the ingress gateway\n\n1. Create the namespace. This namespace will be used to deploy the ingress\n gateway.\n\n kubectl create namespace ${ASM_INGRESSGATEWAY_NAMESPACE}\n\n2. Enable the namespace for injection. The steps depend on your Cloud Service Mesh type (either managed or in-cluster).\n\n Managed\n 1. Use the following command to locate the available release channels:\n\n kubectl -n istio-system get controlplanerevision\n\n The output is similar to the following: \n\n NAME AGE\n asm-managed 6d7h\n asm-managed-rapid 6d7h\n\n In the output, the value under the `NAME` column is the revision label that corresponds to the available [release channel](/service-mesh/docs/managed/select-a-release-channel#anthos_service_mesh_versions_per_channel) for the Cloud Service Mesh version.\n 2. Apply the revision label to the namespace:\n\n kubectl label namespace ${ASM_INGRESSGATEWAY_NAMESPACE} \\\n istio-injection- istio.io/rev=\u003cvar translate=\"no\"\u003eREVISION_LABEL\u003c/var\u003e --overwrite\n\n In-cluster\n 1. Use the following command to locate the revision label on `istiod`:\n\n kubectl get deploy -n istio-system -l app=istiod -o \\\n jsonpath={.items[*].metadata.labels.'istio\\.io\\/rev'}'{\"\\n\"}'\n\n 2. Apply the revision label to the namespace. In the following command,\n \u003cvar translate=\"no\"\u003eREVISION\u003c/var\u003e is the value of the `istiod` revision\n label that you noted in the previous step.\n\n kubectl label namespace ${ASM_INGRESSGATEWAY_NAMESPACE} \\\n istio-injection- istio.io/rev=\u003cvar translate=\"no\"\u003eREVISION\u003c/var\u003e --overwrite\n\n3. Apply the [ingress gateway manifest file](https://github.com/GoogleCloudPlatform/anthos-service-mesh-samples/blob/main/docs/ingress-gateway-external-lb/ingress-gateway.yaml).\n\n kubectl --namespace ${ASM_INGRESSGATEWAY_NAMESPACE} apply --filename https://raw.githubusercontent.com/GoogleCloudPlatform/anthos-service-mesh-samples/main/docs/ingress-gateway-external-lb/ingress-gateway.yaml\n\n Expected output: \n\n serviceaccount/asm-ingressgateway created\n role.rbac.authorization.k8s.io/asm-ingressgateway created\n rolebinding.rbac.authorization.k8s.io/asm-ingressgateway created\n deployment.apps/asm-ingressgateway created\n service/asm-ingressgateway created\n poddisruptionbudget.policy/asm-ingressgateway created\n horizontalpodautoscaler.autoscaling/asm-ingressgateway created\n\n4. Patch the `ingressgateway` service with the external load balancer IP address.\n\n cat \u003c\u003cEOF \u003e asm-external-ip-patch.yaml\n spec:\n externalIPs:\n - ${EXTERNAL_LB_IP_ADDRESS}\n loadBalancerIP: ${EXTERNAL_LB_IP_ADDRESS}\n EOF\n\n kubectl --namespace ${ASM_INGRESSGATEWAY_NAMESPACE} patch service/${ASM_INGRESSGATEWAY_SERVICE_NAME} --patch \"$(cat asm-external-ip-patch.yaml)\"\n\n5. \\[Optional\\] Patch the `ingressgateway` deployment for the ingress gateway\n nodes label affinity.\n\n cat \u003c\u003cEOF \u003e asm-ingress-node-label-patch.yaml\n spec:\n template:\n spec:\n affinity:\n nodeAffinity:\n requiredDuringSchedulingIgnoredDuringExecution:\n nodeSelectorTerms:\n - matchExpressions:\n - key: ${ASM_INGRESSGATEWAY_NODE_LABEL}\n operator: Exists\n EOF\n\n kubectl --namespace ${ASM_INGRESSGATEWAY_NAMESPACE} patch deployment/${ASM_INGRESSGATEWAY_DEPLOYMENT_NAME} --patch \"$(cat asm-ingress-node-label-patch.yaml)\"\n\nSet up the external load balancer\n\nIn this section, you will configure the external load balancer to connect with\nthe ingress gateway from the cluster.\n\nFetch ingress gateway `Service` port information\n\n1. Get the `NodePorts`.\n\n export HTTP_INGRESS_PORT=$(kubectl --namespace ${ASM_INGRESSGATEWAY_NAMESPACE} get service/${ASM_INGRESSGATEWAY_SERVICE_NAME} --output jsonpath='{.spec.ports[?(@.name==\"http2\")].nodePort}')\n export HTTPS_INGRESS_PORT=$(kubectl --namespace ${ASM_INGRESSGATEWAY_NAMESPACE} get service/${ASM_INGRESSGATEWAY_SERVICE_NAME} --output jsonpath='{.spec.ports[?(@.name==\"https\")].nodePort}')\n export STATUS_PORT=$(kubectl --namespace ${ASM_INGRESSGATEWAY_NAMESPACE} get service/${ASM_INGRESSGATEWAY_SERVICE_NAME} --output jsonpath='{.spec.ports[?(@.name==\"status-port\")].nodePort}')\n\n2. Display the `NodePorts`.\n\n echo HTTP_INGRESS_PORT=${HTTP_INGRESS_PORT}\n echo HTTPS_INGRESS_PORT=${HTTPS_INGRESS_PORT}\n echo STATUS_PORT=${STATUS_PORT}\n\nConfigure the external load balancer\n\nUse the `NodePorts` displayed in the previous step to configure connectivity\nbetween the external load balancer and the ingress gateway.\n\n1. Configure the health check in your load balancer configuration.\n\n hosts: \u003cvar translate=\"no\"\u003eCLUSTER_NODE_IP\u003c/var\u003e\n Protocol: HTTP\n Port: \u003cvar translate=\"no\"\u003eSTATUS_PORT\u003c/var\u003e\n Path: /healthz/ready\n\n - \u003cvar translate=\"no\"\u003eCLUSTER_NODE_IP\u003c/var\u003e: is the IP address of the nodes in your\n Kubernetes cluster that hosts the ingress gateway. This IP address must be\n reachable from your external load balancer. You may have to set up this\n configuration multiple times, once per cluster node.\n\n - \u003cvar translate=\"no\"\u003eSTATUS_PORT\u003c/var\u003e: is the `NodePort` via which the ingress\n gateway's health status API is exposed. You can copy this information from\n the previous step. It will be the same for every node in the cluster.\n\n2. Configure node pools in your load balancer for routing `HTTP` and `HTTPS`\n traffic. Use the following `IP:PORT` configuration for traffic on port 80\n (`HTTP`) and port 443 (`HTTPS`).\n\n 80 -\u003e \u003cvar translate=\"no\"\u003eCLUSTER_NODE_IP\u003c/var\u003e:\u003cvar translate=\"no\"\u003eHTTP_INGRESS_PORT\u003c/var\u003e\n 443 -\u003e \u003cvar translate=\"no\"\u003eCLUSTER_NODE_IP\u003c/var\u003e:\u003cvar translate=\"no\"\u003eHTTPS_INGRESS_PORT\u003c/var\u003e\n\n - \u003cvar translate=\"no\"\u003eCLUSTER_NODE_IP\u003c/var\u003e: is the IP address of the nodes in your\n Kubernetes cluster that hosts the ingress gateway. This IP address must be\n reachable from your external load balancer. You may have to set up this\n configuration multiple times, once per cluster node.\n\n - \u003cvar translate=\"no\"\u003eHTTP_INGRESS_PORT\u003c/var\u003e: is the `NodePort` via which the\n ingress gateway's HTTP traffic is exposed. You can copy this information\n from the previous step. It will be the same for every node in the cluster.\n\n - \u003cvar translate=\"no\"\u003eHTTPS_INGRESS_PORT\u003c/var\u003e: is the `NodePort` via which the\n ingress gateway's HTTPS traffic is exposed. You can copy this information\n from the previous step. It will be the same for every node in the cluster.\n\nTo verify your set up, ensure that the health checks on your load balancer are\npassing.\n\nWhat's next\n\n- Read more about [Installing and upgrading gateways](/service-mesh/v1.20/docs/gateways)"]]