skip to Main Content

I am trying to connect to redis cache in dev server which is a pod in GCP. we are trying to connect it through a proxy server using below command

gcloud beta compute ssh --zone "<zone>" "proxy-server" --project "project-name" --internal-ip --ssh-flag="-NL <local_port>:<redis-server-ip>:<port>"

but its throwing error in google cloud console installed in my windows system
error is ‘unknown option "-NL"’

ERROR: (gcloud.compute.beta.ssh) [C:Users<user-dir>AppDataLocalGoogleCloud SDKgoogle-cloud-sdkbinsdkputty.exe] exited with return code [1].

but its running fine in mac, please help me in resolving the issue at the earliest.

As suggested by one of the answer, tried running below command

kubectl port-forward pod/pod-58759-s4wfz 6377:6379

getting this error now:

C:Windowssystem32>kubectl port-forward pod/pod-587597c46d-s4wfz 6377:6379
Forwarding from 127.0.0.1:6377 -> 6379
Forwarding from [::1]:6377 -> 6379
Handling connection for 6377
E0120 12:34:32.504209   18476 portforward.go:406] an error occurred forwarding 6377 -> 6379: error forwarding port 6379 to pod a5bba767d7ec94aaf, uid : exit status 1: 2022/01/20 07:04:34 socat[910] E connect(5, AF=2 127.0.0.1:6379, 16): Connection refused
E0120 12:34:32.508193   18476 portforward.go:234] lost connection to pod

Thanks

3

Answers


  1. Chosen as BEST ANSWER

    After 1 day of effort I found an answer which corrected my command, just need to use below command, in place of -NL we should use -N -L in windows

    gcloud beta compute ssh --zone "<zone>" "proxy-server" --project "project-name" --internal-ip -- -N -L <local_port>:<redis-server-ip>:<port>
    

  2. Putty SSH (and the OpenSSH client for windows as well) does not support the -N flag. But

    gcloud beta compute ssh --zone "<zone>" "proxy-server" --project "project-name" --internal-ip --ssh-flag="-L <local_port>:<redis-server-ip>:<port>"
    

    should work just fine on Windows.

    Login or Signup to reply.
  3. If your redis server is deployed on GKE, you can use kubectl port-forward. It should look like

    kubectl port-forward pod/POD_NAME local-port:redis-server-port

    And use localhost:local-port to connect to your redis server

    This should work regardless of the OS

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search