Skip to content

Commit

Permalink
feat: set quay image expiry to prevent overflow of images
Browse files Browse the repository at this point in the history
Signed-off-by: KevFan <[email protected]>
  • Loading branch information
KevFan committed Sep 5, 2024
1 parent b7a58ca commit 9e481f6
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
11 changes: 11 additions & 0 deletions .github/workflows/build-images-base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ on:
description: Bundle and catalog channels, comma separated
default: preview
type: string
quayImageExpiry:
description: When to expire the built quay images. The time values could be something like 1h, 2d, 3w for hours, days, and weeks, respectively, from the time the image is built.
default: never
type: string
workflow_dispatch:
inputs:
kuadrantOperatorTag:
Expand Down Expand Up @@ -69,6 +73,10 @@ on:
description: Bundle and catalog channels, comma separated
default: preview
type: string
quayImageExpiry:
description: When to expire the built quay images. The time values could be something like 1h, 2d, 3w for hours, days, and weeks, respectively, from the time the image is built.
default: never
type: string

env:
IMG_TAGS: ${{ inputs.kuadrantOperatorTag }}
Expand Down Expand Up @@ -107,6 +115,7 @@ jobs:
provenance: false
tags: |
${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }}/${{ env.OPERATOR_NAME }}:${{ env.IMG_TAGS }}
build-args: QUAY_IMAGE_EXPIRY=${{ inputs.quayImageExpiry }}
- name: Print Image URL
run: echo "Image pushed to ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }}/${{ env.OPERATOR_NAME }}:${{ env.IMG_TAGS }}"

Expand Down Expand Up @@ -155,6 +164,7 @@ jobs:
provenance: false
tags: |
${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }}/${{ env.OPERATOR_NAME }}-bundle:${{ env.IMG_TAGS }}
build-args: QUAY_IMAGE_EXPIRY=${{ inputs.quayImageExpiry }}
- name: Print Bundle Image URL
run: echo "Bundle image pushed to ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }}/${{ env.OPERATOR_NAME }}-bundle:${{ env.IMG_TAGS }}"

Expand Down Expand Up @@ -202,5 +212,6 @@ jobs:
provenance: false
tags: |
${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }}/${{ env.OPERATOR_NAME }}-catalog:${{ env.IMG_TAGS }}
build-args: QUAY_IMAGE_EXPIRY=${{ inputs.quayImageExpiry }}
- name: Print Catalog Image URL
run: echo "Catalog image pushed to ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }}/${{ env.OPERATOR_NAME }}-catalog:${{ env.IMG_TAGS }}"
1 change: 1 addition & 0 deletions .github/workflows/build-images-branches.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ jobs:
with:
kuadrantOperatorVersion: ${{ github.ref_name }}
kuadrantOperatorTag: ${{ github.ref_name }}
quayImageExpiry: 2w
1 change: 1 addition & 0 deletions .github/workflows/build-images-nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ jobs:
limitadorOperatorVersion: ${{ vars.LIMITADOR_OPERATOR_SHA }}
dnsOperatorVersion: ${{ vars.DNS_OPERATOR_SHA }}
wasmShimVersion: ${{ vars.WASM_SHIM_SHA }}
quayImageExpiry: 1w
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@ WORKDIR /
COPY --from=builder /workspace/manager .
USER 65532:65532

# When to expire Quay image
ARG QUAY_IMAGE_EXPIRY
ENV QUAY_IMAGE_EXPIRY=${QUAY_IMAGE_EXPIRY:-never}
LABEL quay.expires-after=$QUAY_IMAGE_EXPIRY

ENTRYPOINT ["/manager"]
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ SHELL = /usr/bin/env bash -o pipefail
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
PROJECT_PATH := $(patsubst %/,%,$(dir $(MKFILE_PATH)))

QUAY_IMAGE_EXPIRY ?= never

# Container Engine to be used for building image and with kind
CONTAINER_ENGINE ?= docker

Expand Down Expand Up @@ -341,7 +343,7 @@ run: generate fmt vet ## Run a controller from your host.
go run ./main.go

docker-build: ## Build docker image with the manager.
$(CONTAINER_ENGINE) build -t $(IMG) .
$(CONTAINER_ENGINE) build --build-arg QUAY_IMAGE_EXPIRY=$(QUAY_IMAGE_EXPIRY) -t $(IMG) .

docker-push: ## Push docker image with the manager.
$(CONTAINER_ENGINE) push $(IMG)
Expand Down

0 comments on commit 9e481f6

Please sign in to comment.