https://github.com/edosrecki/google-cloud-redis-cli
Connect to private Google Cloud Redis instance from local machine through stunnel proxy running in Kubernetes.
https://github.com/edosrecki/google-cloud-redis-cli
cli gcloud gcloud-cli google google-cloud google-cloud-platform javascript kubectl kubernetes nodejs proxy redis stunnel typescript
Last synced: 11 months ago
JSON representation
Connect to private Google Cloud Redis instance from local machine through stunnel proxy running in Kubernetes.
- Host: GitHub
- URL: https://github.com/edosrecki/google-cloud-redis-cli
- Owner: edosrecki
- Created: 2023-07-23T14:17:58.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-17T08:32:32.000Z (over 1 year ago)
- Last Synced: 2024-12-22T18:39:09.823Z (over 1 year ago)
- Topics: cli, gcloud, gcloud-cli, google, google-cloud, google-cloud-platform, javascript, kubectl, kubernetes, nodejs, proxy, redis, stunnel, typescript
- Language: TypeScript
- Homepage:
- Size: 3.49 MB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.adoc
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
:toc: macro
:toc-title:
:toclevels: 10
= ⛅ google-cloud-redis
image:https://img.shields.io/github/package-json/v/edosrecki/google-cloud-redis-cli/main?color=blue&label=google-cloud-redis["google-cloud-redis CLI Version"]
image:https://img.shields.io/github/actions/workflow/status/edosrecki/google-cloud-redis-cli/continuous-integration.yml["Build Status", link="https://github.com/edosrecki/google-cloud-redis-cli/actions"]
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 https://www.stunnel.org/[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.
image::screenshot.png[]
---
toc::[]
== Install
=== Homebrew
[source,bash]
----
brew install edosrecki/tools/google-cloud-redis
# Update
brew upgrade google-cloud-redis
----
=== Releases
Download a corresponding distribution from https://github.com/edosrecki/google-cloud-redis-cli/releases[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 https://cloud.google.com/sdk/docs/install[`gcloud`] tool
* Install https://kubernetes.io/docs/tasks/tools/#kubectl[`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
[source,bash]
----
# 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
[source,bash]
----
npm run clean
npm run build
----
== Package
=== Pre-configured
Package the app for Node.JS 18 on MacOS, Linux, and Windows.
[source,bash]
----
npm run bundle
----
=== Manual
See https://www.npmjs.com/package/pkg#targets[pkg] for details.
[source,bash]
----
npx pkg --
----
== Deploy
To deploy a new version of `google-cloud-redis` app, manually run a https://github.com/edosrecki/google-cloud-redis-cli/actions/workflows/continuous-deployment.yml["Continuous Deployment"] worklow in GitHub Actions.