Skip to content

Commit

Permalink
Add a janitor periodic job to cleanup stale ec2 instances from the no…
Browse files Browse the repository at this point in the history
…de-e2e-tests service account

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
  • Loading branch information
dims committed Aug 16, 2023
1 parent c6d834f commit 67d6374
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions config/jobs/kubernetes/sig-testing/ec2-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -347,3 +347,40 @@ periodics:
requests:
cpu: 8
memory: 10Gi
- interval: 12h
cluster: eks-prow-build-cluster
name: ci-aws-ec2-janitor
annotations:
testgrid-dashboards: amazon-ec2
testgrid-tab-name: aws-ec2-janitor
description: cleanup any EC2 instances older than 2 days
labels:
preset-e2e-containerd-ec2: "true"
decorate: true
decoration_config:
timeout: 4h
spec:
serviceAccountName: node-e2e-tests
containers:
- image: gcr.io/k8s-staging-test-infra/kubekins-e2e:v20230727-ea685f8747-master
command:
- runner.sh
args:
- bash
- -c
- |
set -xeu
target=$(date -d "2 days ago" +%Y-%m-%d)
region="us-east-1"
# Is the Launch time *before* two days ago? if so then terminate the instance.
for id in `aws ec2 describe-instances --query "Reservations[].Instances[?LaunchTime<='$target'][].{id: InstanceId}" --filters "Name=instance-state-name,Values=running" --output text`
do
aws ec2 --region us-east-1 terminate-instances --instance-ids $id
done
resources:
limits:
cpu: 2
memory: 4Gi
requests:
cpu: 2
memory: 4Gi

0 comments on commit 67d6374

Please sign in to comment.