Closed gocruncher closed 2 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.
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 `
@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.)
I have executed this bash -x ./k8sviz.sh -n default --kubeconfig "/Users/mac/.kube/config" -o bh.out result:
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 `
Also wondering if adding --user $(id -u):$(id -g)
to docker command helps?
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
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.
as you see, I did step by step and finally, I got my present, thank you a lot!
@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.
FYI I use MacOS Catalina
@gocruncher
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).
Updated the README on how to enable long options in Mac, please see https://github.com/mkimuram/k8sviz#bash-script-version-2 for details.
I try to make a diagram via this tool.
it holds for 5 sec and finishes successfully but as a result, there is no output file