Git Product home page Git Product logo

gcloud-client's Introduction

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

  • gcloud-client instances refresh

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

Demo

Search

  • gcloud-client --help to show the help with flag information

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

  • --limit total instances to add
  • --filter regexp to filter the instances while listing. uses gcloud filter=name~'regex'
  • --user username to which your ssh key is added for, defaults to $USER
  • --ssh_key ssh_key file to be uploaded, defaults to $HOME/.ssh/id_rsa.pub
  • --dbfile file to store the instances and search, defaults to $HOME/hosts.db
  • --projects list of project-ids to search for while login, or to refresh
  • --host_mapping prints results of search command in the format of /etc/hosts file
# 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
  • prefix search is much faster than regex search

Customize flags

  • --user username for ssh
  • --session tmux session name, so multiple ssh sessions can be done at same time
  • --projects if you've many gcloud projects, mention the projects to search

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:

  • customize which cmd to run once ssh to all instances
  • customize login via external ip / internal ip via flags (currently only internal ip is supported)
  • Infer id from ssh key
  • revoking ssh key for user from machine
  • ssh customize project to use via flag
  • TAG: search list could be tagged, so can login via tags

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.