A Go tool designed to shrink
AWS Autoscaling Clusters based on CPU
and Memory
Cloudwatch Alarm Metrics.
This tool is meant to be for people who want to scale their instances back in whenever both CPU
AND Memory
conditions are met.
- A DynamoDB table
- AWS credentials with the following permissions:
- DynamoDB Table Read/Write access
- Ability to Execute Autoscaling Policies
In order to work, your DynamoDB table should look like the one that follows:
ID | isLowCPU | isLowMemory |
---|---|---|
0 | false | false |
NB it is important that the table is pre-populated with the values showed above, most importantly you must make sure that the ID
= 0 - that value will never change.
You can directly use the go
tool to download and install the sigmund
package into your GOPATH
:
$ go get github.com/darkraiden/sigmund.go
You can also clone the repository yourself:
$ mkdir -p $GOPATH/src/github.com/darkraiden
$ cd $GOPATH/src/github.com/darkraiden
$ git clone git@git.int.avast.com:devops/sigmund
First things first, initialise a Sigmund
from your application:
// Get a Sigmund
s, err := sigmund.New(&sigmund.Config{Region: "eu-west-1", AsgName: "anASGName", PolicyName: "anASGPolicyName", TableName: "aDynamoTableName", Metric: "LowCPU"}) // LowCPU can be replaced by OkCPU, LowMemory, OkMemory, depending on which metric changed on your Cloudwatch Alerts
if err != nil {
panic(err)
}
Now that you have your Sigmund
, you're ready to update the DB and eventually execute the autoscaling group policy:
err := s.Shrink()
if err != nil {
panic(err)
}
Sigmund uses Logrus for logging. The default config is different depending on whether it was compiled for production or not (mage releaseLambda
or building with the PRODUCTION
environment variable set).
Currently, all errors are deemed irrecoverable and result in a panic.
Every Package of this project comes with some unit tests which use the Go testing
package. Run the tests, from the package folder, by typing:
$ go test ./...
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
We use SemVer for versioning. For the versions available, see the tags on this repository.
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE.md file for details