Skip to content

Connect to private Google Cloud Redis instance through stunnel proxy running in Kubernetes.

Notifications You must be signed in to change notification settings

emartech/google-cloud-redis-cli

 
 

Repository files navigation

⛅ google-cloud-redis

google-cloud-redis CLI Version Build Status

A CLI app which establishes a connection to a private Google Cloud Redis instance and port-forwards it to a local machine.

Connection is established by running an stunnel pod in a Google Kubernetes Engine cluster which runs in the same VPC network as the private Cloud Redis instance. Connection is then port-forwarded to the local machine, where a user can connect to the instance on localhost. Configurations in the app can be saved for practical future usage.

The app relies on local gcloud and kubectl commands which have to be configured and authenticated with the proper Google Cloud user and GKE Kubernetes cluster.

The app also needs an existing Kubernetes Secret containing the Google Cloud Redis certificate to exist in the Kubernetes cluster. You can download a Redis certificate file and create a Kubernetes secret manually, or you can use google-cloud-redis secrets create command to do so.

screenshot

Install

Homebrew

brew install edosrecki/tools/google-cloud-redis

# Update
brew upgrade google-cloud-redis

Releases

Download a corresponding distribution from Releases and add the executable to your PATH.

Build from source

Build the app from source by building and packaging it manually: see Build and Package sections.

Use

Prerequisites

  • Install gcloud tool

  • Install kubectl tool

  • Authenticate to Google Cloud: gcloud auth login

  • Get GKE cluster credentials: gcloud container clusters get-credentials

  • Download Google Cloud Redis certificate and store it in a Kubernetes secret (see google-cloud-redis secrets create).

Run

# Help
google-cloud-redis help

# Create Kubernetes secret containing Gogle Cloud Redis certificate
google-cloud-redis secrets create

# Create (or override existing) configuration
google-cloud-redis configurations create

# Run configuration (interactive mode)
google-cloud-redis configurations run
# Run configuration (non-interactive mode)
google-cloud-redis configurations run $NAME
# HINT: Add alias
alias myDbProd="google-cloud-redis configurations run $NAME"

## Connect to the instance on localhost
redis-cli -p $LOCAL_PORT

# Export configurations (and share :-])
cat $(google-cloud-redis configurations path)

Build

npm run clean
npm run build

Package

Pre-configured

Package the app for Node.JS 18 on MacOS, Linux, and Windows.

npm run bundle

Manual

See pkg for details.

npx pkg <NODE_RANGE>-<PLATFORM>-<ARCH>

Deploy

To deploy a new version of google-cloud-redis app, manually run a "Continuous Deployment" worklow in GitHub Actions.

About

Connect to private Google Cloud Redis instance through stunnel proxy running in Kubernetes.

Resources

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 92.8%
  • Shell 4.5%
  • JavaScript 1.7%
  • Other 1.0%