HUB
Sign inSign up
aws-ec2-runtime-checker logo

rayselfs/aws-ec2-runtime-checker

By rayselfs

•Updated 12 months ago

Image
0

1.8K

rayselfs/aws-ec2-runtime-checker repository overview

⁠AWS EC2 Runtime Checker

Monitors AWS EC2 instances and automatically terminates those exceeding configured runtime thresholds.

⁠Features

  • 🔍 Instance Monitoring: Tracks EC2 instances by type and runtime duration
  • ⏰ Flexible Scheduling: Supports both Kubernetes CronJob and Deployment modes
  • 🎯 Per-Type Configuration: Set different runtime thresholds for each instance type
  • 🛡️ Dry Run Mode: Test without actually terminating instances
  • 🔔 SNS Notifications: Sends alerts before taking action

⁠Prerequisites

  • Kubernetes 1.23+
  • Helm 3.8.0+
  • AWS credentials with appropriate permissions

⁠Installation

helm repo add aws-ec2-runtime-checker https://rayselfs.github.io/aws-ec2-runtime-checker
helm install aws-ec2-runtime-checker aws-ec2-runtime-checker/aws-ec2-runtime-checker

For detailed Helm configuration options, IAM policies, and deployment modes, see the Helm Chart README⁠.

⁠From Source
git clone https://github.com/rayselfs/aws-ec2-runtime-checker
cd aws-ec2-runtime-checker
helm install aws-ec2-runtime-checker ./charts/aws-ec2-runtime-checker

⁠Quick Start

⁠Basic Configuration

Create a values.yaml file:

aws:
  region: "us-east-1"

dryRun: true # Set to false to enable actual termination

targets:
  - instanceType: "t2.micro"
    maxRuntimeHours: 24
  - instanceType: "t3.micro"
    maxRuntimeHours: 48

Install with custom values:

helm install aws-ec2-runtime-checker aws-ec2-runtime-checker/aws-ec2-runtime-checker -f values.yaml

For complete configuration options and production setup, refer to the Helm Chart README⁠.

⁠Config File Format

The config.json file (mounted via ConfigMap) should contain:

[
  {
    "instanceType": "t2.micro",
    "maxRuntimeHours": 24
  },
  {
    "instanceType": "t3.micro",
    "maxRuntimeHours": 48
  }
]

⁠Usage

⁠Deployment Mode (Continuous Monitoring)
kind: Deployment
replicaCount: 2
schedule: "*/5 * * * *" # Every 5 minutes

leaderElection:
  enabled: true # Required when replicaCount > 1
⁠CronJob Mode (Scheduled Checks)
kind: CronJob
schedule: "0 */6 * * *" # Every 6 hours

⁠License

This project is licensed under the Apache License 2.0 - see the LICENSE⁠ file for details.

⁠Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Tag summary

Content type

Image

Digest

sha256:562e5b2f8…

Size

20.2 MB

Last updated

12 months ago

docker pull rayselfs/aws-ec2-runtime-checker