Garden port-forwards behave differently than `kube...
# 🌱|help-and-getting-started
f
I have a strange problem. I have
Service/cockroachdb
listening on 26257. I also have a manifest that looks as follows:
Copy code
kind: Deploy
type: kubernetes
name: cockroach-client
dependencies:
  - run.cockroach-db-confirm
spec:
  files:
    - dev/client.yml
  portForwards:
    ...
    - name: db
      resource: Service/cockroachdb
      targetPort: 26257
      localPort: 26257
I can connect using the
cockroach sql
CLI tool using this port-forward without any issues. However, I'm trying to use a tool called JetBrains Datagrip to connect (over JDBC driver) to localhost:26257. It does not work -- the connection fails (a connection failure, not certs or something else). What's extremely strange to me is that when I manually port-forward using
kubectl port-forward svc/cockroachdb 26257:26257
, it works every time. No issues. I understand that this might actually be a Datagrip limitation, but I wanted to post it here because datagrip is simply a client looking for a valid connection. The fact that the manual port-forward works when the port-forward created by garden does not (at least for this one tool) is perplexing and leaves me with questions about how garden sets up the port forward. I would assume it's just the exact command I wrote out above, but maybe not? Thanks again for your help team.
If you identify this as a bug, I'll be happy to write the issue. I've been a bit ghosty in the past trying to just get past issues -- sorry for that! 👻
f
Hi @fresh-yak-35965 Can you double check if Garden is forwarding to the correct local port? See note this from our docs:
Copy code
The preferred local port to forward from. If none is set, a random port is chosen. If the specified port is not available, a warning is shown and a random port chosen instead.
If the configured
localPort
is already in use, a random port is chosen. Is it possible that this was the case?
f
If that were true it would not have let me explicitly
kubectl port-forward
, I think.
@freezing-pharmacist-34446 I confirmed through
netstat -an | grep ESTABLISHED | grep <localPort>
that it wasn't occupied.
f
Hi @fresh-yak-35965 Can you check with netstat as well if the port is bound on ipv4 and ipv6 when port-forwarding with gardenß
f
Sure. That's a great idea.
Only binds to IPV6:
Copy code
➜  ~ netstat -an | grep 26257
tcp6       0      0  ::1.26257              *.*                    LISTEN
@freezing-pharmacist-34446 Thanks for pointing me in this direction. I've figured it out. I had to add the following to the project configuration (proxy):
Copy code
kind: Project
apiVersion: garden.io/v1
name: kraken
defaultEnvironment: dev
proxy:
  hostname: 127.0.0.1
I have had some long standing issue in my macos where localhost doesn't work properly despite /etc/hosts being properly specified. No idea what's going on there.
So, skill issue! Thanks!
f
Happy to hear that!
23 Views