omrikiei / ktunnel

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

ERRO[0009] error upgrading connection due to incorrect port-forward url #13

Closed mrkswrnr closed 4 years ago

mrkswrnr commented 4 years ago

Hi @omrikiei, first of all: thank you for your work!

I'm trying to use ktunnel to forward a local port to the cluster.

Steps to reproduce

  1. download latest (brew) binary 1.1.8 for macos
  2. execute ktunnel expose myapp 3000:8000 -n mynamespace -v
  3. see:
INFO[0005] Exposed service's cluster ip is: 10.96.53.19 (correct)
INFO[0005] waiting for deployment to be ready (deployment gets ready, pod and service created)           
INFO[0009] Waiting for port forward to finish           
ERRO[0009] error upgrading connection: error sending request: Post https://rv01.mydomain.de:6443//api/v1/namespaces/default/pods/myapp-5b65c8777b-dd54r/portforward: dial tcp [ip of mydomain.de]:6443: connect: connection refused 

kubectl version

Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.1", GitCommit:"4485c6f18cee9a5d3c3b4e523bd27972b1b53892", GitTreeState:"clean", BuildDate:"2019-07-18T14:25:20Z", GoVersion:"go1.12.7", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.4", GitCommit:"67d2fcf276fcd9cf743ad4be9a9ef5828adc082f", GitTreeState:"clean", BuildDate:"2019-09-18T14:41:55Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"linux/amd64"}

kube config

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: [omitted]
    server: https://srv01.mydomain.de:6443
  name: kubernetes
contexts:
- context:
    cluster: kubernetes
    namespace: default
    user: kubernetes-admin
  name: kubernetes-admin@kubernetes
current-context: kubernetes-admin@kubernetes
kind: Config
preferences: {}
users:
- name: kubernetes-admin
  user:
    client-certificate-data: [omitted]
    client-key-data: [omitted]

The configured kube.config server is: srv01.mydomain.de while rv01.mydomain.de is being used, which resolves to another IP.

Also it seems that this results in #9 when hitting CTRL+C after receiving ERRO[0009]:

INFO[0052] Got exit signal, closing client tunnels and removing k8s objects 
INFO[0052] Deleting service travellerapp                
INFO[0053] Deleting deployment travellerapp  

The service and deployment get successfully terminated but ktunnel hangs until killed.

omrikiei commented 4 years ago

Hi @mrkswrnr, nice catch, thank you! issued a fix in v1.1.10(being released now). would be great if you can confirm it's working now..

mrkswrnr commented 4 years ago

I can confirm it's working now. Both errors seem to be fixed: Deployment and service are started, port forwarding works and the tunnel is successfully established. Also, ktunnel no longer hangs when exiting. Thank you!

omrikiei commented 4 years ago

Awesome, closing this!