Skip to content

Commit 11536bf

Browse files
authored
Sign images using cosign (#1389)
Summary: This uses cosign to sign all of our images. Type of change: /kind cleanup Test Plan: Created RCs for operator, cloud, and vizier. Verified that they were all signed as expected. Signed-off-by: Vihang Mehta <vihang@pixielabs.ai>
1 parent 80acc6b commit 11536bf

File tree

5 files changed

+23
-1
lines changed

5 files changed

+23
-1
lines changed

.github/workflows/cloud_release.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ jobs:
3838
BUILD_NUMBER: ${{ github.run_attempt }}
3939
JOB_NAME: ${{ github.job }}
4040
GH_API_KEY: ${{ secrets.GITHUB_TOKEN }}
41+
COSIGN_PASSWORD: ${{secrets.COSIGN_PASSWORD}}
42+
COSIGN_PRIVATE_KEY: ${{secrets.COSIGN_PRIVATE_KEY}}
4143
shell: bash
4244
run: |
4345
export TAG_NAME="${REF#*/tags/}"

.github/workflows/operator_release.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ jobs:
3737
REF: ${{ github.event.ref }}
3838
BUILD_NUMBER: ${{ github.run_attempt }}
3939
JOB_NAME: ${{ github.job }}
40+
COSIGN_PASSWORD: ${{secrets.COSIGN_PASSWORD}}
41+
COSIGN_PRIVATE_KEY: ${{secrets.COSIGN_PRIVATE_KEY}}
4042
shell: bash
4143
run: |
4244
export TAG_NAME="${REF#*/tags/}"

.github/workflows/vizier_release.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ jobs:
3737
REF: ${{ github.event.ref }}
3838
BUILD_NUMBER: ${{ github.run_attempt }}
3939
JOB_NAME: ${{ github.job }}
40+
COSIGN_PASSWORD: ${{secrets.COSIGN_PASSWORD}}
41+
COSIGN_PRIVATE_KEY: ${{secrets.COSIGN_PRIVATE_KEY}}
4042
shell: bash
4143
run: |
4244
export TAG_NAME="${REF#*/tags/}"

ci/cloud_build_release.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ echo "The image tag is: ${release_tag}"
3535
bazel run --config=stamp -c opt --action_env=GOOGLE_APPLICATION_CREDENTIALS --//k8s:image_version="${release_tag}" \
3636
--//k8s:build_type=public //k8s/cloud:cloud_images_push
3737

38+
while read -r image;
39+
do
40+
image_digest=$(crane digest "${image}")
41+
cosign sign --key env://COSIGN_PRIVATE_KEY --yes -r "${image}@${image_digest}"
42+
done < <(bazel run --config=stamp -c opt --action_env=GOOGLE_APPLICATION_CREDENTIALS --//k8s:image_version="${release_tag}" \
43+
--//k8s:build_type=public //k8s/cloud:list_image_bundle)
44+
3845
all_licenses_opts=("//tools/licenses:all_licenses" "--action_env=GOOGLE_APPLICATION_CREDENTIALS" "--remote_download_outputs=toplevel")
3946
all_licenses_path="$(bazel cquery "${all_licenses_opts[@]}" --output starlark --starlark:expr "target.files.to_list()[0].path" 2> /dev/null)"
4047
bazel build "${all_licenses_opts[@]}"

ci/image_utils.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
#
1717
# SPDX-License-Identifier: Apache-2.0
1818

19+
sign_image() {
20+
multiarch_image="$1"
21+
image_digest="$2"
22+
23+
cosign sign --key env://COSIGN_PRIVATE_KEY --yes -r "${multiarch_image}@${image_digest}"
24+
}
25+
1926
push_images_for_arch() {
2027
arch="$1"
2128
image_rule="$2"
@@ -38,7 +45,9 @@ push_multiarch_image() {
3845
# instead it seems to just ignore images that already exist in the local manifest.
3946
docker manifest rm "${multiarch_image}" || true
4047
docker manifest create "${multiarch_image}" "${x86_image}" "${aarch64_image}"
41-
docker manifest push "${multiarch_image}"
48+
pushed_digest=$(docker manifest push "${multiarch_image}")
49+
50+
sign_image "${multiarch_image}" "${pushed_digest}"
4251
}
4352

4453
push_all_multiarch_images() {

0 commit comments

Comments
 (0)