Created
October 27, 2022 15:36
-
-
Save petr-muller/847fe535678c0e1ec4566d38434cca61 to your computer and use it in GitHub Desktop.
Hotswap CVO in a running cluster
This file contains hidden or 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
#!/bin/bash | |
set -eu | |
root="$(dirname "${BASH_SOURCE[0]}")/.." | |
customCvoPullspec=quay.io/petr-muller/cluster-version-operator:"$(git branch --show-current)" | |
payload="$(oc get -n openshift-cluster-version clusterversion version -o jsonpath='{.status.desired.image}')" | |
podman pull "$payload" | |
dockerfile="$(mktemp)" | |
cp "$root/Dockerfile" "$dockerfile" | |
sed -i 's|registry.ci.openshift.org/openshift/origin-v4.0:base|'"$payload"'|' "$dockerfile" | |
sed -i '\|COPY install /manifests|d' "$dockerfile" | |
sed -i '\|COPY vendor.*|d' "$dockerfile" | |
sed -i '\|COPY bootstrap.*|d' "$dockerfile" | |
podman build "$root" -f "$dockerfile" -t "$customCvoPullspec" | |
podman push "$customCvoPullspec" | |
digestPullspec="$(skopeo inspect --format='{{.Name}}@{{.Digest}}' docker://"$customCvoPullspec")" | |
imagePatch='{"op":"replace","path":"/spec/template/spec/containers/0/image","value":"'"$digestPullspec"'"}' | |
releaseImageArgPatch='{"op":"replace","path":"/spec/template/spec/containers/0/args/1","value":"--release-image='"$digestPullspec"'"}' | |
oc patch -n openshift-cluster-version deployment cluster-version-operator --type json --patch="[$imagePatch,$releaseImageArgPatch]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment