<p>I'm facing a problem to configure an ingress for traefik.</p>
<p>The design is simple :</p>
<p>I want to be able to reach port 8888 and 8080 from the host via a CI/CD flow with argocd and a simple docker application, all the stuff embedded in a cluster created with k3d. I thought that the easiest way to do that is to execute something like this :</p>
<pre><code>k3d cluster create -p 8888:8888@loadblancer -p 8080:80@loadbalancer
</code></pre>
<p>I installed everything  I need (argocd cli, kubectl...)  and defined for the application and argocd a &quot;naive&quot; ingress.</p>
<p>For argocd :</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: argocd-ingress
  namespace: argocd
  annotations:
    ingress.kubernetes.io/ssl-redirect: &quot;false&quot;
spec:
  rules:
  - host: argocd.local
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: argocd-server
            port:
              number: 80
</code></pre>
<p>For the application :</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: wil-app-ingress
  namespace: dev
  annotations:
    ingress.kubernetes.io/ssl-redirect: &quot;false&quot;
spec:
  rules:
  - host: localhost
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: wil-app-svc
            port:
              number: 8888
</code></pre>
<p>For argocd, it seems to work perfectly fine : I'm able to reach the ui, connect to it etc.</p>
<p>But for the app, I can do nothing.</p>
<p>Indeed, if I try to curl to localhost:8888 I have this response :</p>
<blockquote>
<p>empty reply from server</p>
</blockquote>
<p>When I'm trying to know how the ingresses are defined, I have this :</p>
<pre class="lang-bash prettyprint-override"><code>john@doe:~$ kubectl describe ing wil-app-ingress -n dev
Name:             wil-app-ingress
Labels:           &lt;none&gt;
Namespace:        dev
Address:          172.18.0.2
Ingress Class:    traefik
Default backend:  &lt;default&gt;
Rules:
  Host        Path  Backends
  ----        ----  --------
  localhost   
              /   wil-app-svc:8888 (10.42.0.17:8888)
Annotations:  ingress.kubernetes.io/ssl-redirect: false
Events:       &lt;none&gt;
john@doe:~$ kubectl describe ing argocd-ingress -n argocd
Name:             argocd-ingress
Labels:           &lt;none&gt;
Namespace:        argocd
Address:          172.18.0.2
Ingress Class:    traefik
Default backend:  &lt;default&gt;
Rules:
  Host          Path  Backends
  ----          ----  --------
  argocd.local  
                /   argocd-server:80 (10.42.0.16:8080)
Annotations:    ingress.kubernetes.io/ssl-redirect: false
Events:         &lt;none&gt;
</code></pre>
<p>Synthetically :</p>
<pre class="lang-bash prettyprint-override"><code>john@doe:~$ kubectl get ing --all-namespaces
NAMESPACE   NAME              CLASS     HOSTS          ADDRESS      PORTS   AGE
argocd      argocd-ingress    traefik   argocd.local   172.18.0.2   80      16m
dev         wil-app-ingress   traefik   localhost      172.18.0.2   80      14m 
</code></pre>
<p>It seems that traefik point to port 80 for both ingress. If I delete the ingress for argocd, and I curl localhost:8080, I'm able to reach the app ! Like if traefik redirect all the trafic to the same port (here, 80 and 8080 on the host).</p>
<p>I'm a noob in kubernetes, I can't figure out why this happen. Sorry if I use the wrong term for such and such a notion, I'm a beginner and it's quite complicated.</p>
<p>Can someone explain me why I have this problem ? I think maybe it is related to traefik and its basic behaviour, but I was not able to find something clear about this. Thanks !</p>

Batche
<p>Well, there is a solution. It do not answer to my initial question (how to get the application on the host port 8888 via an ingress), but it makes possible to reach the app and argocd without troubles.</p>
<p>To do so, I exposed my service following this : <a href="https://k3d.io/v5.0.1/usage/exposing_services/#2-via-nodeport" rel="nofollow noreferrer">https://k3d.io/v5.0.1/usage/exposing_services/#2-via-nodeport</a></p>
<p>It's really simple :</p>
<pre class="lang-bash prettyprint-override"><code>k3d cluster create p3-iot -p &quot;8080:80@loadbalancer&quot; -p &quot;8888:30080@agent:0&quot; --agents 2
</code></pre>
<p>Then, we have to create a service of type nodePort :</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Service
metadata:
  labels:
    app: wil-app
  name: wil-app-svc
spec:
  ports:
  - name: 8888-8888
    nodePort: 30080
    port: 8888
    protocol: TCP
    targetPort: 8888
  selector:
    app: wil-app
  type: NodePort
</code></pre>
<p>Like so, we do not have to create an ingress for the application. k3d seems to expose the service directly from the port of the service of type nodePort. I think it's not a best pratice, but it works. Another solution is to use nginx as an ingress controller. It is worth because the way to configure nginx for such a project is straightforward.</p>
<p>The rest is unchanged, we can reach argocd ui, and reach the application.</p>
<p>If someone can answer why my previous way to achieve this task did not work, I will be glad of it.</p>
