KubeView fails to start. How can I start KubeView container and not have it exit right away?

128 Views Asked by At

Based on the KubeView README, I tried to run KubeView using the container provided here.

I run:

$ docker run --publish-all --name kubeview ghcr.io/benc-uk/kubeview:0.1.31

I get the following output:

2023/03/12 18:06:45 ### Kubeview v0.1.31 starting...
2023/03/12 18:06:45 ### Connecting to Kubernetes...
2023/03/12 18:06:45 ### Creating client with config file: /.kube/config
panic: stat /.kube/config: no such file or directory

goroutine 1 [running]:
main.main()
    /build/cmd/server/main.go:60 +0x6a5

I can see that the problem is that the tool is looking for the kubeconfig file in /.kube/config. It can't find it because mine is in my home directory, ~/.kube/config/

I tried to pass an environment variable like this:

$ docker run --publish-all --name kubeview -e KUBECONFIG=/Users/<MY_USERNAME>/.kube/config ghcr.io/benc-uk/kubeview:latest

It didn't work. Has anyone been able to run KubeView as a container? I'm on a Mac.

1

There are 1 best solutions below

2
Harsh Manvar On

You can mount your local kubeconfig file to the Docker image that you are trying, not sure if the way you follow Env variable option is suggested anywhere or not

Try something like :

docker run --publish-all --name kubeview -v ./config:/.kube/config ghcr.io/benc-uk/kubeview:0.1.31

./config - will the path of your ~/.kube/config/ local system

/.kube/config - path where your local file will get set in the container, so when container will run your local file will be available at that path

Tried with fake values, which not able to parse but it got the file

2023/03/12 19:28:04 ### Kubeview v0.0.0 starting...
2023/03/12 19:28:04 ### Connecting to Kubernetes...
2023/03/12 19:28:04 ### Creating client with config file: /.kube/config
panic: error loading config file "/.kube/config": couldn't get version/kind; json parse error: json: cannot unmarshal string into Go value of type struct { APIVersion string "json:\"apiVersion,omitempty\""; Kind string "json:\"kind,omitempty\"" }

goroutine 1 [running]:
main.main()
        /build/cmd/server/main.go:60 +0x6a5