traefik 2.2 显示 404 页面在 kubernetes 中找不到
traefik 2.2 shows 404 page not found in kubernetes
我正在使用 traefik 2.2 在 kubernetes v1.18 中公开 kubernetes 仪表板cluster.This 是我机器中的 traefik IngressRoute 配置:
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
并且 traefik 使用 hostNetwork:true
配置并监听主机的 8000 和 8443 端口。当我在集群中使用服务 ip 访问 kubernetes 仪表板时,它显示如下:
[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>
它告诉我 kubernetes 仪表板工作正常。但是当我从本地机器访问 kubernetes 仪表板时:
[root@k8smaster ~]# curl -k --header 'Host:kubernete.dolphin.com' https://192.168.31.30:8443
404 page not found
我应该怎么做才能成功?我正在使用此命令安装 traefik:
helm install traefik traefik/traefik
没有错误日志:
我正在本地实验环境中部署我的 kubernetes,因此在 traefik 中禁用 TLS 检查修复此问题,在 Traefik 中添加配置:
containers:
- name: traefik
args:
- '--serversTransport.insecureSkipVerify=true'
然后使用它来检查是否成功:
[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>
我正在使用 traefik 2.2 在 kubernetes v1.18 中公开 kubernetes 仪表板cluster.This 是我机器中的 traefik IngressRoute 配置:
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
并且 traefik 使用 hostNetwork:true
配置并监听主机的 8000 和 8443 端口。当我在集群中使用服务 ip 访问 kubernetes 仪表板时,它显示如下:
[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>
它告诉我 kubernetes 仪表板工作正常。但是当我从本地机器访问 kubernetes 仪表板时:
[root@k8smaster ~]# curl -k --header 'Host:kubernete.dolphin.com' https://192.168.31.30:8443
404 page not found
我应该怎么做才能成功?我正在使用此命令安装 traefik:
helm install traefik traefik/traefik
没有错误日志:
我正在本地实验环境中部署我的 kubernetes,因此在 traefik 中禁用 TLS 检查修复此问题,在 Traefik 中添加配置:
containers:
- name: traefik
args:
- '--serversTransport.insecureSkipVerify=true'
然后使用它来检查是否成功:
[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>