mkimuram / k8sviz

Generate Kubernetes architecture diagrams from the actual state in a namespace
Apache License 2.0
286 stars 47 forks source link

there is no any output files #9

Closed gocruncher closed 2 years ago

gocruncher commented 3 years ago

I try to make a diagram via this tool.

Screenshot 2021-03-09 at 20 52 18

it holds for 5 sec and finishes successfully but as a result, there is no output file

mkimuram commented 3 years ago

@gocruncher

Thank you for your report.

To reduce dependency, I've rewrite with go and make it containerized, as discussed in #1 . Could you try with the new instruction and check if it works? (You will need to specify --kubeconfig if the path to KUBECONFIG file isn't ~/kubeconfig.)

Note that new version requires docker, I hope that this requirement won't block you.

gocruncher commented 3 years ago

Thank you @mkimuram I've done everything that you said and I see it is already with Docker but anyway nothing happens

` ➜ k8sviz git:(master) ✗ ./k8sviz.sh -n default -kubeconfig "/Users/mac/.kube/config" -o bh.dot ➜ k8sviz git:(master) ✗ ls

Dockerfile LICENSE README.md _info.log examples go.mod go.sum icons k8sviz k8sviz.go k8sviz.out k8sviz.sh `

mkimuram commented 3 years ago

@gocruncher

Thank you for trying it and reporting the result. Could you try prepend bash -x to the command like?

bash -x ./k8sviz.sh -n default --kubeconfig "/Users/mac/.kube/config" -o bh.out

Then, you will see the output like below in the last line.

docker run --network host -v /Users/mac:/work -v /Users/mac/.kube/config:/config:ro -e KUBECONFIG=/config -it mkimuram/k8sviz:0.2 /k8sviz -kubeconfig /config -n default -t dot -o /work/bh.out

Let's split the above command into two commands and manually (1) create the conatiner and (2) run the command inside the container.

(1) create the conatiner Please copy the command line before /k8sviz and append sh like below:

$ docker run --network host -v /Users/mac:/work -v /Users/mac/.kube/config:/config:ro -e KUBECONFIG=/config -it mkimuram/k8sviz:0.2 sh

Then the container is created and prompt will be shown.

(2) run the command inside the container

Please copy the rest of the command line from /k8sviz like below:

/ # /k8sviz -kubeconfig /config -n default -t dot -o /work/bh.out

And check the exit code.

/ # echo $?

Then, check if the file is created inside the container.

/ # ls /work

Could you report the results of above?

I think that you will see (a) exit code 1 with error message or (b) exit code 0 with the output file inside the container. (I suspect that case (b) is happening due to the difference of the Docker environment. Something like write permission of the bind mount volume in Docker for Mac.)

gocruncher commented 3 years ago

I have executed this bash -x ./k8sviz.sh -n default --kubeconfig "/Users/mac/.kube/config" -o bh.out result:

gocruncher commented 3 years ago

anyway, I copied to /Users/mac/kubeconfig and executed following command: ` docker run --network host -v /Users/mac/k8sviz:/work -v /Users/mac/kubeconfig:/config:ro -e KUBECONFIG=/config -it mkimuram/k8sviz:0.2

Failed to build config from "/root/.kube/config": stat /root/.kube/config: no such file or directory `

mkimuram commented 3 years ago

Also wondering if adding --user $(id -u):$(id -g) to docker command helps?

mkimuram commented 3 years ago

Please add sh at the end like:

docker run --network host -v /Users/mac/k8sviz:/work -v /Users/mac/kubeconfig:/config:ro -e KUBECONFIG=/config -it mkimuram/k8sviz:0.2 sh
mkimuram commented 3 years ago

I am wondering why config file is not replaces ?

It bind mounts like below:

Hosts Container
/Users/mac/k8sviz /work
/Users/mac/kubeconfig /config

So, insdie container, kubeconfig file should be accessible via /config.

gocruncher commented 3 years ago

Screenshot 2021-03-12 at 16 06 56 as you see, I did step by step and finally, I got my present, thank you a lot!

mkimuram commented 3 years ago

@gocruncher

Thank you for letting me know. I'm glad to hear that you got the output.

Two questions:

I will check what need to be improved in the script.

gocruncher commented 3 years ago

FYI I use MacOS Catalina

mkimuram commented 3 years ago

@gocruncher

19 should fix this issue. Could you download the latest k8sviz.sh and try again?

mkimuram commented 3 years ago

Long flags like --kubeconfig don't seem to work well in Mac OS, even with shflags. However, it works as long as we use short flags like -k. I will search for a workaround (Maybe just document it).

mkimuram commented 3 years ago

Updated the README on how to enable long options in Mac, please see https://github.com/mkimuram/k8sviz#bash-script-version-2 for details.