缺少 kubectl 安装后的配置文件

huangapple go评论147阅读模式
英文:

missing kubectl config files after install

问题

我尝试在Pop!_OS上使用以下命令安装kubectl:

sudo apt install -y ca-certificates curl apt-transport-https
sudo curl -fsSLo /etc/apt/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
echo "deb [signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt update
sudo apt install -y kubectl

安装完成后,运行kubectl cluster-info,出现以下错误信息:

kalin@pop-os:~$ kubectl cluster-info
E0304 00:04:05.721040   93361 memcache.go:238] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connect: connection refused
E0304 00:04:05.721478   93361 memcache.go:238] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connect: connection refused
E0304 00:04:05.722950   93361 memcache.go:238] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connect: connection refused
E0304 00:04:05.724685   93361 memcache.go:238] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connect: connection refused
E0304 00:04:05.726373   93361 memcache.go:238] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connect: connection refused

要进一步调试和诊断集群问题,请使用'kubectl cluster-info dump'拒绝连接到服务器localhost:8080 - 您是否指定了正确的主机或端口?

运行helm status RELEASE_NAME,出现以下错误信息:

kalin@pop-os:~$ helm status RELEASE_NAME
Error: Kubernetes cluster unreachable: Get "http://localhost:8080/version": dial tcp [::1]:8080: connect: connection refused

不确定这是否是原因,但看起来我没有~/.kube/config/etc/kubernetes/admin.conf文件。我进行了许多谷歌搜索,但在这一点上我放弃了。

英文:

I tried to install kubectl on popos using the following commands

sudo apt install -y ca-certificates curl apt-transport-https
sudo curl -fsSLo /etc/apt/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
echo "deb [signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt update
sudo apt install -y kubectl

After the installation kubectl cluster-info give me that

kalin@pop-os:~$ kubectl cluster-info
E0304 00:04:05.721040   93361 memcache.go:238] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connect: connection refused
E0304 00:04:05.721478   93361 memcache.go:238] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connect: connection refused
E0304 00:04:05.722950   93361 memcache.go:238] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connect: connection refused
E0304 00:04:05.724685   93361 memcache.go:238] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connect: connection refused
E0304 00:04:05.726373   93361 memcache.go:238] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connect: connection refused

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
The connection to the server localhost:8080 was refused - did you specify the right host or port?

helm status RELEASE_NAME give me that

kalin@pop-os:~$ helm status RELEASE_NAME
Error: Kubernetes cluster unreachable: Get "http://localhost:8080/version": dial tcp [::1]:8080: connect: connection refused

Not sure if that is the reason but it's turnout that I don't have ~/.kube/config or /etc/kubernetes/admin.conf. I made a lot of google searches but at that point I surrender

答案1

得分: 2

以下是已翻译的内容:

"It's turnout that the installation of kubectl don't provide kubernetes cluster itself. After some googling I find out that I need to install more components on my system. There are at least 4 possible options for local kubernetes cluster

It seems that minikube is the simplest and I didn't explore the rest. Also if you install minukube you may not need to install kubectl because minikube provide one"

英文:

It's turnout that the installation of kubectl don't provide kubernetes cluster itself. After some googling I find out that I need to install more components on my system. There are at least 4 possible options for local kubernetes cluster

It seems that minikube is the simplest and I didn't explore the rest. Also if you install minukube you may not need to install kubectl because minikube provide one

答案2

得分: 0

以下是翻译好的部分:

  • What is your version of k8s?

    • 你的 k8s 版本是多少?
  • Port 8080 is not supported in higher versions, you need to use 6443.

    • 在较高版本中不支持端口8080,您需要使用6443。
  • kubectl version and k8s version

    • kubectl 版本和 k8s 版本
  • Are kubelet and kube-apiserver compatible?

    • kubelet 和 kube-apiserver 是否兼容?
  • https://kubernetes.io/releases/version-skew-policy/#kubelet

  • kubelet must not be newer than kube-apiserver, and may be up to two minor versions older.

    • kubelet 不能比 kube-apiserver 新,可以旧最多两个次要版本。
  • If your configuration file is in the correct location, the kubectl version is also correct. You can troubleshoot this in the way given below

    • 如果您的配置文件位于正确位置,kubectl 版本也是正确的。您可以按照下面的方法进行故障排除。
英文:

What is your version of k8s ?

Port 8080 is not supported in higher versions, you need to use 6443.

kubectl version and k8s version

Are kubelet and kube-apiserver compatible ?

https://kubernetes.io/releases/version-skew-policy/#kubelet

>kubelet must not be newer than kube-apiserver, and may be up to two minor versions older.

Example:

kube-apiserver is at 1.26
kubelet is supported at 1.26, 1.25, and 1.24

If your configuration file is in the correct location, the kubectl version is also correct. You can troubleshoot this in the way given below

