cnrancher / kube-explorer

A portable explorer for Kubernetes, without any dependency.
Apache License 2.0
220 stars 27 forks source link

kube explorer not working with k3d local cluster #34

Closed nurrony closed 1 year ago

nurrony commented 1 year ago

kube-explorer does not start and shows no logs. here is my kube-explorer command

kube-explorer --kubeconfig="$HOME/.kube/config" --context=k3d-devship --http-listen-port=9080 --https-listen-port=0 --debug

When I run the command it shows nothing, even I passed the --debug flag. If I go to http://localhost:9080, it shows Site can not be reached error.

I am using kube-explorer version v0.3.1 (f4970b8)

My Machine

macOS v12.6.4 (MacbookPro Mid 2015 model)
Darwin Kernel Version 21.6.0: Thu Mar  9 20:08:59 PST 2023; root:xnu-8020.240.18.700.8~1/RELEASE_X86_64 x86_64

Others Informations

# devship.localhost resolves to 127.0.0.1
$ kubectl cluster-info

Kubernetes control plane is running at https://devship.localhost:6445
CoreDNS is running at https://devship.localhost:6445/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
Metrics-server is running at https://devship.localhost:6445/api/v1/namespaces/kube-system/services/https:metrics-server:https/proxy

$ kubectl get nodes

NAME                   STATUS   ROLES                  AGE   VERSION
k3d-devship-server-0   Ready    control-plane,master   13m   v1.26.3+k3s1
k3d-devship-agent-1    Ready    <none>                 13m   v1.26.3+k3s1
k3d-devship-agent-0    Ready    <none>                 13m   v1.26.3+k3s1
niusmallnan commented 1 year ago

How did you create your k3d cluster? I cannot reproduce this way.

k3d cluster create -i rancher/k3s:v1.26.3-k3s1 v1-26-3
kube-explorer --kubeconfig="$HOME/.kube/config" --context=k3d-v1-26-3 --http-listen-port=9080 --https-listen-port=0
nurrony commented 1 year ago

@niusmallnan thanks for replying. Here is my k3d-cluster.yml

apiVersion: k3d.io/v1alpha4
kind: Simple # internally, we also have a Cluster config, which is not yet available externally
metadata:
  name: devship # name that you want to give to your cluster (will still be prefixed with `k3d-`)
servers: 1
agents: 2
kubeAPI:
  host: devship.localhost
  hostIP: 0.0.0.0
  hostPort: "6443"
image: rancher/k3s:v1.26.3-k3s1
# network: ronsvpn
volumes:
  - volume: /Volumes/Devzone/storage/kubernetes/clusters/volumes/devship:/mnt/devship
    nodeFilters:
      - all
ports:
  - port: 0.0.0.0:443:443
    nodeFilters:
      - loadbalancer
  - port: 0.0.0.0:80:80
    nodeFilters:
      - loadbalancer
env:
  - envVar: DEV_SALT=MyrCUiOM1dFfmSbUVI9EWP3UAVBmRogR # for hashing secrets
    nodeFilters:
      - server:0
registries:
  create:
    name: registry.devship.localhost
    host: "0.0.0.0"
    hostPort: "5000"
    volumes:
      - /Volumes/Devzone/storage/kubernetes/k8s-clusters/registry:/var/lib/registry

# hostAliases:
#   - ip: 1.1.1.1
#     hostnames:
#       - cloud.flare.dns # add cloudflare dns
options:
  k3d:
    wait: true
    timeout: 30s
    disableLoadbalancer: false
    disableImageVolume: false
    disableRollback: false
    # loadbalancer:
    #   configOverrides:
    #     - settings.workerConnections=2048
  k3s: # options passed on to K3s itself
    extraArgs:
      - arg: "--tls-san=*.devship.localhost"
        nodeFilters:
          - server:*
      - arg: "--tls-san=127.0.0.1"
        nodeFilters:
          - server:*
      - arg: "--disable=traefik" # disable traefik
        nodeFilters:
          - server:0
    nodeLabels:
      - label: "CreatedBy=Rony"
        nodeFilters:
          - server:*
  kubeconfig:
    updateDefaultKubeconfig: true
    switchCurrentContext: true
  runtime: # runtime (docker) specific options
    gpuRequest: ""
    serversMemory: ""
    agentsMemory: ""
    labels:
      - label: CreatedBy=Rony
        nodeFilters:
          - server:0
          - loadbalancer
niusmallnan commented 1 year ago

When I run the command it shows nothing, even I passed the --debug flag.

This means kube-explorer cannot talk to kube-api via kubeconfig. Could you please share more details about $HOME/.kube/config.

nurrony commented 1 year ago

Hi @niusmallnan, I figured out the issue!! It is kubeAPI.host key in kube config that was creating the timeout. I have removed the value and rebuild the cluster and it starts working. Thanks a lot for showing me the right direction.

IMHO, kube-explorer should be more verbose when --debug flag has been passed.

Thanks for your help! Closing the issue