yudai / gotty

Share your terminal as a web application
MIT License
18.82k stars 1.38k forks source link

Listen failures under Kubernetes #228

Open lizrice opened 6 years ago

lizrice commented 6 years ago

What version of GoTTY are you using (gotty --version)?

It's actually reporting gotty version unknown_version+unknown_commit :-(

What operating system and browser are you using?

Runs fine under Docker but having issues running under Kubernetes

What did you do?

Built an image with a Dockerfile like this:

FROM golang:latest
RUN go get github.com/yudai/gotty

ENTRYPOINT ["gotty", "-w", "/bin/bash"]

And then running under Kubernetes with a container spec like this:

   ...
      containers:
      - name: gotty
        image: <image name>
        ports:
        - containerPort: 8080
   ...

What did you expect to see?

If I run the image under Docker it's great, but somehow it's picking up malformed addresses under Kubernetes and the container fails

What did you see instead?

Logs show issues setting up the listen address:

$ kubectl logs gotty-deployment-5b9f598b7b-ls442
Error: failed to listen at `0.0.0.0:tcp://172.20.244.217:8080`: listen tcp: address 0.0.0.0:tcp://172.20.244.217:8080: too many colons in address
failed to listen at `0.0.0.0:tcp://172.20.244.217:8080`: listen tcp: address 0.0.0.0:tcp://172.20.244.217:8080: too many colons in address
2018/11/21 15:22:36 GoTTY is starting with command: /bin/bash
2018/11/21 15:22:36 Permitting clients to write input to the PTY.
lalyos commented 6 years ago

Hi @lizrice I'm using the release v2.0.0-alpha.3 and works stable on gke. Instead of go get use the prebuilt binaries from github release.

You can give a go to my image: https://hub.docker.com/r/lalyos/k8s-workshop/ its full with other tools (vi/tmux/curl/jq/kubectl/helm), or here are the relevant Dockerfile lines:

https://github.com/lalyos/k8s-workshop/blob/5a7339e0ea6fb280712b903483d001cd88e91f5f/Dockerfile#L20-L21

lizrice commented 6 years ago

I figured out what's happening: I have a Kubernetes service called gotty, which is causing the environment variable GOTTY_PORT to be defined!