haf / zorya

GCP Instance Scheduler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

zorya

GCP Instance Scheduler

Blog Post

License GitHub stars

In Slavic mythology, Zoryas are two guardian goddesses. The Zoryas represent the morning star and the evening star, — if you have read or watched Neil Gaiman’s American Gods, you will probably remember these sisters).

Install dependencies
  • Note: deployment from Google Cloud Shell fails with an error #25.

pip install -r requirements.txt -t lib

Download and install Yarn.

Deploy

./deploy.sh project-id

You need to enable compute engine API (https://console.cloud.google.com/apis/library/compute.googleapis.com) for the Zorya project/app to work and communicate with compute engine instances.

Access the app

gcloud app browse

To sign into the app, we are using Cloud Identity-Aware Proxy (Cloud IAP). Cloud IAP works by verifying a user’s identity and determining if that user should be allowed to access the application. The setup is as simple as heading over to GCP console, enabling IAP on your GAE app and adding the users who should have access to it.

Authentication

In order to allow Zorya to manage instances on your behalf in any project under your organization, you will need to create a new entry in your Organization IAM and assign Zorya’s service account with a role of XXXX First, navigate to https://console.cloud.google.com, then IAM from the menu and then select the name of your organization (not just specific project) from the dropdown at the top of the page:

The name of the service account you will need to assign permissions to is as following:project-id@appspot.gserviceaccount.com, just replace project-id with your real project id where you deploy Zorya.

Flow

  • Every hour on the hour a cron job calls /tasks/schedule which loop over all the policies
  • We are checking the desired state vs the previous hour desired state. If they are not the same we will apply the change.

API Documentation

Creating a Schedule

Creating a Policy

About

GCP Instance Scheduler

License:MIT License


Languages

Language:JavaScript 79.5%Language:Python 18.3%Language:HTML 1.8%Language:Shell 0.5%