<p>I have created a YAML file its only job is: <code>It should immediately redirect to google.com</code></p>
<p>but it just doesn't work...</p>
<p>my <code>localhost</code> still returns <code>404-nginx</code></p>
<p>I'm on docker-desktop and my cluster version is <code>v1.21.5</code></p>
<p>here is my <code>redirect.yaml</code></p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: my-google
  annotations:
    nginx.ingress.kubernetes.io/permanent-redirect: https://www.google.com
spec:
  rules:
  - http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: doesntmatter
            port:
              number: 80
</code></pre>
<p>here is my <code>kubectl get ingress</code></p>
<pre><code>NAME          CLASS    HOSTS                          ADDRESS     PORTS   AGE
cheddar       nginx    cheddar.127.0.0.1.nip.io       localhost   80      31m
my-google     &lt;none&gt;   *                                          80      26m
stilton       nginx    stilton.127.0.0.1.nip.io       localhost   80      31m
wensleydale   nginx    wensleydale.127.0.0.1.nip.io   localhost   80      31m
</code></pre>
<p>NOTE: the other ingress sevices e.g. <code>cheddar.127.0.0.1.nip.io</code> is working perfectly...</p>

Ali
<p>I guess you forgot the ingress class name.</p>
<pre class="lang-yaml prettyprint-override"><code>spec:
  ingressClassName: nginx
  ...
</code></pre>
<p>Apart from that, you can create an <a href="https://kubernetes.io/docs/concepts/services-networking/service/#externalname" rel="nofollow noreferrer">external service</a>.</p>
<pre class="lang-yaml prettyprint-override"><code>---
apiVersion: v1
kind: Service
metadata:
  name: google
spec:
  type: ExternalName
  externalName: www.google.com
  ports:
    - name: https
      port: 443
      protocol: TCP
      targetPort: 443
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: google
  labels:
    name: google
  annotations:
    nginx.ingress.kubernetes.io/backend-protocol: HTTPS
    nginx.ingress.kubernetes.io/upstream-vhost: www.google.com
spec:
  ingressClassName: nginx
  rules:
  - http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: google
            port:
              name: https
</code></pre>
<p>Note, that the cert from your ingress controller is not the cert of google. So there can be some issues around that. One setting that may help with those kind of issues is the annotation <code>nginx.ingress.kubernetes.io/upstream-vhost</code> like shown above.</p>
