Metadata-Version: 2.4
Name: spotter-cli
Version: 1.0.1
Summary: Production-grade spot instance scheduling for EKS worker nodes
Project-URL: Repository, https://github.com/mrlikl/spotter
Project-URL: Issues, https://github.com/mrlikl/spotter/issues
Project-URL: Documentation, https://github.com/mrlikl/spotter/blob/main/README.md
Author: Spotter Authors
License: MIT License
        
        Copyright (c) 2025 Spotter Authors
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: aws,cost-optimization,eks,kubernetes,spot-instances
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: System :: Systems Administration
Classifier: Topic :: Utilities
Requires-Python: >=3.9
Requires-Dist: boto3
Requires-Dist: botocore
Requires-Dist: rich
Requires-Dist: typer
Description-Content-Type: text/markdown

# Spotter

**Production-grade spot instance scheduling for EKS worker nodes**

Spotter intelligently manages EC2 spot instances as EKS worker nodes, automatically finding the cheapest ARM64 instances across availability zones while handling interruptions gracefully. Achieves 70-80% cost savings over on-demand instances.

![spotter](docs/spotter.png)

## Features

- **Real-time Pricing Analysis**: Continuous spot price monitoring with automatic instance selection
- **Multi-AZ Distribution**: Optimal instance placement across availability zones
- **Interruption Resilience**: Automatic replacement with fallback instance types
- **ARM64 Optimization**: Targets modern ARM64 families (c7g, c8g, m7g, m8g, r7g, r8g)
- **EKS Integration**: Native integration via CloudFormation launch templates

## Architecture

### Core Components

**Spotter Lambda**
- Analyzes spot pricing every 10 minutes
- Stores top 6 cheapest instances per AZ in SSM parameters
- Filters for ARM64, current-generation, non-burstable instances

**InstanceRunner Lambda**
- Launches instances based on pricing recommendations
- Handles spot interruption events with same-AZ replacement
- Implements intelligent fallback on Capacity issues

## Installation

### Prerequisites

- AWS CLI configured with appropriate permissions
- SAM CLI installed
- EKS cluster with kubectl access
- EC2 Spot service-linked role

```bash
pip install spotter-cli
```

### Quick Start


```bash
# Bootstrap Infrastructure
$ spotter bootstrap --region us-west-2

# Onboard EKS Cluster
$ spotter onboard my-cluster --region us-west-2

# Launch Instances
$ spotter scale my-cluster --count 3 --region us-west-2
```

### Scale to count

`--scale-to-count` will scale up or down to the `count` specified

```bash
$ spotter scale my-cluster --count 7 --scale-to-count --region us-west-2
```
![scale](docs/scale.png)

### Rebalancing

rebalance will make the instance spread across AZ's

```bash
$ spotter rebalance my-cluster --region us-west-2
```
![rebalance](docs/rebalance.png)


### Commands
```bash
bootstrap        Deploy Spotter infrastructure
destroy          Destroy Spotter infrastructure
onboard          Onboard an EKS cluster to spotter
list-clusters    List onboarded clusters
offboard         Remove a cluster from Spotter
scale            Scale Spotter instances for a cluster
list-instances   Show current instance status for a cluster
rebalance        Rebalance instances across availability zones
refresh-prices   Refresh spot pricing data
pricing          View spot pricing data  
```

![list](docs/list-instances.png)

### Data Storage
Pricing data stored in SSM parameters:
- `/spotter/prices/{az}` - Top 6 instances per availability zone
- `/spotter/settings/{cluster}` - Cluster configuration


## Monitoring & Troubleshooting

### CloudWatch Logs
- `/aws/lambda/Spotter` - Pricing analysis logs
- `/aws/lambda/InstanceRunner` - Instance launch logs

### Troubleshooting
See [docs/troubleshooting.md](docs/troubleshooting.md) for comprehensive troubleshooting guidance.

## Cleanup

Remove all Spotter resources:
```bash
spotter destroy --region us-west-2
```

For cluster-specific cleanup:
```bash
spotter offboard my-cluster --region us-west-2
```

---

Vibe coded with [Amazon Q](https://github.com/aws/amazon-q-developer-cli)
