<p>I want to expose the web service through ingress with hostNetwork setting to true, but when I try to reach the <code>www.example.com/example-api</code>api, the response always return <code>404 not found</code> error code for me.</p>
<pre><code>--- Ingress
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: example-ingress
spec:
  tls:
  - hosts:
    - www.example.com
    secretName: example-tls
  rules:
  - host: www.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: example-service
            port:
              number: 3000

--- service
apiVersion: v1
kind: Service
metadata:
  name: example-service
spec:
  selector:
    app: example
  ports:
    - name: example-api
      port: 3000
      targetPort: example-api # 3000
</code></pre>

ccd
<p>This is because I have not defined the nginx class for ingress.</p>
<pre><code>--- Ingress
...
metadata:
  annotations:
    kubernetes.io/ingress.class: &quot;nginx&quot;
  name: example-ingress
...
</code></pre>
