Skip to content

Commit

Permalink
✨ add new build for new k8s registry infra-prow
Browse files Browse the repository at this point in the history
  • Loading branch information
camilamacedo86 committed May 7, 2023
1 parent b86694d commit 644007a
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 6 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,23 @@ its upstream quay.io source.
GCP Cloud Build watches this branch. On every push, it runs the pipeline
defined in [build/cloudbuild_kube-rbac-proxy.yaml][cloudbuild-file], which
grabs the source images from `quay.io/brancz/kube-rbac-proxy` and tags them as
`gcr.io/kubebuilder/kube-rbac-proxy`, with a tag for each arch as well as
`gcr.io/k8s-staging-kubebuilder/kube-rbac-proxy`, with a tag for each arch as well as
a single manifest bundle of:

- amd64
- arm64
- ppc64le
- s390x

There's also a helper script in [build/thirdparty](build/thirdparty) to assist in the process.
Then, once the image be build it should be promoted via https://github.com/kubernetes/k8s.io/blob/main/k8s.gcr.io/images/k8s-staging-kubebuilder/images.yaml
and once this gets merged, the images will be available on registry.k8s.io/kubebuilder/image. This Cloudbuild
manifest is started via prow in https://github.com/kubernetes/test-infra/tree/master/config/jobs/image-pushing.

**NOTE** Previously, the images were rebuilt as gcr.io/kubebuilder/kube-rbac-proxy. The job
to trigger them were present [here](https://console.cloud.google.com/gcr/images/kubebuilder/global/kube-rbac-proxy)
which has been kept as legacy until we be able to ensure the transition to the new
k8s registry.


To update, simply update the variable at the top of the [cloudbuild file][cloudbuild-file],
then submit a PR against this branch.
Expand Down
50 changes: 50 additions & 0 deletions build-legacy/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright 2021 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#!/usr/bin/env bash

# This script effectively retags the quay.io/brancz/kube-rbac-proxy image
# as a grc.io/kubebuilder registry image and pushes it (and all constituent images).
# This script cannot be inlined due to:
# https://github.com/GoogleCloudPlatform/cloud-build-local/issues/129

set -eu

SOURCE_IMAGE_TAG="quay.io/brancz/kube-rbac-proxy:${KUBE_RBAC_PROXY_VERSION}"
TARGET_IMAGE_TAG="gcr.io/kubebuilder/kube-rbac-proxy:${KUBE_RBAC_PROXY_VERSION}"

# Each arch to pull an image for.
declare ARCHES
ARCHES=( amd64 arm64 ppc64le s390x )

declare IMAGES
for a in ${ARCHES[@]}; do
docker pull "${SOURCE_IMAGE_TAG}-$a"
docker tag "${SOURCE_IMAGE_TAG}-$a" "${TARGET_IMAGE_TAG}-$a"
# These images must exist remotely to build a manifest list.
docker push "${TARGET_IMAGE_TAG}-$a"
# weird syntax for bash<4.4
IMAGES=( ${IMAGES[@]+"${IMAGES[@]}"} "${TARGET_IMAGE_TAG}-$a" )
done

# `manifest` is an experimental CLI feature.
export DOCKER_CLI_EXPERIMENTAL=enabled

# If $TARGET_IMAGE_TAG exists, `manifest create` will fail.
docker manifest rm "$TARGET_IMAGE_TAG" || true
docker manifest create "$TARGET_IMAGE_TAG" ${IMAGES[@]}
for a in ${ARCHES[@]}; do
docker manifest annotate "$TARGET_IMAGE_TAG" "${TARGET_IMAGE_TAG}-$a" --arch $a
done
docker manifest push "$TARGET_IMAGE_TAG"
24 changes: 24 additions & 0 deletions build-legacy/cloudbuild_kube-rbac-proxy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2021 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

substitutions:
# This is the kube-rbac-proxy version, source image tags for which must exist remotely.
_KUBE_RBAC_PROXY_VERSION: v0.14.1
steps:
- name: "gcr.io/cloud-builders/docker"
env:
- "KUBE_RBAC_PROXY_VERSION=${_KUBE_RBAC_PROXY_VERSION}"
entrypoint: "/usr/bin/env"
args: ["bash", "-c", "./build-legacy/build.sh"]
images: ["gcr.io/kubebuilder/kube-rbac-proxy:${_KUBE_RBAC_PROXY_VERSION}"]
2 changes: 1 addition & 1 deletion build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
set -eu

SOURCE_IMAGE_TAG="quay.io/brancz/kube-rbac-proxy:${KUBE_RBAC_PROXY_VERSION}"
TARGET_IMAGE_TAG="gcr.io/kubebuilder/kube-rbac-proxy:${KUBE_RBAC_PROXY_VERSION}"
TARGET_IMAGE_TAG="gcr.io/k8s-staging-kubebuilder/kube-rbac-proxy:${KUBE_RBAC_PROXY_VERSION}"

# Each arch to pull an image for.
declare ARCHES
Expand Down
11 changes: 8 additions & 3 deletions build/cloudbuild_kube-rbac-proxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ substitutions:
# This is the kube-rbac-proxy version, source image tags for which must exist remotely.
_KUBE_RBAC_PROXY_VERSION: v0.14.1
steps:
- name: "gcr.io/cloud-builders/docker"
- name: 'gcr.io/k8s-staging-test-infra/gcb-docker-gcloud:v20211118-2f2d816b90'
env:
- "KUBE_RBAC_PROXY_VERSION=${_KUBE_RBAC_PROXY_VERSION}"
entrypoint: "/usr/bin/env"
args: ["bash", "-c", "./build/build.sh"]
images: ["gcr.io/kubebuilder/kube-rbac-proxy:${_KUBE_RBAC_PROXY_VERSION}"]
args:
- bash
- -c
- |
gcloud auth configure-docker \
&& ./build/build.sh
images: ["gcr.io/k8s-staging-kubebuilder/kube-rbac-proxy:${_KUBE_RBAC_PROXY_VERSION}"]

0 comments on commit 644007a

Please sign in to comment.