Currently connecting to MySQL on Kubernetes with DBeaver after run the following command on terminal.
kubectx arn:aws:eks:XXX:cluster/XXX && kubens XXX && kubectl port-forward --address 0.0.0.0 XXX 13306:3306
I am looking for a way to do port-forwarding directly on DBeaver, as it is tedious to run the command every time and then connect with DBeaver.
What are some possible ways to do this?
Its possible to run kubectl port-forward before connecting automatically.
#!/usr/bin/env bash
export PATH='' # note that you need to set you path to include all dependencies default path of the dbeaver shell contains almost nothing.
echo "connect to database-name"
aws sso login --profile your-profile
kubectx arn:aws:eks:XXX:cluster/XXX
kubens XXX
kubectl port-forward --address 0.0.0.0 XXX 13306:3306
echo "connection closed"
Give the script excution rights chmod +x database-name.sh
Test script by running it via your terminal.
Edit your db connection its configuration. In the UI you will find a 'Shell commands' tab which has a setting called 'Before connect'.
set the working directory to the before-connect folder
set the command to
/bin/bash -c "./database-name.sh"
Pause before connecting for the amount of seconds you need for your script to run (I set it to a safe 10000ms)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With