Add image-cache, improve cleanup

This commit is contained in:
Stefan Reimer 2023-05-24 09:54:05 +00:00
parent c9e09a9a73
commit 22cc3a226b
4 changed files with 17 additions and 6 deletions

View File

@ -1,8 +1,7 @@
#!/bin/bash
# set -x
TAG_FILTER="Name=tag:Name,Values=*-uefi-*kubezero*"
TAG_FILTER="Name=tag:Name,Values=*3.17*minimal*"
TAG_FILTER="Name=tag:Name,Values=*-uefi-*minimal*r1"
# TAG_FILTER="Name=tag:Name,Values=zdt-alpine-3.16.2-x86_64-bios-tiny-kubezero-1.23.10-r0"
# TAG_FILTER="Name=tag:Name,Values=zdt-alpine-3.16.2-x86_64-bios-tiny-minimal-r2"
@ -16,13 +15,24 @@ for r in eu-central-1 us-west-2 ap-southeast-2 ca-central-1 us-east-1 us-west-1;
aws ec2 deregister-image --region $r --image-id $a && echo "Deleted AMI $a in $r"
done
# failed AMIs
amis=$(aws ec2 describe-images --region $r --owners self --output json --filters Name=state,Values=failed | jq -r '.Images[].ImageId')
for a in $amis; do
aws ec2 deregister-image --region $r --image-id $a && echo "Deleted AMI $a in $r"
done
amis=$(aws ec2 describe-images --region $r --owners self --output json --query 'Images[? ! not_null(Tags)].{ID:ImageId,Name:Tags[?Key==`Name`]|[0].Value}' | jq -r '.[].ID')
for a in $amis; do
aws ec2 deregister-image --region $r --image-id $a && echo "Deleted AMI $a in $r"
done
snapshots=$(aws ec2 describe-snapshots --region $r --owner-ids self --output json --filters $TAG_FILTER | jq -r '.Snapshots[].SnapshotId')
for s in $snapshots; do
aws ec2 delete-snapshot --snapshot-id $s --region $r && echo "Deleted snapshot $s in $r"
done
# delete orphaned snapshots
snapshots=$(aws ec2 describe-snapshots --region $r --owner-ids self --output json --query 'Snapshots[? ! not_null(Tags)].{ID:SnapshotId,Time:StartTime,Name:Tags[?Key==`Name`]|[0].Value}' | jq -r '.[].ID')
for s in $snapshots; do
aws ec2 delete-snapshot --snapshot-id $s --region $r && echo "Deleted snapshot $s in $r"
done
done

View File

@ -1,2 +1,3 @@
curl = true
kubezero = "kubezero=~1.25"
curl = true
kubezero = "kubezero=~1.25"
kubezero-imagecache = "kubezero=~1.25"

View File

@ -7,7 +7,7 @@ services { include required("kubezero-services.conf") }
description = [ "- https://kubezero.com" ]
name = [ kubezero-1.25.8 ]
# size = 2G
size = 2G
WHEN {
x86_64 {

View File

@ -69,7 +69,7 @@ Dimensions {
aws.regions {
ALL = false
ap-southeast-2 = true
#ca-central-1 = true
ca-central-1 = true
eu-central-1 = true
us-east-1 = true
us-west-1 = true