Skip to content

Instantly share code, notes, and snippets.

View andrimuhyidin's full-sized avatar
🏠
Working from home

Andri Muhyidin andrimuhyidin

🏠
Working from home
View GitHub Profile
@andrimuhyidin
andrimuhyidin / configmap.yaml
Created April 24, 2022 06:13
K8s manifest to run cronjobs GCR Cleaner
apiVersion: v1
kind: ConfigMap
metadata:
name: gcr-cleaner
data:
# AUTH
SERVICE_ACCOUNT: gcr-cleaner@adept-primer-345706.iam.gserviceaccount.com
GCR_URL_REGION: https://asia.gcr.io
# IMAGE_NAME must be full of image repository URL
IMAGE_NAME: asia.gcr.io/adept-primer-345706/alpine
@andrimuhyidin
andrimuhyidin / gcr-cleaner.sh
Last active June 8, 2022 13:50
Deleting unused image tags from Google Container Registry, leaving x number left
#!/bin/bash
IFS=$'\n\t'
set -eou pipefail
if [[ "$#" -ne 3 || "${1}" == '-h' || "${1}" == '--help' ]]; then
cat >&2 <<"EOF"
gcr-cleaner.sh will cleans up the gcr tags or untaged images pushed in a repository (image name with the specific tag)
and except the given number most recent images.