GoogleContainerTools / container-debug-support

Language-runtime support files for in-container debugging
Apache License 2.0
93 stars 25 forks source link

ci: add gcb script to promote images on GitHub release #111

Closed briandealwis closed 2 years ago

briandealwis commented 2 years ago

This PR adds a GCB script to handle promoting images to gcr.io/k8s-skaffold/skaffold-debug-support as triggered by a GitHub release tagging event. Currently the images are promoted by hand, and there is no easy way for users to rollback to an earlier set of images. It is also difficult to trace back an image to the corresponding commit.

Approach

With the approach encoded in this promotion script, images are copied into gcr.io/k8s-skaffold/skaffold-debug-support and be promoted to latest. The images are copied in using a naming scheme that allows users to easily use images from a specific release. Images are also tagged with the SHORT-SHA of the commit; this is admittedly imperfect and #110 tracks embedding this information as image annotations.

Release tags are generally expected (though not required) to follow a tagging format like v1.0, with a major and minor version. On a release, this script will place the resulting images in

gcr.io/k8s-skaffold/skaffold-debug-support/<release>

The images in this location will be tagged as both latest and with the commit's <SHORT-SHA>. This allows users to use these images by setting the Skaffold global config property debug-helpers-registry.

If the <release> has a major version (e.g., v1.1 has major version v1), then the images will furthermore be placed in

gcr.io/k8s-skaffold/skaffold-debug-support/<major-version>

tagged with <release> and <SHORT-SHA>. When _IS_LATEST=1 (the default), then the images will also be tagged with latest. So users can use the latest version within a major-release without having to track the specific release.

There is an additional special case: if the major version is v1 and _IS_LATEST=1 (the default), then the images will also be copied to

gcr.io/k8s-skaffold/skaffold-debug-support/

and tagged with latest, <major-version>, and <SHORT-SHA>. This maintains backwards compatibility with the deployed Skaffold installations. The intention is that the current images will be released as v1.0.

How it works

Currently this project has a GCB script that builds images on each commit to HEAD and stores the results under

us-central1-docker.pkg.dev/k8s-skaffold/skaffold-staging/skaffold-debug-support/<SHORT-SHA>

On a release tag, this new cloudbuild-promote.yaml script copies out the staged images for the corresponding commit SHA1 and places them into gcr.io/k8s-skaffold/skaffold-debug-support/ using the rules described above.

Further work