omrikiei / ktunnel

A cli that exposes your local resources to kubernetes
GNU General Public License v3.0
974 stars 75 forks source link

is there a way to make a version of this but which works? #134

Open doctorpangloss opened 3 months ago

doctorpangloss commented 3 months ago

I wonder how to simplify things so that there are fewer surprising interactions

doctorpangloss commented 3 months ago

variety of error messages observed:

(1) trying with no deployment or service existing

./bin/windows/amd64/ktunnel.exe expose proxy --node-selector-tags kubernetes.io/os=linux -r 3000:3000 --namespace default
time="2024-08-07T11:24:42-07:00" level=info msg="Exposed service's cluster ip is: 10.152.184.144"
time="2024-08-07T11:24:42-07:00" level=info msg="waiting for deployment to be ready"
time="2024-08-07T11:24:42-07:00" level=info msg="ProgressDeadlineInSeconds is currently 600s. It may take this long to detect a deployment failure."
time="2024-08-07T11:24:43-07:00" level=info msg="deployment \"proxy\" successfully rolled out\n"
time="2024-08-07T11:24:43-07:00" level=info msg="port forwarding to https://appmana-cluster-03-k.appmana.com/api/v1/namespaces/default/pods/proxy-59dd6ff9b7-bq5dz/portforward"
time="2024-08-07T11:24:43-07:00" level=info msg="Waiting for port forward to finish"
time="2024-08-07T11:24:43-07:00" level=info msg="Forwarding from 127.0.0.1:28688 -> 28688\nForwarding from [::1]:28688 -> 28688\n"
INFO[2024-08-07 11:24:43.385] starting tcp tunnel from source 3000 to target localhost:3000
E0807 11:24:43.399449   34272 portforward.go:409] an error occurred forwarding 28688 -> 28688: error forwarding port 28688 to pod f73624df91aebbb4a4c272f7f6cef6ca7d892303d064a994c73f9444bc1140e1, uid : failed to execute portforward in network namespace "/var/run/netns/cni-d22a23d3-c16b-5bb2-b322-9cd147d88a21": failed to connect to localhost:28688 inside namespace "f73624df91aebbb4a4c272f7f6cef6ca7d892303d064a994c73f9444bc1140e1", IPv4: dial tcp4 127.0.0.1:28688: connect: connection refused IPv6 dial tcp6: address localhost: no suitable address found
ERRO[2024-08-07 11:24:43.399] Error sending init tunnel request: rpc error: code = Unavailable desc = connection error: desc = "error reading server preface: EOF"
time="2024-08-07T11:25:06-07:00" level=info msg="Got exit signal, closing client tunnels"

(2) trying after failure observed above

$ ./bin/windows/amd64/ktunnel.exe expose proxy --node-selector-tags kubernetes.io/os=linux -r 3000:3000 --namespace default
time="2024-08-07T11:25:09-07:00" level=info msg="Exposed service's cluster ip is: 10.152.184.144"
time="2024-08-07T11:25:09-07:00" level=info msg="waiting for deployment to be ready"
time="2024-08-07T11:25:09-07:00" level=info msg="ProgressDeadlineInSeconds is currently 600s. It may take this long to detect a deployment failure."

at this stage, hitting Ctrl+C shows time="2024-08-07T11:25:55-07:00" level=info msg="Got exit signal, closing client tunnels" with a hang

$ kubectl logs deployments/proxy
INFO[2024-08-07 18:24:43.406] Starting to listen on port 28688

everything appears to be healthy

(3) trying to recover from failure observed above

$ kubectl delete deployments/proxy services/proxy
deployment.apps "proxy" deleted
service "proxy" deleted

great, everything is deleted. let's rerun

 $ ./bin/windows/amd64/ktunnel.exe expose proxy --node-selector-tags kubernetes.io/os=linux -r 3000:3000 --namespace default
time="2024-08-07T11:27:26-07:00" level=info msg="Exposed service's cluster ip is: 10.152.184.199"
time="2024-08-07T11:27:26-07:00" level=info msg="waiting for deployment to be ready"
time="2024-08-07T11:27:26-07:00" level=info msg="ProgressDeadlineInSeconds is currently 600s. It may take this long to detect a deployment failure."

hmm, but it's healthy:

$ kubectl logs deployments/proxy
INFO[2024-08-07 18:27:27.572] Starting to listen on port 28688

okay, let's Ctrl+C again

time="2024-08-07T11:27:51-07:00" level=info msg="Got exit signal, closing client tunnels"

and now we hang

omrikiei commented 2 months ago

It would require some focus and attention span that I currently don't have, but I have been wanting to refactor and improve this for a while now..