Skip to content

aliakts/keeper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Keeper - Spot VM Recovery Utility

A Cloud Function that automatically recovers terminated spot VMs in Google Cloud Platform.

Features

  • Periodically checks spot VMs
  • Automatically restarts terminated VMs
  • Scheduled execution with Cloud Scheduler
  • VM exclusion with labels:
    # Exclude a VM from recovery
    gcloud compute instances add-labels INSTANCE_NAME --labels=exclude_from_keeper=true
    
    # Include a VM back
    gcloud compute instances remove-labels INSTANCE_NAME --labels=exclude_from_keeper

Requirements

  • Terraform >= 1.0
  • Google Cloud Account
  • Google Cloud CLI installed and configured
  • Required IAM permissions:
    • Cloud Functions Admin
    • Cloud Scheduler Admin
    • Storage Admin
    • Service Account Admin
    • IAM Admin

Project Structure

keeper/
├── main.py              # Cloud Function source code
├── requirements.txt     # Python dependencies
├── terraform/          # Infrastructure as Code
│   ├── main.tf         # Main Terraform configuration
│   ├── variables.tf    # Variable definitions
│   └── terraform.tfvars.example  # Example variable values

Installation

  1. Clone the repository
  2. Authenticate with Google Cloud:
    gcloud auth application-default login
  3. Create terraform.tfvars:
    cd keeper/terraform
    cp terraform.tfvars.example terraform.tfvars
  4. Edit terraform.tfvars:
    project_id = "your-project-id"
    region     = "your-region"
    zone       = "your-zone"
    schedule   = "*/1 * * * *"  # Desired cron schedule
  5. Initialize Terraform:
    terraform init
  6. Review the plan:
    terraform plan
  7. Apply the configuration:
    terraform apply

Configuration

You can configure the following variables in terraform.tfvars:

  • project_id: Your GCP project ID
  • region: Region where resources will be created
  • zone: Zone where spot VMs are located
  • schedule: Cloud Scheduler cron expression

Cleanup

To remove all created resources:

terraform destroy

About

A self-healing utility for GCP spot VMs - automatically recovers terminated instances

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors