-
Notifications
You must be signed in to change notification settings - Fork 211
USHIFT-5531: Auto-rebase procedure with flannel and kube-proxy image update #4726
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
Open
praveenkumar
wants to merge
2
commits into
openshift:main
Choose a base branch
from
praveenkumar:issue_5531
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -816,6 +816,7 @@ EOF | |
|
||
update_olm_images | ||
update_multus_images | ||
update_kubeproxy_images | ||
|
||
popd >/dev/null | ||
} | ||
|
@@ -1118,6 +1119,44 @@ EOF | |
done # for goarch | ||
} | ||
|
||
update_kubeproxy_images() { | ||
praveenkumar marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you know what's the difference between |
||
title "Rebasing kube-proxy images" | ||
|
||
for goarch in amd64 arm64; do | ||
arch=${GOARCH_TO_UNAME_MAP["${goarch}"]:-noarch} | ||
|
||
local release_file="${STAGING_DIR}/release_${goarch}.json" | ||
local kustomization_arch_file="${REPOROOT}/assets/optional/kube-proxy/kustomization.${arch}.yaml" | ||
local kubeproxy_release_json="${REPOROOT}/assets/optional/kube-proxy/release-kube-proxy-${arch}.json" | ||
|
||
local base_release | ||
base_release=$(jq -r ".metadata.version" "${release_file}") | ||
jq -n "{\"release\": {\"base\": \"$base_release\"}, \"images\": {}}" > "${kubeproxy_release_json}" | ||
|
||
# Create extra kustomization for each arch in separate file. | ||
# Right file (depending on arch) should be appended during rpmbuild to kustomization.yaml. | ||
cat <<EOF > "${kustomization_arch_file}" | ||
|
||
images: | ||
EOF | ||
|
||
for container in kube-proxy; do | ||
local new_image | ||
new_image=$(jq -r ".references.spec.tags[] | select(.name == \"${container}\") | .from.name" "${release_file}") | ||
local new_image_name="${new_image%@*}" | ||
local new_image_digest="${new_image#*@}" | ||
|
||
cat <<EOF >> "${kustomization_arch_file}" | ||
- name: ${container} | ||
newName: ${new_image_name} | ||
digest: ${new_image_digest} | ||
EOF | ||
|
||
yq -i -o json ".images += {\"${container}\": \"${new_image}\"}" "${kubeproxy_release_json}" | ||
done # for container | ||
done # for goarch | ||
} | ||
|
||
check_for_manifests_changes() { | ||
# Changes to ignore: | ||
# - `release-$ARCH.json` files | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit | ||
set -o errtrace | ||
set -o nounset | ||
set -o pipefail | ||
|
||
shopt -s expand_aliases | ||
shopt -s extglob | ||
|
||
export PS4='+ $(date "+%T.%N") ${BASH_SOURCE#$HOME/}:$LINENO \011' | ||
|
||
REPOROOT="$(readlink -f "$(dirname "${BASH_SOURCE[0]}")/../..")" | ||
STAGING_DIR="${REPOROOT}/_output/staging" | ||
FLANNEL_VERSION=v0.25.6 | ||
FLANNEL_CNI_PLUGIN_VERSION=v1.5.1-flannel2 | ||
REGISTRY="docker.io/flannel" | ||
declare -A GOARCH_TO_UNAME_MAP=( ["amd64"]="x86_64" ["arm64"]="aarch64" ) | ||
declare -A FLANNEL_MAP=( ["flannel"]="flannel_release.json" ["flannel-plugin"]="flannel-plugin_release.json") | ||
|
||
title() { | ||
echo -e "\E[34m$1\E[00m"; | ||
} | ||
|
||
get_manifest_from_docker() { | ||
title "Downloading manifest for flannel" | ||
mkdir -p "${STAGING_DIR}" | ||
pushd "${STAGING_DIR}" >/dev/null | ||
oc image info ${REGISTRY}/flannel:${FLANNEL_VERSION} --show-multiarch -ojson > "${FLANNEL_MAP["flannel"]}" | ||
oc image info ${REGISTRY}/flannel-cni-plugin:${FLANNEL_CNI_PLUGIN_VERSION} --show-multiarch -ojson > "${FLANNEL_MAP["flannel-plugin"]}" | ||
popd >/dev/null | ||
} | ||
|
||
|
||
update_flannel_images() { | ||
title "Rebasing flannel images" | ||
|
||
for goarch in amd64 arm64; do | ||
arch=${GOARCH_TO_UNAME_MAP["${goarch}"]:-noarch} | ||
|
||
local kustomization_arch_file="${REPOROOT}/assets/optional/flannel/kustomization.${arch}.yaml" | ||
local flannel_release_json="${REPOROOT}/assets/optional/flannel/release-flannel-${arch}.json" | ||
|
||
jq -n "{\"release\": {\"base\": \"${REGISTRY}\"}, \"images\": {}}" > "${flannel_release_json}" | ||
|
||
# Create extra kustomization for each arch in separate file. | ||
# Right file (depending on arch) should be appended during rpmbuild to kustomization.yaml. | ||
cat <<EOF > "${kustomization_arch_file}" | ||
|
||
images: | ||
EOF | ||
|
||
for container in flannel flannel-plugin; do | ||
new_image_name=$(jq -r ".[] | select(.config.architecture == \"${goarch}\") | .name" "${STAGING_DIR}/${FLANNEL_MAP[${container}]}") | ||
new_image_digest=$(jq -r ".[] | select(.config.architecture == \"${goarch}\") | .digest" "${STAGING_DIR}/${FLANNEL_MAP[${container}]}") | ||
local new_image="${new_image_name%%:*}@${new_image_digest}" | ||
|
||
cat <<EOF >> "${kustomization_arch_file}" | ||
- name: ${container} | ||
newName: ${new_image_name%%:*} | ||
digest: ${new_image_digest} | ||
EOF | ||
|
||
yq -i -o json ".images += {\"${container}\": \"${new_image}\"}" "${flannel_release_json}" | ||
done # for container | ||
done # for goarch | ||
} | ||
|
||
get_manifest_from_docker | ||
update_flannel_images |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this function be executed?
I recall that newest flannel requires a kernel module, should we even proceed with this PR?