devdinu / gcloud-client

google cloud client which give ssh access and login to multiple instances with tmuxinator
28 stars 3 forks source link

gcloud client

Go Report Card Build Status

scripts to do things which you wish google console client does.

Installation

Required libs

Go

go get -u github.com/devdinu/gcloud-client

Homebrew

brew install devdinu/devlife/gcloud-client

If you've installed with brew, command will be gcl, might need to remove alias from git plugin of oh-my-zsh ~/.oh-my-zsh/plugins/git/git.plugin.zsh

Usage

Refresh

all instances, which's stored in boltd

optionally you can pass flag --projects proj1,proj2 to refresh specific projects You could add the refresh as cron

Demo

Search

Add SSH key to compute instances

You could add your ssh key to compute instance[s], so you could ssh directly. default gcloud compute add ssh overrides the existing keys. you can add your key along with existing ones in instances with this command.

# adds your ~/.ssh/id_rsa.pub key to 10 instances
gcloud-client ssh_access --limit=10

The existing keys with new key is written to temp file and cleared after added to the instance.

You could customize the flags

# customize ssh file, username
gcloud-client ssh_access --ssh_key=$HOME/.ssh/gcp_id_rsa.pub --filter='.*pg.*' --limit=10 --user username

Add to single instance

You could give --instance and --zone to add ssh key to single instance, as its faster than listing instances with regexp

gcloud-client --instance=some_instance --zone=asia-zone

Demo

Login to instances

ssh into the instances which you searched, open each in tmux pane.

gcloud-client instances login --regex=some-prefix
gcloud-client instances login --prefix='some-.*db.*' --user username --session session_name
gcl instances search --regex=".*kafka.*" --projects=proj-integration,proj-production

Customize flags

Demo

Additional information

Homebrew

if you've installed via homebrew, use gcl instead of gcloud-client /usr/local/Cellar/gcloud-client/ have the template file and bin directory with the executable

Tmux

enable syncronized panes, so most cases require you to run command on all machines

:set synchronized-panes on

TODO: