0

We use a helm container in our CI environment to execute our helm commands and it works swimmingly. I am trying to replicate that success running helm from a container locally and not having much luck. I'm 99% sure it's a config issue, but I haven't been able to find any thing on the Internet specific to this situation. Here's the snippet docker command from my script. I've been testing with ls as the argument:

  docker run \
      -v $(pwd):/apps \
      -v "${HOME}/.kube:/root/.kube" \
      -v "${HOME}/.helm:/root/.helm" \
      -e KUBECONFIG=${HOME}/foo/kubeconfig \
      -it \
      -w "$(pwd)" \
      -ti \
      docker-dev.foo.com/bar/bat/helm helm "$@"

And here's the error I'm getting:

Error: Get http://localhost:8080/api/v1/namespaces/kube-system/pods?labelSelector=app%3Dhelm%2Cname%3Dtiller: dial tcp 127.0.0.1:8080: connect: connection refused

If I do a helm ls locally, everything works just fine which is why I believe this is a config issue.

icfantv
  • 4,523
  • 7
  • 36
  • 53
  • make sure to use proper network because when you are calling `127.0.0.1:8080` from the container, it most certainly doesn't have anything running on that port inside of it – edbighead Nov 18 '20 at 07:45
  • see https://stackoverflow.com/questions/24319662/from-inside-of-a-docker-container-how-do-i-connect-to-the-localhost-of-the-mach – edbighead Nov 18 '20 at 09:16
  • 1
    If you're seeing Kubernetes trying to connect to `localhost:8080` it probably means it can't find the `$HOME/.kube/config` file; that's a default value that often isn't correct. – David Maze Nov 18 '20 at 11:06
  • @edbighead, I will check test that out tomorrow, thanks! – icfantv Nov 19 '20 at 06:29
  • @DavidMaze, that would be odd because I confirmed that all three volume mounts are accessible in the running container and contain the data from my host system. Does helm spin up a new container and then try to connect to that, by chance? If so, I could totally see `connection refused` happening because nothing is running on localhost in the container. – icfantv Nov 19 '20 at 06:30
  • @edbighead unfortunately, that didn't work. I'm not running anything on my host so there's nothing to map. My current theory is that `helm ls` tries to spin up a new container running on `:8080` and connect to it, but I don't know helm well enough to know for sure. – icfantv Nov 19 '20 at 06:37
  • Looking at the command again, you're setting `-e KUBECONFIG=...` to your host-system path, but also `-v` bind-mounting it to `/root/.kube` in the container. Those need to match. – David Maze Nov 19 '20 at 10:54
  • @DavidMaze that's a great point. I volume mounted that folder from my host into the container and confirmed it's visible and has the kubeconfig, but still the same error. I might need to move on from this and find another way. – icfantv Nov 19 '20 at 15:37

0 Answers0