<p>I am having trouble accessing my k8s api through its ingress controller. Using port-forward to my pod IP ClusterIP service, I can verify that the api is accessible. However, when trying to access through the ingress setup, the IP address is not accessible. How do I debug it?</p>
<p>My Deployment is setup as follows:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: weather-api
  labels:
    app: webapi
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ingress-weather
  template:
    metadata:
      labels:
        app: ingress-weather
        api: weather
    spec:
      containers:
        - name: api
          image: xyz/weatherforecast:v2
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 80
              protocol: TCP
            - containerPort: 443
              protocol: TCP   </code></pre>
</div>
</div>
</p>
<p>Service:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>apiVersion: v1
kind: Service
metadata:
  name: api-svc
spec:
  ports:
    - port: 8100
      targetPort: 80
      name: web
  selector:
    app: ingress-weather
  type: ClusterIP</code></pre>
</div>
</div>
</p>
<p>And ingress controller:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /
  name: api-ingress
  namespace: app
spec:
  rules:
    - http:
        paths:
        - path: /api
          pathType: Prefix
          backend:
            service: 
              name: api-svc
              port: 
                number: 8100</code></pre>
</div>
</div>
</p>
<p>Using either of the following port-forwards, allows me to access my api through //localhost:8080/:</p>
<pre><code>kubectl port-forward pod/weather-api-99c9c7fd6-7sr6z 8080:80
kubectl port-forward service/api-svc 8080:8100
</code></pre>
<p>kubectl get svc -n ingress-nginx returns:</p>
<pre><code>NAME                                 TYPE           CLUSTER-IP     EXTERNAL-IP      PORT(S)                      AGE
ingress-nginx-controller             LoadBalancer   10.0.240.185   104.42.145.179   80:32294/TCP,443:31047/TCP   4d2h
ingress-nginx-controller-admission   ClusterIP      10.0.116.19    &lt;none&gt;           443/TCP                      4d2h
</code></pre>
<p>But when I access //104.42.145.179:32294/api it does not resolve (times out).</p>
<p>what else can I do to find the cause of no access?</p>

Marc
<p>Not sure why you have mentioned the <strong>32294</strong> you access it directly.</p>
<p>Try something like, as you have now ingress controller with port <strong>80</strong> &amp; <strong>443</strong></p>
<p><a href="http://104.42.145.179/api" rel="nofollow noreferrer">http://104.42.145.179/api</a></p>
<p>also, make sure your ingress controller POD is running</p>
<p><strong>Update</strong></p>
<p>Looks like you ingress is in <strong>wrong</strong> <strong>namespace</strong> : <strong>namespace: app</strong></p>
<p>while your <strong>port-forward</strong> is from the <strong>default</strong> namespace</p>
<pre><code>kubectl port-forward service/api-svc 8080:8100
</code></pre>
<p>So when the request comes to ingress it finds the <strong>service</strong> in <strong>app</strong> namespace</p>
<p>Remove the <strong>namespace</strong> from ingress and try</p>
