emosbaugh / gcommands Goto Github PK
View Code? Open in Web Editor NEWSome commands to make working with gcloud easier
Some commands to make working with gcloud easier
While working with the scripts I've had a few complications that I've made some changes for which I'll commit back but wanted to have a discussion on the intention before I go to far down this path.
Between the dev and qa environments I'm finding the scripts are. hardcoding things that provide unintuitive results. For example:
I think two changes could be made which would make the commands more generically usable, less surprising, and hopefully easier to maintain moving forward.
You can see what this looks like with my WIP currently Here
Here's an example of creating, listing, and deleting
╭chris:~ %
╰➤ glist
Configuration: qa
WARNING: The following filter keys were not present in any resource : labels.owner
Listed 0 items.
╭chris:~ %
╰➤ gcreate ubuntu-minimal-2004-focal-v20210720 {test-app,test-app2,test-three-app}
Configuration: qa
+gcreate:15> echo test-app test-app2 test-three-app
+gcreate:15> gcloud compute instances create test-app test-app2 test-three-app --labels 'owner=chriss' '--machine-type=n1-standard-4' '--subnet=default' '--network-tier=PREMIUM' '--maintenance-policy=MIGRATE' '--service-account=846065462912-compute@developer.gserviceaccount.com' '--scopes=https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/logging.write,https://www.googleapis.com/auth/monitoring.write,https://www.googleapis.com/auth/servicecontrol,https://www.googleapis.com/auth/service.management.readonly,https://www.googleapis.com/auth/trace.append' '--image=ubuntu-minimal-2004-focal-v20210720' '--image-project=ubuntu-os-cloud' '--boot-disk-size=200GB' '--boot-disk-type=pd-standard' --no-shielded-secure-boot --shielded-vtpm --shielded-integrity-monitoring '--reservation-affinity=any'
Created [https://www.googleapis.com/compute/v1/projects/replicated-qa/zones/us-central1-a/instances/test-app].
Created [https://www.googleapis.com/compute/v1/projects/replicated-qa/zones/us-central1-a/instances/test-app2].
Created [https://www.googleapis.com/compute/v1/projects/replicated-qa/zones/us-central1-a/instances/test-three-app].
WARNING: Some requests generated warnings:
- Disk size: '200 GB' is larger than image size: '10 GB'. You might need to resize the root repartition manually if the operating system does not support automatic resizing. See https://cloud.google.com/compute/docs/disks/add-persistent-disk#resize_pd for details.
NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS
test-app us-central1-a n1-standard-4 10.128.0.73 34.121.13.57 RUNNING
test-app2 us-central1-a n1-standard-4 10.128.0.80 34.123.235.234 RUNNING
test-three-app us-central1-a n1-standard-4 10.128.0.78 34.132.52.185 RUNNING
╭chris:~ %
╰➤ glist
Configuration: qa
NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS
test-app us-central1-a n1-standard-4 10.128.0.73 34.121.13.57 RUNNING
test-app2 us-central1-a n1-standard-4 10.128.0.80 34.123.235.234 RUNNING
test-three-app us-central1-a n1-standard-4 10.128.0.78 34.132.52.185 RUNNING
╭chris:~ %
╰➤ gdelete test-app
Configuration: qa
The following instances will be deleted. Any attached disks configured
to be auto-deleted will be deleted unless they are attached to any
other instances or the `--keep-disks` flag is given and specifies them
for keeping. Deleting a disk is irreversible and any data on the disk
will be lost.
- [test-app2] in [us-central1-a]
- [test-app] in [us-central1-a]
Do you want to continue (Y/n)? Y
Deleted [https://www.googleapis.com/compute/v1/projects/replicated-qa/zones/us-central1-a/instances/test-app].
Deleted [https://www.googleapis.com/compute/v1/projects/replicated-qa/zones/us-central1-a/instances/test-app2].
╭chris:~ %
╰➤ glist
Configuration: qa
NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS
test-three-app us-central1-a n1-standard-4 10.128.0.78 34.132.52.185 RUNNING
While you could leave the name prefix and still use labels, the scripts are a lot easier to maintain when you don't have to mess with column and string manipulation to find the items that belong to you.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.