Ubuntu 中安装 minikube,处理启动错误


4
(1)

按照官网的文档来,https://minikube.sigs.k8s.io/docs/start/

执行下面的命令安装 minikube

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube

我这里记录一下遇到的问题:

可能是我这里安装过,后来又不能用了,导致这次安装好之后一直无法使用,经过网上查询别人遇到的同样的问题,经过测试,知道删除 ~/.minikube 后,再使用minikube start重新启动可以解决,启动不起来的问题。启动起来后,也有可能遇到别的问题,例如,我就碰到了dashboard启动不了的问题。

使用minikube dashboard --url --alsologtostderr -v=1 来启动dashboard,我这里报的错误是 一直停在 正在验证 proxy 运行状况, 控制台输出如下:

W0830 20:45:19.595863   76019 out.go:145] 🚀  Launching proxy ...
🚀  Launching proxy ...
I0830 20:45:19.595991   76019 dashboard.go:146] Executing: /usr/local/bin/kubectl [/usr/local/bin/kubectl --context minikube proxy --port=0]
I0830 20:45:19.596308   76019 dashboard.go:151] Waiting for kubectl to output host:port ...
I0830 20:45:19.651973   76019 dashboard.go:169] proxy stdout: Starting to serve on 127.0.0.1:41431
W0830 20:45:19.652060   76019 out.go:145] 🤔  正在验证 proxy 运行状况 ...
🤔  正在验证 proxy 运行状况 ...
I0830 20:45:19.667701   76019 dashboard.go:206] http://127.0.0.1:41431/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/ response: <nil> &{Status:503 Service Unavailable StatusCode:503 Proto:HTTP/1.1 ProtoMajor:1 ProtoMinor:1 Header:map[Cache-Control:[no-cache, private] Content-Length:[188] Content-Type:[application/json] Date:[Mon, 30 Aug 2021 12:45:19 GMT]] Body:0xc0007b1ac0 ContentLength:188 TransferEncoding:[] Close:false Uncompressed:false Trailer:map[] Request:0xc00018a500 TLS:<nil>}
I0830 20:45:19.667764   76019 retry.go:30] will retry after 110.466µs: Temporary Error: unexpected response code: 503

可以看到503错误,然后使用 kubectl get pods --all-namespaces查看当前系统pods启动的情况,发现:

NAMESPACE              NAME                                        READY   STATUS             RESTARTS   AGE
kube-system            coredns-6c76c8bb89-jlhpq                    0/1     Running            1          33m
kube-system            etcd-minikube                               1/1     Running            1          33m
kube-system            kube-apiserver-minikube                     1/1     Running            1          33m
kube-system            kube-controller-manager-minikube            1/1     Running            1          33m
kube-system            kube-proxy-glbfq                            1/1     Running            13         33m
kube-system            kube-scheduler-minikube                     1/1     Running            1          33m
kube-system            storage-provisioner                         0/1     CrashLoopBackOff   11         33m
kubernetes-dashboard   dashboard-metrics-scraper-c95fcf479-4zhdc   1/1     Running            1          33m
kubernetes-dashboard   kubernetes-dashboard-5c448bc4bf-sdssm       0/1     CrashLoopBackOff   11         33m

又几个核心pods就没有启动成功,然后查看失败的pods的日志

kubectl logs --namespace=kube-system kube-proxy-glbfq                              
I0830 12:32:07.835997       1 node.go:136] Successfully retrieved node IP: 172.17.0.4
I0830 12:32:07.836078       1 server_others.go:111] kube-proxy node IP is an IPv4 address (172.17.0.4), assume IPv4 operation
W0830 12:32:07.869666       1 server_others.go:579] Unknown proxy mode "", assuming iptables proxy
I0830 12:32:07.869749       1 server_others.go:186] Using iptables Proxier.
W0830 12:32:07.869761       1 server_others.go:456] detect-local-mode set to ClusterCIDR, but no cluster CIDR defined
I0830 12:32:07.869766       1 server_others.go:467] detect-local-mode: ClusterCIDR , defaulting to no-op detect-local
I0830 12:32:07.870043       1 server.go:650] Version: v1.19.0
I0830 12:32:07.870435       1 conntrack.go:100] Set sysctl 'net/netfilter/nf_conntrack_max' to 393216
F0830 12:32:07.870462       1 server.go:495] open /proc/sys/net/netfilter/nf_conntrack_max: permission denied

发现是因为 nf_conntrack_max 设置失败了,此时我也不知道怎么处理,我就尝试了一下手动去设置试试

sudo sysctl net/netfilter/nf_conntrack_max=393216

过了一会,pods自动重试,通过查看pods的状态,发现启动成功了,然后再使用 minikube dashboard --url 发现成功的输出了管理界面的url

➜  ~ minikube dashboard --url                       
🤔  正在验证 dashboard 运行情况 ...
🚀  Launching proxy ...
🤔  正在验证 proxy 运行状况 ...
http://127.0.0.1:42235/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/

到这里,dashboard就成功的可以进入了。

另外还可以使用下面的语句,将dashboard的端口映射到本机的9090

kubectl port-forward $(kubectl get pods --namespace=kubernetes-dashboard | grep Running | grep kubernetes-dashboard | awk '{print $1}') 9090:9090 --namespace=kubernetes-dashboard

这篇文章有用吗?

平均评分 4 / 5. 投票数: 1

到目前为止还没有投票!成为第一位评论此文章。

很抱歉,这篇文章对您没有用!

让我们改善这篇文章!

告诉我们我们如何改善这篇文章?