┌──[root@vms100.liruilongs.github.io]-[~/ansible/falco]
└─$kubectl cluster-info -v=1
Kubernetes control plane is running at https://192.168.26.99:30033
CoreDNS is running at https://192.168.26.99:30033/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
┌──[root@vms100.liruilongs.github.io]-[~/ansible/falco]
└─$kubectl cluster-info -v=9
I0304 23:00:23.406007  117409 loader.go:374] Config loaded from file:  /root/.kube/config
I0304 23:00:23.430565  117409 round_trippers.go:466] curl -v -XGET  -H "Accept: application/json, */*" -H "User-Agent: kubectl/v1.25.1 (linux/amd64) kubernetes/e4d4e1a" 'https://192.168.26.99:30033/api/v1/namespaces/kube-system/services?labelSelector=kubernetes.io%2Fcluster-service%3Dtrue'
I0304 23:00:23.433095  117409 round_trippers.go:510] HTTP Trace: Dial to tcp:192.168.26.99:30033 succeed
I0304 23:00:23.447398  117409 round_trippers.go:553] GET https://192.168.26.99:30033/api/v1/namespaces/kube-system/services?labelSelector=kubernetes.io%2Fcluster-service%3Dtrue 200 OK in 16 milliseconds
I0304 23:00:23.447454  117409 round_trippers.go:570] HTTP Statistics: DNSLookup 0 ms Dial 1 ms TLSHandshake 6 ms ServerProcessing 7 ms Duration 16 ms
I0304 23:00:23.447464  117409 round_trippers.go:577] Response Headers:
I0304 23:00:23.447474  117409 round_trippers.go:580]     X-Kubernetes-Pf-Flowschema-Uid: 428a4a76-922c-4451-ba2d-74bc231f896c
I0304 23:00:23.447482  117409 round_trippers.go:580]     X-Kubernetes-Pf-Prioritylevel-Uid: dfc65bb0-fb29-4499-bdbb-420ace44c285
I0304 23:00:23.447510  117409 round_trippers.go:580]     Content-Length: 1676
I0304 23:00:23.447518  117409 round_trippers.go:580]     Date: Sat, 04 Mar 2023 15:00:23 GMT
I0304 23:00:23.447545  117409 round_trippers.go:580]     Audit-Id: c67e042d-7506-448a-b709-369410528d11
I0304 23:00:23.447557  117409 round_trippers.go:580]     Cache-Control: no-cache, private
I0304 23:00:23.447565  117409 round_trippers.go:580]     Content-Type: application/json
I0304 23:00:23.447770  117409 request.go:1154] Response Body: {"kind":"ServiceList","apiVersion":"v1","metadata":{"resourceVersion":"7355757"},"items":[{"metadata":{"name":"kube-dns","namespace":"kube-system","uid":"ec55d5bf-be92-461f-bbda-8d8a694eb25a","resourceVersion":"256","creationTimestamp":"2023-01-26T11:28:00Z","labels":{"k8s-app":"kube-dns","kubernetes.io/cluster-service":"true","kubernetes.io/name":"CoreDNS"},"annotations":{"prometheus.io/port":"9153","prometheus.io/scrape":"true"},"managedFields":[{"manager":"kubeadm","operation":"Update","apiVersion":"v1","time":"2023-01-26T11:28:00Z","fieldsType":"FieldsV1","fieldsV1":{"f:metadata":{"f:annotations":{".":{},"f:prometheus.io/port":{},"f:prometheus.io/scrape":{}},"f:labels":{".":{},"f:k8s-app":{},"f:kubernetes.io/cluster-service":{},"f:kubernetes.io/name":{}}},"f:spec":{"f:clusterIP":{},"f:internalTrafficPolicy":{},"f:ports":{".":{},"k:{\"port\":53,\"protocol\":\"TCP\"}":{".":{},"f:name":{},"f:port":{},"f:protocol":{},"f:targetPort":{}},"k:{\"port\":53,\"protocol\":\"UDP\"}":{".":{},"f:name":{},"f:port":{},"f:protocol":{},"f:targetPort":{}},"k:{\"port\":9153,\"protocol\":\"TCP\"}":{".":{},"f:name":{},"f:port":{},"f:protocol":{},"f:targetPort":{}}},"f:selector":{},"f:sessionAffinity":{},"f:type":{}}}}]},"spec":{"ports":[{"name":"dns","protocol":"UDP","port":53,"targetPort":53},{"name":"dns-tcp","protocol":"TCP","port":53,"targetPort":53},{"name":"metrics","protocol":"TCP","port":9153,"targetPort":9153}],"selector":{"k8s-app":"kube-dns"},"clusterIP":"10.96.0.10","clusterIPs":["10.96.0.10"],"type":"ClusterIP","sessionAffinity":"None","ipFamilies":["IPv4"],"ipFamilyPolicy":"SingleStack","internalTrafficPolicy":"Cluster"},"status":{"loadBalancer":{}}}]}
Kubernetes control plane is running at https://192.168.26.99:30033
CoreDNS is running at https://192.168.26.99:30033/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
┌──[root@vms100.liruilongs.github.io]-[~/ansible/falco]
└─$

huangapple
  • 本文由 发表于 2023年3月4日 06:12:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/75632287.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定