skip to Main Content

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

2

Answers


  1. Chosen as BEST ANSWER

    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. 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

    ┌──[[email protected]]-[~/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'.
    ┌──[[email protected]]-[~/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'.
    ┌──[[email protected]]-[~/ansible/falco]
    └─$
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search