Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vietanhduong/pause-gcp
Pause GCP resources to save your cost
https://github.com/vietanhduong/pause-gcp
gcp gke save-cost sql vm
Last synced: about 1 month ago
JSON representation
Pause GCP resources to save your cost
- Host: GitHub
- URL: https://github.com/vietanhduong/pause-gcp
- Owner: vietanhduong
- License: apache-2.0
- Created: 2023-05-18T05:08:11.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-06-14T03:18:08.000Z (over 1 year ago)
- Last Synced: 2024-06-21T14:06:46.841Z (7 months ago)
- Topics: gcp, gke, save-cost, sql, vm
- Language: Go
- Homepage:
- Size: 170 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Pause GCP
A tool support you pause/unpause your GCP resources which save your cost. This tool is designed for running on CI.
Currently, we support `gke`, `vm` and `cloud sql` resources.
**Note:** from `v0.2.0`, we deprecated `gcloud` CLI. You don't need to pre-install it to run `pause-gcp`.
## Usage
### Pause a GKE cluster
```console
$ pause-gcp gke pause --helpPause a GKE cluster.
This command require '--location' and '--project' flags.Usage:
pause-gcp gke pause [CLUSTER_NAME] [flags]Examples:
# write output from stdout
$ pause-gcp gke pause dev-cluster -l asia-southeast1 -p develop-project > output_state.json# write output to gcs bucket
$ pause-gcp gke pause dev-cluster -l asia-southeast -p develop-project --output-dir=gs://bucket-name/gke-states# write output to a directory, pause-gcp will try to create the output dir if it not exists
$ pause-gcp gke pause dev-cluster -p project --output-dir=output_states# pause cluster with some except pools
$ pause-gcp gke pause dev-cluster -p project --except-pools=critical-poolFlags:
--except-pools strings except node pools
-h, --help help for pause
-l, --location string the cluster location (default "asia-southeast1")
--output-dir gke___.json the output directory to write the cluster state. If no path is specified, this will skip the write-to-file process. The output state file has named by format gke___.json
-p, --project string the project where contain the cluster
```This command will print the previous state of the input cluster after it is paused. This state is used to recover the cluster in the unpause command.
If the `--output-dir` is a GCS bucket (start with `gs://`), this tool will push the state file to the destination directly.
### Unpause a GKE cluster
```console
$ pause-gcp gke unpause --helpUnpause a GKE cluster.
This command requires a GKE state file which is created when you pause the cluster.Usage:
pause-gcp gke unpause [STATE_FILE] [flags]Examples:
# STATE_FILE from local
$ pause-gcp gke unpause ./gke-states/gke_develop_asia-southeast1_dev-cluster.state.json# STATE_FILE from a gcs bucket
$ pause-gcp gke unpause gs://bucket/path/json_file.json --rmFlags:
-h, --help help for unpause
--rm Remove the cluster state after complete
```
The input file must be the previos state of a cluster. The input file can be a GCS url (with `gs://` prefix).### Refresh a GKE cluster
```console
$ pause-gcp gke refresh --helpRefresh a GKE cluster.
Refresh all worker nodes in all node pools of the input cluster. This command just works with node pool has type is spot or preemptible.Usage:
pause-gcp gke refresh [CLUSTER_NAME] [flags]Flags:
-h, --help help for refresh
-l, --location string the cluster location (default "asia-southeast1")
-p, --project string the project where contain the cluster
--recreate keep the instance (node) name or delete and create with new name otherwise
```This command will refresh all node pools has type as `spot` or `preemptible`. This action will prevent GCP revokes your worker nodes during working hours.
## FAQ
### Why do I need this tool?
This will save your money.### Can I use `gcloud` CLI instead?
Yes, you can. If you only need to turn off a VM or a cloud SQL instance,
you can use cloud CLI instead of this tool. But if you need to turn off a `GKE` cluster, I recommend you use `pause-gcp` because turning off a cluster is more complicated than a VM and cloud SQL.