traefik 2.2 shows 404 page not found in kubernetes

7/17/2020

I am using traefik 2.2 to expose kubernetes dashboard in kubernetes v1.18 cluster.This is my traefik IngressRoute config in my machine:

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: kubernetes-dashboard-route
  namespace: default
spec:
  entryPoints:
    - websecure
  routes:
    - match: Host(`kubernete.dolphin.com`) 
      kind: Rule
      services:
        - name: kubernetes-dashboard
          port: 443

and the traefik was using hostNetwork:true config and listening in host machine's 8000 and 8443 port. When I am using service ip in cluster to access kubernetes dashboard, it shows like this:

[root@k8smaster ~]# curl -k https://10.20.57.188:443
<!--
Copyright 2017 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<!doctype html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <title>Kubernetes Dashboard</title>
  <link rel="icon"
        type="image/png"
        href="assets/images/kubernetes-logo.png" />
  <meta name="viewport"
        content="width=device-width">
<link rel="stylesheet" href="styles.988f26601cdcb14da469.css"></head>

<body>
  <kd-root></kd-root>
<script src="runtime.ddfec48137b0abfd678a.js" defer></script><script src="polyfills-es5.d57fe778f4588e63cc5c.js" nomodule defer></script><script src="polyfills.49104fe38e0ae7955ebb.js" defer></script><script src="scripts.391d299173602e261418.js" defer></script><script src="main.b94e335c0d02b12e3a7b.js" defer></script></body>

</html>

it tell me the kubernetes dashboard works fine. But when I access kubernetes dashboard from local machine:

[root@k8smaster ~]# curl -k --header 'Host:kubernete.dolphin.com' https://192.168.31.30:8443
404 page not found

what should I do to make it successful? I am install traefik using this command:

helm install traefik traefik/traefik

there is no error logs:

enter image description here

-- Dolphin
kubernetes
traefik

1 Answer

7/18/2020

I am deployment my kubernetes in local experimental environment, so disable the TLS check in traefik fix this problem, add config in Traefik:

containers:
- name: traefik
    args:
      - '--serversTransport.insecureSkipVerify=true'

and then using this to check if success:

[root@k8smaster ~]# curl -k --header "Host: kubernetes.dolphin.com" http://192.168.31.30:8443
<!--
Copyright 2017 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<!doctype html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <title>Kubernetes Dashboard</title>
  <link rel="icon"
        type="image/png"
        href="assets/images/kubernetes-logo.png" />
  <meta name="viewport"
        content="width=device-width">
<link rel="stylesheet" href="styles.988f26601cdcb14da469.css"></head>

<body>
  <kd-root></kd-root>
<script src="runtime.ddfec48137b0abfd678a.js" defer></script><script src="polyfills-es5.d57fe778f4588e63cc5c.js" nomodule defer></script><script src="polyfills.49104fe38e0ae7955ebb.js" defer></script><script src="scripts.391d299173602e261418.js" defer></script><script src="main.b94e335c0d02b12e3a7b.js" defer></script></body>

</html>
-- Dolphin
Source: StackOverflow