|
| 1 | +# Support for Type ExternalName Services in Transport Server |
| 2 | + |
| 3 | +The Ingress Controller supports routing requests to services of the type [ExternalName](https://kubernetes.io/docs/concepts/services-networking/service/#externalname). |
| 4 | + |
| 5 | +An ExternalName service is defined by an external DNS name that is resolved into the IP addresses, typically external to the cluster. This enables to use the Ingress Controller to route requests to the destinations outside of the cluster. |
| 6 | + |
| 7 | +**Note:** This feature is only available in NGINX Plus. |
| 8 | + |
| 9 | +# Prerequisites |
| 10 | + |
| 11 | +For the illustration purpose we will run NGINX Ingress Controller (refered as NIC in the examples) with the ```-watch-namespace=nginx-ingress,default``` option. The option enables NIC to watch selected namespaces. |
| 12 | + |
| 13 | +Any application deployed in other namespaces will be treated as an external service. |
| 14 | + |
| 15 | +We will use the ```examples/custom-resources/tls-passthrough``` application example as our backend app that will be responding to requests. |
| 16 | + |
| 17 | +# Example |
| 18 | + |
| 19 | +## 1. Deploy the tls-passthrough application |
| 20 | + |
| 21 | +1. Deploy the backend application as described in the ```examples/custom-resources/tls-passthrough``` example, and make sure it is working as described. |
| 22 | + |
| 23 | +## 2. Deploy external service to external namespace |
| 24 | + |
| 25 | +1. Deploy backend application to external namespace (```external-ns```). Note that the namespace is not being watched by ```NIC```. |
| 26 | + ```bash |
| 27 | + $ kubectl apply -f secure-app-external.yaml |
| 28 | + ``` |
| 29 | + |
| 30 | +## 3. Setup ExternalName service |
| 31 | + |
| 32 | +1. Create the service of type ```ExternalName``` |
| 33 | + ``` |
| 34 | + $ kubectl apply -f externalname-svc.yaml |
| 35 | + ``` |
| 36 | + |
| 37 | +2. Apply the config map |
| 38 | + ```bash |
| 39 | + $ kubectl apply -f nginx-config.yaml |
| 40 | + ``` |
| 41 | + |
| 42 | +## 4. Change the Transport Server to point to the ExternalName and verify if it is working correctly |
| 43 | + |
| 44 | +1. Navigate to the tls-passthrough example ```examples/custom-resources/tls-passthrough``` and open the ```transport-server-passthrough.yaml``` file. |
| 45 | + |
| 46 | +2. Replace the service name ```secure-app``` with ```externalname-service``` and apply the change. |
| 47 | + ```yaml |
| 48 | + apiVersion: k8s.nginx.org/v1alpha1 |
| 49 | + kind: TransportServer |
| 50 | + metadata: |
| 51 | + name: secure-app |
| 52 | + spec: |
| 53 | + listener: |
| 54 | + name: tls-passthrough |
| 55 | + protocol: TLS_PASSTHROUGH |
| 56 | + host: app.example.com |
| 57 | + upstreams: |
| 58 | + - name: secure-app |
| 59 | + service: externalname-service |
| 60 | + port: 8443 |
| 61 | + action: |
| 62 | + pass: secure-app |
| 63 | + ``` |
| 64 | + |
| 65 | + ``` |
| 66 | + $ kubectl apply -f transport-server-passthrough.yaml |
| 67 | + ``` |
| 68 | + |
| 69 | +3. Verify if the application is working by sending a request and check if the response is coming from the "external backend pod" (refer to to the tls-passthrough example) |
| 70 | + ```bash |
| 71 | + $ curl --resolve app.example.com:$IC_HTTPS_PORT:$IC_IP https://app.example.com:$IC_HTTPS_PORT --insecure |
| 72 | + ``` |
| 73 | + Response |
| 74 | + ``` |
| 75 | + hello from pod secure-app-external-backend-5fbf4fb494-x7bkl |
| 76 | + ``` |
0 commit comments