【kubernetes】kubectl logs connection refused


因為啟動dashboard報CrashLoopBackOff錯誤,嘗試使用logs去查看日志,結果報錯,錯誤如下:

[root@localhost ~]# kubectl -s http://192.168.37.130:8080 logs kubernetes-dashboard-v1.4.0-vceyf --namespace=kube-system
Using HTTP port: 9090
Using apiserver-host location: http://127.0.0.1:8080
Creating API server client for http://127.0.0.1:8080
Error while initializing connection to Kubernetes apiserver. This most likely means that the cluster is misconfigured (e.g., it has invalid apiserver certificates or service accounts configuration) or the --apiserver-host param points to a server that does not exist. Reason: Get http://127.0.0.1:8080/version: dial tcp 127.0.0.1:8080: getsockopt: connection refused

但是使用curl  http://192.168.37.130:8080卻是可以訪問通的

[root@localhost ~]# curl  http://192.168.37.130:8080
{
  "paths": [
    "/api",
    "/api/v1",
  ....
"/version" ] }[root@localhost ~]#

實在很奇怪,

首先懷疑是不是因為IPV6的原因導致,關閉IPV6

編輯文件/etc/sysctl.conf,
vi /etc/sysctl.conf
添加下面的行:
net.ipv6.conf.all.disable_ipv6 =1
net.ipv6.conf.default.disable_ipv6 =1
如果你想要為特定的網卡禁止IPv6,比如,對於enp0s3,添加下面的行。
net.ipv6.conf.enp0s3.disable_ipv6 =1
保存並退出文件。
執行下面的命令來使設置生效。
sysctl -p

但再次重啟服務,也還是無法訪問,原因不在此。

 從網上看這篇文章:http://blog.csdn.net/qingchi0/article/details/42538549,說

監聽的接口,如果配置為127.0.0.1則只監聽localhost,配置為0.0.0.0會監聽所有接口,這里配置為0.0.0.0。

嘗試進行修改

  把前文安裝kube-apiserver的配置文件/etc/sysconfig/kubernets/kube-apiserver修改為

INSECURE_BIND_ADDRESS="--insecure-bind-address=0.0.0.0"

  重啟服務,發現這次連本來能訪問的localhost:8080都訪問不通了,說明無效,再次嘗試將INSECURE_BIND_ADDRESS改為

INSECURE_BIND_ADDRESS="--address=0.0.0.0"

  重啟服務,

curl 127.0.0.1:8080
curl localhost:8080
curl 192.168.37.130:8080

  三種方式訪問都么有問題。

  本以為按照127.0.0.1能夠訪問通了,kubectl -s http://192.168.37.130:8080 logs kubernetes-dashboard-v1.4.0-vceyf --namespace=kube-system就能看到結果了,但結果依舊,那么就應該是提示中的另外一個問題了,

  This most likely means that the cluster is misconfigured (e.g., it has invalid apiserver certificates or service accounts configuration) 

這個就應該是證書的問題了,這個問題比較復雜,后面在系統的去研究下

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM