<p>I am using google clould, GKE.</p>

<p>I have this example <code>ingress.yaml</code>:</p>

<pre><code>  1 apiVersion: extensions/v1beta1
  2 kind: Ingress
  3 metadata:
  4   name: kuard
  5   namespace: sample
  6   annotations:
  7     kubernetes.io/ingress.class: "nginx"
  8     cert-manager.io/issuer: "letsencrypt-prod"
  9     nginx.ingress.kubernetes.io/permanent-redirect: https://www.google.com
 10 spec:
 11   tls:
 12   - hosts:
 13     - example.gordion.io
 14     secretName: quickstart-example-tls
 15   rules:
 16   - host: example.gordion.io
 17     http:
 18       paths:
 19       - path: /
 20         backend:
 21           serviceName: kuard
 22           servicePort: 80
</code></pre>

<p>I need that when user request specific host, like: <code>example-2.gordion.io</code>, to be redirected to other site, outside the cluster, (on other google cluster actually), using nginx.</p>

<p>Currently I am aware only to the specific annonation <code>nginx.ingress.kubernetes.io/permanent-redirect</code> which seems to be global. How is it possible to redirct based on specific requested host in this ingress file?</p>

<p>you combine an externalName service with another ingress file:
In the following yaml file we define an <a href="https://kubernetes.io/docs/concepts/services-networking/service/#externalname" rel="nofollow noreferrer">ExternalName</a> service with the name <code>example-2.gordion.io-service</code>, which will lead to the real site service in the other cluster:</p>

<pre><code>kind: Service
apiVersion: v1
metadata:
  name: example-2.gordion.io-service
spec:
  type: ExternalName
  externalName: internal-name-of-example-2.gordion.io
</code></pre>

<p>And an ingress file to direct <code>example-2.gordion.io</code> to <code>example-2.gordion.io-service</code>:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: example-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
spec:
  rules:
  - host: example-2.gordion.io
    http:
      paths:
      - path: /
        backend:
          serviceName: example-2.gordion.io-service
          servicePort: 80

</code></pre>
