diff --git a/config/jobs/kubernetes/sig-testing/ec2-e2e.yaml b/config/jobs/kubernetes/sig-testing/ec2-e2e.yaml index 178b4b63bd4f..fc75e9b16ea5 100644 --- a/config/jobs/kubernetes/sig-testing/ec2-e2e.yaml +++ b/config/jobs/kubernetes/sig-testing/ec2-e2e.yaml @@ -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