5

I'm running a k8 cluster on Docker for Mac. To allow a connection from my database client to my mysql pod, I use the following command kubectl port-forward mysql-0 3306:3306. It works great, however a few hours later I get the following error E0201 18:21:51.012823 51415 portforward.go:233] lost connection to pod.

I check the actual mysql pod, and it still appears to be running. This happens every time I run the port-forward command.

I've seen the following answer here: kubectl port forwarding timeout issue and the solution is to use the following flag --streaming-connection-idle-timeout=0 but the flag is now deprecated.

So following on from there, It appears that I have to set that parameter via a kubelet config file (config file)? I'm unsure on how I could achieve this as Docker for Mac runs as a daemon and I don't manually start the cluster.

Could anyone send me a code example or instructions as to how i could configure kubectl to set that flag so my port forwarding won't have timeouts?

thatguyjono
  • 506
  • 2
  • 7
  • 16
  • You should run your database client inside the cluster, or if you can't do that, expose the database using something like a NodePort service. `kubectl port-forward` isn't designed to be a permanent connection into the cluster. – David Maze Feb 01 '20 at 18:59
  • Documentation does suggest setting that flag to `0` would establish a permanent connection though? Would you know how I could achieve this? – thatguyjono Feb 01 '20 at 19:07

1 Answers1

8

Port forwards are generally for short term debugging, not “hours”. What you probably want is a NodePort type service which you can then connect to directly.

coderanger
  • 52,400
  • 4
  • 52
  • 75