diff --git a/tutorials/deploy-istio-kapsule-proxy-protocol/index.mdx b/tutorials/deploy-istio-kapsule-proxy-protocol/index.mdx index 2ebadd064b..5c6f2e4ce6 100644 --- a/tutorials/deploy-istio-kapsule-proxy-protocol/index.mdx +++ b/tutorials/deploy-istio-kapsule-proxy-protocol/index.mdx @@ -10,7 +10,7 @@ categories: - load-balancer tags: kubernetes load-balancer proxy-protocol istio dates: - validation: 2025-02-18 + validation: 2025-03-13 posted: 2025-02-18 --- @@ -33,77 +33,243 @@ This tutorial describes the steps required to deploy Istio on a Scaleway Kuberne helm repo add istio https://istio-release.storage.googleapis.com/charts helm repo update ``` +2. Create a Kubernetes namespace for Istio: + ``` + kubectl create namespace istio-system + ``` -2. Install the Istio control plane: +3. Install the Istio base and control plane into the previously created namesapce: ``` - helm install istiod istio/istiod -n istio-system --create-namespace + helm install istio-base istio/base -n istio-system + helm install istiod istio/istiod -n istio-system --wait ``` -3. Install the Istio ingress Gateway: +4. Install the Istio ingress Gateway: ``` - helm install istio-ingressgateway istio/gateway -n istio-system + helm install istio-ingressgateway istio/gateway -n istio-system --wait ``` -## Verify the ingress Gateway Service - -An ingress gateway service acts as an entry point for external traffic into the cluster. It is exposed via a Kubernetes LoadBalancer Service, which, in our case, uses a Scaleway Load Balancer. The Load Balancer forwards external traffic to the ingress Gateway Pod. +## Install a test application (httpbin) -1. Run the following command to retrieve the service configuration +Deploy a simple application to test how Istio works with a Load Balancer. +In this tutorial we use `httpbin` as test application. +1. Create and label a new namespace for the test application: ``` - kubectl get svc istio-ingressgateway -n istio-system -o yaml + kubectl create namespace test-app + kubectl label namespace test-app istio-injection=enabled ``` -2. Verify that the service is of type `LoadBalancer`, and that a Scaleway Load Balancer is associated with it. +2. Apply the following configuration using `kubectl`: -## Add annotations for Proxy Protocol + ```yaml + kubectl apply -n test-app -f - < GET /get HTTP/1.1 + > Host: 51.159.112.157 + > User-Agent: curl/8.7.1 + > Accept: */* + > + * Request completely sent off + < HTTP/1.1 200 OK + < server: istio-envoy + < date: Mon, 24 Feb 2025 09:06:45 GMT + < content-type: application/json + < content-length: 491 + < access-control-allow-origin: * + < access-control-allow-credentials: true + < x-envoy-upstream-service-time: 19 + < + { + "args": {}, + "headers": { + "Accept": "*/*", + "Host": "51.159.112.157", + "User-Agent": "curl/8.7.1", + "X-Envoy-Attempt-Count": "1", + "X-Envoy-Internal": "true", + "X-Forwarded-Client-Cert": "By=spiffe://cluster.local/ns/testapp/sa/default;Hash=ddf3ba6fee32a74f9a83efd752df7960c9f3139fa1fe979370becddad3def062;Subject=\"\";URI=spiffe://cluster.local/ns/istiosystem/sa/istio-ingressgateway" + }, + "origin": "172.16.16.5", + "url": "http://51.159.112.157/get" + } + * Connection #0 to host 51.159.112.157 left intact ``` -## Configure Envoy to support Proxy Protocol +## Configuring the Scaleway Load Balancer +When you deploy a LoadBalancer service in Kubernetes, Scaleway automatically creates a Load Balancer and associates it with your service. You now need to activate `Proxy Protocol V2` for this Load Balancer. -Envoy is a proxy server used by Istio to manage and control the flow of traffic between services in the Kubernetes cluster. It is responsible for routing the traffic between services. +Modify the `istio-ingressgateway` service to add the necessary annotations: +```bash +kubectl annotate -n istio-system services istio-ingressgateway \ + service.beta.kubernetes.io/scw-loadbalancer-proxy-protocol-v2=true +kubectl annotate -n istio-system services istio-ingressgateway \ + service.beta.kubernetes.io/scw-loadbalancer-use-hostname=true +``` -1. Create an EnvoyFilter to enable Proxy Protocol support: +## Configure Proxy protocol and the X-Forwarded-For header to retrieve the source IP +1. Create an `EnvoyFilter` to enable Proxy Protocol support: ```yaml + kubectl apply -f - < GET /get HTTP/1.1 + > Host: 51.159.112.157 + > User-Agent: curl/8.7.1 + > Accept: */* + > + * Request completely sent off + < HTTP/1.1 200 OK + < server: istio-envoy + < date: Mon, 24 Feb 2025 09:11:46 GMT + < content-type: application/json + < content-length: 510 + < access-control-allow-origin: * + < access-control-allow-credentials: true + < x-envoy-upstream-service-time: 4 + < + { + "args": {}, + "headers": { + "Accept": "*/*", + "Host": "51.159.112.157", + "User-Agent": "curl/8.7.1", + "X-Envoy-Attempt-Count": "1", + "X-Envoy-External-Address": "62.210.16.37", + "X-Forwarded-Client-Cert": "By=spiffe://cluster.local/ns/test-app/sa/default;Hash=ddf3ba6fee32a74f9a83efd752df7960c9f3139fa1fe979370becddad3def062;Subject=\"\";URI=spiffe://cluster.local/ns/istio-system/sa/istio-ingressgateway" + }, + "origin": "62.210.16.37", + "url": "http://51.159.112.157/get" + } + * Connection #0 to host 51.159.112.157 left intact ``` - kubectl apply -f proxy-protocol.yaml - ``` - -## Enable X-Forwarded-For - -1. Create a file named `ingressgateway-settings.yaml` with the following content: - ```yaml +3. Configure Istio using `kubectl` to ensure that the source IP is correctly transmitted via the `X-Forwarded-For` header. + ```bash + kubectl apply -f - < GET /get HTTP/1.1 + > Host: 51.159.112.157 + > User-Agent: curl/8.7.1 + > Accept: */* + > + * Request completely sent off + < HTTP/1.1 200 OK + < server: istio-envoy + < date: Mon, 24 Feb 2025 09:14:32 GMT + < content-type: application/json + < content-length: 522 + < access-control-allow-origin: * + < access-control-allow-credentials: true + < x-envoy-upstream-service-time: 2 + < + { + "args": {}, + "headers": { + "Accept": "*/*", + "Host": "51.159.112.157", + "User-Agent": "curl/8.7.1", + "X-Envoy-Attempt-Count": "1", + "X-Envoy-External-Address": "62.210.16.37", + "X-Forwarded-Client-Cert": "By=spiffe://cluster.local/ns/test-app/sa/default;Hash=7e20594ba5421aa9df88b0d025498a5c51d02b0224daa3faea319c13a106d8b6;Subject=\"\";URI=spiffe://cluster.local/ns/istio-system/sa/istio-ingressgateway" + }, + "origin": "62.210.16.37,100.64.2.46", + "url": "http://51.159.112.157/get" + } + * Connection #0 to host 51.159.112.157 left intact ``` - curl -v http:///get - ``` - - If the configuration is correct, the response should include the `X-Forwarded-For` and `X-Envoy-External-Address` headers. - +### It may be necessary to restart the Istio IngressGateway Pods +Once you have added the configurations, you may need to restart the IngressGateway pods so that the changes to take effect. -For further support with Istio, read their [dedicated documentation](https://istio.io/latest/docs/). - \ No newline at end of file +Run the following command to delete the existing pods using `kubectl`. Kubernetes will spin up new ones automatically after you launch the command: +```bash +kubectl delete pod -n istio-system -l istio=ingressgateway +``` \ No newline at end of file