K8s Tag Mapper¶
When a GitLab pipeline that builds a tag succeeds, the Tag Mapper creates a K8s Package Profile for that tag, then upgrades the Releases you chose to it.
How it works¶
- You push a tag. Your GitLab CI builds the container image and pushes it as
<image repository>:<tag>. Muppy builds nothing. - GitLab sends a Pipeline events webhook to Muppy at each status of the pipeline.
- Muppy finds the Application Definition by its Git Project ID. It acts only on a pipeline that succeeded and built a tag.
- Muppy reads the tag's code —
betain1.4.0-beta.3— and runs every rule with that code. - Each rule creates a Package Profile for the tag. When the rule says so, Muppy then upgrades the matching Releases to it.
All of it runs in the background, in IMQ messages under Muppy › Qs › Messages.
The Tag Mapper reacts to GitLab pipeline events only.
Turn it on¶
Before you start, connect GitLab and tick Pipeline events on the project's webhook.
Open the Application Definition (Muppy › Applications › Applications › Application Definitions):
- In the header, set Git Project ID, then check Activate K8s CD. The K8s CD tab appears.
- In the K8s CD tab, set K8S App: the Kubernetes application this repository builds.
- Keep Use Tag deployment workflow checked, and check Use Tag mapper (New!).
- Set Base K8s Profile for mapped tag: the profile each new profile is derived from, unless a rule names its own.
- Add rules to K8s deployment Tag map.
The form also requires Default K8s Package Profile once Activate K8s CD is on. The Tag Mapper does not read it.
Rules¶
Each line of K8s deployment Tag map is a rule:
| Column | Meaning |
|---|---|
| (handle) | Drag it to order the rules. |
| Tag match code | The code of the tags this rule handles. |
| Create K8s Profile | Always on: every rule creates its profile. |
| Base K8s Profile | The profile the new one derives from. Empty, Base K8s Profile for mapped tag is used. |
| App Suffix | Appended to the profile's name. Gives this rule a profile of its own. |
| Deploy | Upgrade the matching Releases once the profile exists. |
| Selector qualifiers | The qualifiers of the Releases to upgrade. |
The tag's code¶
The tag must be a SemVer version. Its code is the first word of its pre-release part:
| Tag | Code |
|---|---|
1.4.0-beta.3 |
beta |
1.4.0-rc.1 |
rc |
18.97.0-alpha.mkeyd-k8s.3 |
alpha |
1.4.0 |
:all_stable_tags |
The match is exact and case-sensitive: 1.4.0-Beta.1 and 1.4.0-beta2 do not match beta.
Any word works as a code. A tag that is not SemVer, such as v1.4.0, fails the message with
… is not valid SemVer string.
The profile a rule creates¶
- Its name is
<K8S App>:<tag>, or<K8S App>-<App Suffix>:<tag>. - Its image is the base profile's Docker Image Repository, tagged with the git tag. Your CI must push the image under exactly that tag.
- Its APP Version is the tag, and its Application Definition is this one.
Two rules with the same code and no App Suffix share one profile: the second finds the profile the first created. Give each rule its own App Suffix to get a profile per rule — for instance one sized for staging and one for production.
New profiles are listed under Muppy › K8s › Package Profile.
What Deploy upgrades¶
With Deploy checked and Selector qualifiers set, Muppy upgrades every Release that:
- already exists — the Tag Mapper never installs one, so create the first Release by hand;
- has one of the Selector qualifiers;
- runs a profile whose Application Definition is this one.
Each upgrade runs in its own message, named
Upgrade '<Release>' to Profile '<Profile>' (Rule N). Releases are listed under Muppy ›
K8s › Released Applications › Installed Packages.
Deploy unchecked, the rule only creates the profile. Upgrade the Releases to it by hand.
Several rules for one code: the last one deploys¶
The rules of a code run in order. When two rules with Deploy name the same qualifier, only the last one upgrades its Releases. Every rule still creates its profile.
Rule 1: beta, Selector qualifiers [staging, qa]
Rule 2: beta, Selector qualifiers [qa, demo]
staging → Rule 1
qa → Rule 2 (the last rule wins)
demo → Rule 2
Each qualifier receives one upgrade per tag.
Examples¶
A profile per build level, nothing deployed. Four rules — alpha, beta, rc,
:all_stable_tags — with Deploy unchecked. Every tag gets its profile; each Release is
moved to a new version by hand. This is how Muppy's own releases are built.
Betas to staging, stable versions by hand.
Rule 1: beta, Deploy ✓, Selector qualifiers [staging]
Rule 2: :all_stable_tags, Deploy ✗
Two sizes for one tag.
Rule 1: rc, App Suffix small, Base K8s Profile app-small, Deploy ✓, [staging]
Rule 2: rc, App Suffix large, Base K8s Profile app-large, Deploy ✓, [production]
Follow a tag¶
GitLab sends one webhook per status of the pipeline. Each becomes a message:
Gitlab Webhook:'pipeline' project='acme-erp' tag='1.4.0-beta.3' status='success' by jdoe.
Only success acts; the other statuses log Pipeline event:'<status>' ignored. Open the
success message: its journal lists, rule by rule, the profile created and the Releases
upgraded.
Troubleshooting¶
| Journal line | Cause | Fix |
|---|---|---|
No match found in tag map for code:<code> |
No rule has this code. | Add a rule, or check the tag's spelling. |
… is not valid SemVer string |
The tag is not SemVer, e.g. v1.4.0. |
Tag 1.4.0. |
Rule N: No base profile specified. Skipping this rule. |
Neither the rule nor Base K8s Profile for mapped tag names a base. | Set one. |
Rule N: Found 0 '<qualifier>' package release(s) to upgrade. |
No Release has this qualifier and a profile of this Application Definition. | Install the first Release by hand, on a profile of this Application Definition. |
Rule N: Deploy flag is False. Profile created but deployment skipped… |
Deploy is unchecked. | Expected, or check it. |
Rule N: Skipping deployment to qualifier '…' (rule M will deploy…) |
A later rule names the same qualifier. | Expected: the last rule wins. |
k8s_package_profile::duplicate - Found existing profile:… |
Another rule of this code already created the profile. | Give each rule its own App Suffix. |
Found no App. Def. for Git Project '…' |
No Application Definition has this Git Project ID. | Set it. |
Found several App. Def … |
Several Application Definitions share the Git Project ID. | Set Ref. selection Regex on each, so that only one matches the tag. |
K8s Tag deployment workflow if off in Application Definition … |
Use Tag deployment workflow is unchecked. | Check it. |
A rule that fails logs Rule N: Error during processing: … Continuing to next rule. The next
rules still run, and the message ends done.
Duplicating an Application Definition¶
A duplicate keeps every rule and its Base K8s Profile for mapped tag. Its Tag Mapper creates profiles at once.
It upgrades nothing until a Release runs one of its own profiles: Muppy only upgrades Releases whose profile names this Application Definition, and the duplicate has none yet. Install its first Releases by hand.
A duplicate also keeps the Git Project ID. Set Ref. selection Regex on both
Application Definitions, or each tag fails with Found several App. Def ….