# Traefik 2.0 can not change port for dashboard

**URL:** <https://community.traefik.io/t/traefik-2-0-can-not-change-port-for-dashboard/3570>\
**Category:** Traefik v2\
**Tags:** dashboard-api\
**Created:** [December 25, 2019, 3:25am UTC](https://community.traefik.io/t/traefik-2-0-can-not-change-port-for-dashboard/3570 "2019-12-25T03:25:48Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Macrame](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/macrame/32/1330_2.png) [@Macrame](https://community.traefik.io/u/Macrame)\
**Post date:** [December 25, 2019, 3:25am UTC](https://community.traefik.io/t/traefik-2-0-can-not-change-port-for-dashboard/3570/1 "2019-12-25T03:25:48Z")

</div>

I am trying to use Traefik 2.0 on kubernetes 1.16.2 and found it does not support to change the port of dashboard. It tries to bind the port 8080 which was used by kube-apiserver.

```auto
kind: DaemonSet
apiVersion: apps/v1
...
          volumeMounts:
          - mountPath: "/config"
            name: "config"
          - mountPath: "/crts"
            name: "tls-certs"
          args:
            - --api
            - --log.level=INFO
            - --accesslog
            - --entrypoints.http.Address=:80
            - --entrypoints.https.Address=:443
            - --providers.kubernetescrd
            - --providers.kubernetesingress
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: https-redirect
...
  - match: Host(`traefik-dashboard-xxxx`)
    kind: Rule
    middlewares:
    - name: http-auth
    priority: 50
    services:
    - name: api@internal
      port: 8080

```

And the kubernetes log:

```auto
level=error msg="Cannot create service: service not found xxx/api@internal" namespace=xxx serviceName=api@internal providerName=kubernetescrd ingress=https-redirect servicePort=8080

```

Whatever I change the port, it does not work.

---

<div class="post-metadata">

**Author:** ![ldez](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/ldez/32/5_2.png) [@ldez](https://community.traefik.io/u/ldez)\
**Post date:** [December 25, 2019, 3:34am UTC](https://community.traefik.io/t/traefik-2-0-can-not-change-port-for-dashboard/3570/2 "2019-12-25T03:34:57Z")

</div>

Hello,

1. you have to use Traefik v2.1 because it's the current stable version.
2. you have to read "Dashboard Dynamic Configuration Examples" in [https://docs.traefik.io/v2.1/operations/dashboard/#secure-mode](https://docs.traefik.io/v2.1/operations/dashboard/#secure-mode)
3. you have to define the entrypoint of your IngressRoute [https://docs.traefik.io/v2.1/routing/providers/kubernetes-crd/#traefik-ingressroute-definition](https://docs.traefik.io/v2.1/routing/providers/kubernetes-crd/#traefik-ingressroute-definition)

```auto
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: ingressroutefoo

spec:
  entryPoints:
    - web
# ...

```

---

<div class="post-metadata">

**Author:** ![Macrame](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/macrame/32/1330_2.png) [@Macrame](https://community.traefik.io/u/Macrame)\
**Post date:** [December 25, 2019, 4:06am UTC](https://community.traefik.io/t/traefik-2-0-can-not-change-port-for-dashboard/3570/3 "2019-12-25T04:06:31Z")

</div>

Now, I upgraded to the v2.1.1 version.

```auto
kind: DaemonSet
apiVersion: apps/v1
...
spec:
  ...
    spec:
      serviceAccountName: traefik-ingress-controller
      hostNetwork: true
...
      containers:
        - name: traefik
          image: traefik:v2.1.1
          volumeMounts:
          - mountPath: "/config"
            name: "config"
          - mountPath: "/crts"
            name: "tls-certs"
          args:
            - --api
            - --log.level=INFO
            - --accesslog
            - --entrypoints.http.Address=:80
            - --entrypoints.https.Address=:443
            - --providers.kubernetescrd
            - --providers.kubernetesingress
          ports:
            - name: http
              containerPort: 80
              hostPort: 80
            - name: https
              containerPort: 443
              hostPort: 443
---
---
apiVersion: v1
kind: Service
...
spec:
  ports:
    - protocol: TCP
      name: http
      port: 80
    - protocol: TCP
      name: https
      port: 443
  selector:
    app: traefik-ingress-controller
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: https-redirect
...
  - match: Host(`traefik-dashboard-xxxx`)
    kind: Rule
    middlewares:
    - name: http-auth
    priority: 50
    services:
    - name: api@internal
      port: 8080

```

And the kubernetes log:

```auto
level=error msg="kubernetes service not found: xxx/api@internal" providerName=kubernetescrd ingress=https-redirect namespace=xxx
level=error msg="Error while building TraefikService: kubernetes service not found: xxx/api@internal" providerName=kubernetescrd serviceName=traefikservice

```

---

<div class="post-metadata">

**Author:** ![ldez](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/ldez/32/5_2.png) [@ldez](https://community.traefik.io/u/ldez)\
**Post date:** [December 25, 2019, 4:09am UTC](https://community.traefik.io/t/traefik-2-0-can-not-change-port-for-dashboard/3570/4 "2019-12-25T04:09:46Z")

</div>

the current stable version is v2.1.1

---

<div class="post-metadata">

**Author:** ![Macrame](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/macrame/32/1330_2.png) [@Macrame](https://community.traefik.io/u/Macrame)\
**Post date:** [December 25, 2019, 4:11am UTC](https://community.traefik.io/t/traefik-2-0-can-not-change-port-for-dashboard/3570/5 "2019-12-25T04:11:10Z")

</div>

I don't have a public external loadbalancer. So I set the DaemonSet to use the host network. I hope it can listen the port 80, 443, and 6080 instead of 8080 which was bound by kube-apiserver.  
There are 2 problem to me:

1. How to set the port of dashboard or can it use the 80/443 port to access via ingress rule?
2. If use the dashboard port, k8s logs api@internal service not found.

Oh, sorry, I am using the version v2.1.1

---

<div class="post-metadata">

**Author:** ![ldez](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/ldez/32/5_2.png) [@ldez](https://community.traefik.io/u/ldez)\
**Post date:** [December 25, 2019, 4:15am UTC](https://community.traefik.io/t/traefik-2-0-can-not-change-port-for-dashboard/3570/6 "2019-12-25T04:15:04Z")

</div>

When you are using the api in the secure mode, the port used is the port of the entrypoint of the InrgressRoute (not 8080) because it's an internal service (no port)

from the documentation:

```auto
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: traefik-dashboard
spec:
  entryPoints:
    - http
  routes:
  - match: Host(`traefik.domain.com`)
    kind: Rule
    services:
    - name: api@internal
      kind: TraefikService

```

[https://docs.traefik.io/v2.1/operations/dashboard/#secure-mode](https://docs.traefik.io/v2.1/operations/dashboard/#secure-mode)

---

<div class="post-metadata">

**Author:** ![Macrame](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/macrame/32/1330_2.png) [@Macrame](https://community.traefik.io/u/Macrame)\
**Post date:** [December 25, 2019, 5:05am UTC](https://community.traefik.io/t/traefik-2-0-can-not-change-port-for-dashboard/3570/8 "2019-12-25T05:05:36Z")

</div>

Thank you very much. BTW, could I change the port for dashboard if I want to use it in Insecure Mode? Thanks again.

---

<div class="post-metadata">

**Author:** ![rsoika](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/rsoika/32/1470_2.png) [@rsoika](https://community.traefik.io/u/rsoika)\
**Post date:** [January 26, 2020, 10:49pm UTC](https://community.traefik.io/t/traefik-2-0-can-not-change-port-for-dashboard/3570/9 "2020-01-26T22:49:22Z")

</div>

@Macrame, can you please provide an examples how all the objects need to be configures. I am struggling to setup traefik 2.1 in kubernetes 17.1 since days. I am not the kubernetes expert and need a coherent example of the deployment, the service and the IngressRoute.
