Automatically stop GCE instances

auto-stop-gce-instances

Architecture

How to deploy

1. Deploy Pub/Sub

$ gcloud pubsub topics create $PUBSUB_NAME

2. Deploy Cloud Functions

$ gcloud functions deploy $FUNCTIONS_NAME \
    --runtime go113 \
    --trigger-topic $PUBSUB_NAME \
    --region asia-northeast1 \
    --set-env-vars GCP_PROJECT=$GCP_PROJECT

3. Deploy Cloud Scheduler

$ gcloud scheduler jobs create pubsub $SCHEDULER_NAME \
    --time-zone "Asia/Tokyo" \
    --schedule "0 21 * * 1-5" \
    --topic $PUBSUB_NAME \
    --message-body '{"labelKey":"is-auto-stop", "labelValue":"true"}' \
    --description "Automatically stop gce instances"

References

Owner
Tomomasa Uchida
Solution Platform Development | C/C++, Python, Go, GCP
Tomomasa Uchida
Similar Resources

Simple wrapper around multiple fs.FS instances, recursively merging them together dynamically.

go-layerfs This is a simple wrapper around multiple fs.FS instances, recursively merging them together dynamically. If you have two directories, of wh

Aug 9, 2022

Cloud-Z gathers information and perform benchmarks on cloud instances in multiple cloud providers.

Cloud-Z Cloud-Z gathers information and perform benchmarks on cloud instances in multiple cloud providers. Cloud type, instance id, and type CPU infor

Jun 8, 2022

Drain-my-spot - Service draining the k8s worker node in case of spot instances related event occurrence

drain-my-spot Service draining the k8s worker node in case of spot instances rel

Feb 5, 2022

Lxmin - Backup and Restore LXC instances from MinIO

lxmin Backup and restore LXC instances from MinIO Usage NAME: lxmin - backup a

Dec 7, 2022

🚢 Go package providing lifecycle management for PostgreSQL Docker instances.

🚢  Go package providing lifecycle management for PostgreSQL Docker instances.

🚢 psqldocker powered by ory/dockertest. Go package providing lifecycle management for PostgreSQL Docker instances. Leverage Docker to run unit and in

Sep 2, 2022

Monitoring changes in the source file and automatically compile and run (restart).

Monitoring changes in the source file and automatically compile and run (restart).

dogo Monitoring changes in the source file and automatically compile and run (restart). 中文 Install go get github.com/liudng/dogo Create config Here's

Dec 28, 2022

k8s-image-swapper Mirror images into your own registry and swap image references automatically.

k8s-image-swapper Mirror images into your own registry and swap image references automatically.

k8s-image-swapper Mirror images into your own registry and swap image references automatically. k8s-image-swapper is a mutating webhook for Kubernetes

Dec 27, 2022

Automatically deploy from GitHub to Replit, lightning fast ⚡️

repl.deploy Automatically deploy from GitHub to Replit, lightning fast ⚡️ repl.deploy is split into A GitHub app, which listens for code changes and s

Dec 22, 2022

Annotated and kubez-autoscaler-controller will maintain the HPA automatically for kubernetes resources.

Kubez-autoscaler Overview kubez-autoscaler 通过为 deployment / statefulset 添加 annotations 的方式,自动维护对应 HorizontalPodAutoscaler 的生命周期. Prerequisites 在 kuber

Jan 2, 2023
Cloud-gaming-operator - The one that manages VMs for cloud gaming built on GCE

cloud-gaming-operator GCE上に建てたクラウドゲーミング用のVMを管理するやつ 事前準備 GCEのインスタンスかマシンイメージを作成してお

Jan 22, 2022
Create AWS Auto Scaling groups from running instances or AMIs automatically.

AWS Auto Scaling Groups Builder AWS Auto Scaling group is a great way of managing Amazon EC2 instances. AWS Auto Scaling group watches the correspondi

Oct 7, 2022
ecsk is a CLI tool to interactively use frequently used functions of docker command in Amazon ECS. (docker run, exec, cp, logs, stop)
ecsk is a CLI tool to interactively use frequently used functions of docker command in Amazon ECS. (docker run, exec, cp, logs, stop)

English / 日本語 ecsk ECS + Task = ecsk ?? ecsk is a CLI tool to interactively use frequently used functions of docker command in Amazon ECS. (docker run

Dec 13, 2022
Simple docker tui to list, start and stop your containers
Simple docker tui to list, start and stop your containers

docker-tui Simple docker tui that lets you list, start and stop your containers. Current status Rough, initial prototype. Build with This tool relies

Dec 2, 2022
Ever wanted to stop a PVC from deleting?
Ever wanted to stop a PVC from deleting?

cnskunkworks-unterminate Oh no! This repository will show you how to unterminate terminating kubernetes resources. It relies on manipulating the data

Nov 18, 2021
Stop using install.sh! Start using install.yml! DAJE...

Daje - A general purpose Ansible dotfiles installer Configure one time and run everywhere. What is this I've never liked using a big bash script to in

Nov 14, 2022
Kubegres is a Kubernetes operator allowing to create a cluster of PostgreSql instances and manage databases replication, failover and backup.

Kubegres is a Kubernetes operator allowing to deploy a cluster of PostgreSql pods with data replication enabled out-of-the box. It brings simplicity w

Dec 30, 2022
This plugin helps you to use the AWS Command Line Interface (AWS CLI) to start and end sessions to your managed instances

Session Manager Plugin This plugin helps you to use the AWS Command Line Interface (AWS CLI) to start and end sessions to your managed instances. Sess

Dec 28, 2022
go-awssh is a developer tool to make your SSH to AWS EC2 instances easy.

Describing Instances/VPCs data, select one or multiple instances, and make connection(s) to selected instances. Caching the response of API calls for 1day using Tmpfs.

Oct 11, 2021
A Grafana backend plugin for automatic synchronization of dashboard between multiple Grafana instances.

Grafana Dashboard Synchronization Backend Plugin A Grafana backend plugin for automatic synchronization of dashboard between multiple Grafana instance

Dec 23, 2022