问题遇到的现象和发生背景
安装k8s,并安装dashboard,都安装成功,浏览器打开对应端口31335的时候,http方式提示:400 Bad Request
The plain HTTP request was sent to HTTPS port。如果换成https方式,则提示证书问题,接受后就超时错误。
~$ kubectl get pods,svc -n kubernetes-dashboard
NAME READY STATUS RESTARTS AGE
pod/kubernetes-dashboard-api-54b965bc6d-hj6qm 1/1 Running 0 40h
pod/kubernetes-dashboard-auth-5f97d67b97-kczqm 1/1 Running 0 40h
pod/kubernetes-dashboard-kong-57d45c4f69-c849m 1/1 Running 0 40h
pod/kubernetes-dashboard-metrics-scraper-5f7678d695-7jtwj 1/1 Running 0 40h
pod/kubernetes-dashboard-web-7787947b64-skj2m 1/1 Running 0 40h
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes-dashboard-api ClusterIP 10.109.200.225 <none> 8000/TCP 16d
service/kubernetes-dashboard-auth ClusterIP 10.107.114.161 <none> 8000/TCP 16d
service/kubernetes-dashboard-kong-proxy NodePort 10.111.120.220 <none> 443:31335/TCP 16d
service/kubernetes-dashboard-metrics-scraper ClusterIP 10.111.179.244 <none> 8000/TCP 16d
service/kubernetes-dashboard-web ClusterIP 10.111.174.255 <none> 8000/TCP 16d
操作环境、软件版本等信息
ubuntu系统 安装1.31版本的,2个服务器,一个做master,一个做node。
:~$ kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
van.tpddns.cn Ready control-plane 16d v1.31.1 192.168.0.11 <none> Ubuntu 22.04 LTS 5.15.0-25-generic docker://24.0.2
vanserver Ready <none> 16d v1.31.1 192.168.0.12 <none> Ubuntu 20.04.6 LTS 5.4.0-186-generic docker://27.3.1
尝试过的解决方法
分别查看了2个日志,看起来好像web的pod没用接到请求
~$ kubectl logs kubernetes-dashboard-kong-57d45c4f69-c849m -n kubernetes-dashboard
2024/10/28 15:45:46 [error] 1320#0: *66103 upstream timed out (110: Connection timed out) while connecting to upstream, client: 10.244.0.0, server: kong, request: "GET / HTTP/2.0", upstream: "http://10.111.174.255:8000/", host: "van.tpddns.cn:31335", request_id: "780fe21e49439c577c9b5a7546942f7e"
~$ kubectl logs kubernetes-dashboard-web-7787947b64-skj2m -n kubernetes-dashboard
I1026 23:39:47.142995 1 main.go:37] "Starting Kubernetes Dashboard Web" version="1.5.0"
I1026 23:39:47.143050 1 init.go:47] Using in-cluster config
I1026 23:39:47.143386 1 main.go:57] "Listening and serving insecurely on" address="0.0.0.0:8000"
查看了iptables,是不是有可能是转发被限制了,分别在INPUT、FORWARD、OUTPUT上都加上了ACCEPT在第一行,但是好像没有用。
:~$ sudo iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
KUBE-PROXY-FIREWALL all -- anywhere anywhere ctstate NEW /* kubernetes load balancer firewall */
KUBE-NODEPORTS all -- anywhere anywhere /* kubernetes health check service ports */
KUBE-EXTERNAL-SERVICES all -- anywhere anywhere ctstate NEW /* kubernetes externally-visible service portals */
KUBE-FIREWALL all -- anywhere anywhere
Chain FORWARD (policy DROP)
target prot opt source destination
KUBE-PROXY-FIREWALL all -- anywhere anywhere ctstate NEW /* kubernetes load balancer firewall */
KUBE-FORWARD all -- anywhere anywhere /* kubernetes forwarding rules */
KUBE-SERVICES all -- anywhere anywhere ctstate NEW /* kubernetes service portals */
KUBE-EXTERNAL-SERVICES all -- anywhere anywhere ctstate NEW /* kubernetes externally-visible service portals */
DOCKER-USER all -- anywhere anywhere
DOCKER-ISOLATION-STAGE-1 all -- anywhere anywhere
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
DOCKER all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
FLANNEL-FWD all -- anywhere anywhere /* flanneld forward */
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
KUBE-PROXY-FIREWALL all -- anywhere anywhere ctstate NEW /* kubernetes load balancer firewall */
KUBE-SERVICES all -- anywhere anywhere ctstate NEW /* kubernetes service portals */
KUBE-FIREWALL all -- anywhere anywhere
Chain DOCKER (1 references)
target prot opt source destination
ACCEPT tcp -- anywhere bogon tcp dpt:9000
ACCEPT tcp -- anywhere bogon tcp dpt:8000
ACCEPT tcp -- anywhere bogon tcp dpt:8069
ACCEPT tcp -- anywhere bogon tcp dpt:8069
ACCEPT tcp -- anywhere bogon tcp dpt:8069
Chain DOCKER-ISOLATION-STAGE-1 (1 references)
target prot opt source destination
DOCKER-ISOLATION-STAGE-2 all -- anywhere anywhere
RETURN all -- anywhere anywhere
Chain DOCKER-ISOLATION-STAGE-2 (1 references)
target prot opt source destination
DROP all -- anywhere anywhere
RETURN all -- anywhere anywhere
Chain DOCKER-USER (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere
Chain FLANNEL-FWD (1 references)
target prot opt source destination
ACCEPT all -- bogon/16 anywhere /* flanneld forward */
ACCEPT all -- anywhere bogon/16 /* flanneld forward */
Chain KUBE-EXTERNAL-SERVICES (2 references)
target prot opt source destination
Chain KUBE-FIREWALL (2 references)
target prot opt source destination
DROP all -- !localhost/8 localhost/8 /* block incoming localnet connections */ ! ctstate RELATED,ESTABLISHED,DNAT
Chain KUBE-FORWARD (1 references)
target prot opt source destination
DROP all -- anywhere anywhere ctstate INVALID nfacct-name ct_state_invalid_dropped_pkts
ACCEPT all -- anywhere anywhere /* kubernetes forwarding rules */
ACCEPT all -- anywhere anywhere /* kubernetes forwarding conntrack rule */ ctstate RELATED,ESTABLISHED
Chain KUBE-KUBELET-CANARY (0 references)
target prot opt source destination
Chain KUBE-NODEPORTS (1 references)
target prot opt source destination
Chain KUBE-PROXY-CANARY (0 references)
target prot opt source destination
Chain KUBE-PROXY-FIREWALL (3 references)
target prot opt source destination
Chain KUBE-SERVICES (2 references)
target prot opt source destination
安装过NGINX服务器发布,没用问题。
我想要达到的结果
刚用k8s,想用web管理,因为不熟悉命令。