Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ add new build for new k8s registry infra-prow #3362

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}"]
Copy link
Member Author

@camilamacedo86 camilamacedo86 Apr 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @rikatz,

See that I just changed the step name and image to be built.
Is that right? We need to:

c/c @varshaprasad96 @yashsingh74

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

almost 100% :)
(and I am almost 100% sure on what I am saying!)

the one thing that we do in ingress is to do the push from the build script, and not from the cloudbuild job.

Take a look in https://github.com/kubernetes/ingress-nginx/blob/main/cloudbuild.yaml#L17-L21

We need a credential to push the image (so this is the gcloud auth ....) and after this, the container is able to push images, so our release just calls "docker buildx" to build the image and push it:

https://github.com/kubernetes/ingress-nginx/blob/main/Makefile#L235

The thing to be clear here is:

Anyway, we can get that PR on test-infra merged, and test the things from this branch later. it is a staging repo anyway :D

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use the image to re-tag it see gcr.io/kubebuilder/kube-rbac-proxy the above one. So, I don't know how we would use it anymore. Maybe I am missing something.

See that we download quay.io/brancz/kube-rbac-proxy from https://github.com/brancz/kube-rbac-proxy and then rebuild it with a new tag so that we can store that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The images field is not required but can be useful to explicitly declare the name of the image(s) you want to build.