k8wiz
Flux CD
Medium
Integration

CI tags main branch builds as main-<short-sha>-<unix-timestamp>. Which ImagePolicy reliably picks the newest build?

Select your answer:

Show answer and explanation

Answer: filterTags extracting the timestamp, with policy.numerical.order: asc

Explanation

A pattern such as '^main-[a-fA-F0-9]+-(?P<ts>[1-9][0-9]*)' with extract: '$ts' hands only the timestamp to the policy, and a numerical policy with order asc picks the highest one. Sorting full tags alphabetically orders them by commit SHA, which is random. These tags are not semver, so a semver range never matches them.

Read more about Flux CD