Sign inSign up

berylcc/sqlproxy-ssh-tunnel

By berylcc

Updated almost 2 years ago

https://github.com/team-blaze/helm-sqlproxy-ssh-tunnel

Image
0

7.0K

berylcc/sqlproxy-ssh-tunnel repository overview

sqlproxy-ssh-tunnel Helm chart

This is a simple SSH jumpserver to enable tunneling in to a Google Cloud SQL instance without a public IP. The pod consists of an SSH server with a SQLproxy sidecar, exposed through a Loadbalancer.

There's also an optional SSH client container for setting up a reverse SSH tunnel.

NOTE: to keep things more secure, only ED25519 keys are used in the chart.

Helm chart based on https://v3.helm.sh/docs/topics/chart_repository/#github-pages-example and https://github.com/technosophos/tscharts.

Kubernetes templates and scripts based on:

Repo URL

https://team-blaze.github.io/sqlproxy-ssh-tunnel

Configuration

The following table lists the configurable parameters of the sqlproxy-ssh-tunnel chart and their default values, and can be overwritten via the helm --set flag.

ParameterDescriptionDefault
nameName to give to the k8s objectssqlproxy-ssh-tunnel
imageDocker image and tag to useberylcc/sqlproxy-ssh-tunnel:1.0
imagePullSecretsDocker registry secretunset
authorizedKeysBase64Base64 encoded authorized_keysmust be set
hostKeyBase64Base64 encoded ssh_host_ed25519_keymust be set
sshd_configSSH server configurationsee values.yaml
cloudsql.serviceAccountKeyBase64Base64 encoded Google service account JSONmust be set
cloudsql.instances[0].projectCloud SQL instance projectmy-project
cloudsql.instances[0].regionCloud SQL instance regionus-west1
cloudsql.instances[0].instanceCloud SQL instance namesql_instance
cloudsql.instances[0].portPort to bind Cloud SQL instance to3306
service.loadBalancerPortPort you want to be exposed to the outside22
service.loadBalancerIPLoad balancer IP (if pre-allocated)unset
reverseTunnel.privateKeyBase64Base64 encoded ssh_client_ed25519_keyunset
reverseTunnel.sshUserReverse tunnel server userunset
reverseTunnel.sshHostReverse tunnel server hostunset
reverseTunnel.remoteDbPortReverse tunnel server database portunset
reverseTunnel.localDbPortCloud SQL instance portunset

NOTE: you can proxy multiple Cloud SQL instances (like read replicas), but make sure to bind each instance to a different port.

Usage

Once you have your chart up and running, you can SSH in and forward the SQL server port with a command like:

ssh sshuser@$SSH_SERVER_ADDRESS -i id_ed25519 -L 3306:127.0.0.1:3306 -o ExitOnForwardFailure=yes

Notes

There's an image hosted in Docker Hub built from the Dockerfile in this repo which will work, but you might want to build and push into your private cloud registry. If you do so, you'll need to set imagePullSecrets for Kubernetes to be authenticated to pull the image when deploying, see: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/

Tag summary

Content type

Image

Digest

sha256:dd69e1c04

Size

5.7 MB

Last updated

almost 2 years ago

docker pull berylcc/sqlproxy-ssh-tunnel:1.0.3