Skip to content
Closed
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
16 changes: 14 additions & 2 deletions hack/build-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function print_info {

# Warn when unprivileged
if [ `id --user` -ne 0 ]; then
print_error "Note: Building unprivileged may fail due to permissions"
print_info "Building unprivileged may fail due to permissions"
fi

# Record all images files
Expand All @@ -35,6 +35,13 @@ if [ -z ${WHAT+a} ]; then
exit 1
fi

# Our change detection uses the git sha1
# if ! git diff --quiet --exit-code; then
# print_error "Outstanding uncommitted changes found (git diff)"
# exit 1
# fi

VERSION=$(git describe --tags --abbrev=12 --always)

# If all is the WHAT target then set TOBUILD to all the images found
if [ ${WHAT} == "all" ]; then
Expand Down Expand Up @@ -64,5 +71,10 @@ for IMAGE_TO_BUILD in $TOBUILD; do
NAME="${IMAGE_TO_BUILD#Dockerfile.}"
NAME="${NAME//.upstream}"
set -x
$podman build -t "localhost/${NAME}:latest" -f "${IMAGE_TO_BUILD}" --no-cache
imgname="localhost/${NAME}:${VERSION}"
if $podman inspect ${imgname} &>/dev/null; then
echo "Already built ${imgname}"
else
$podman build -t "${imgname}" -f "${IMAGE_TO_BUILD}" --no-cache
fi
done
67 changes: 67 additions & 0 deletions hack/cluster-cvo-push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env bash

# Build all images and push to to the cluster registry, then
# build a release image referencing them and start an upgrade to that.
# You must have first run `cluster-push-prep.sh` once.
# Assumptions: You have set KUBECONFIG to point to your local cluster,
# and you have exposed the registry via e.g.
# https://github.com/openshift/installer/issues/411#issuecomment-445165262

set -xeuo pipefail

do_build=1
if [ "${1:-}" = "-n" ]; then
do_build=0
fi

NS=openshift-machine-config-operator
COMPONENTS="operator controller server daemon"
podman=${podman:-podman}

internal_registry="image-registry.openshift-image-registry.svc:5000"
internal_registry_ns="${internal_registry}/${NS}"
registry=$(oc get -n openshift-image-registry -o json route/image-registry | jq -r ".spec.host")
curl -k --head https://"${registry}" >/dev/null
registry_ns="${registry}/${NS}"

running_version=$(oc get clusterversion -o=jsonpath='{.items[0].status.desired.image}')

# Keep in sync with build-image.sh
VERSION=$(git describe --tags --abbrev=12 --always)
if [ "${do_build}" = 1 ]; then
make images
fi
declare -A imgbuilds
for c in $COMPONENTS; do
imgname="machine-config-${c}:${VERSION}"
remote_name=${registry_ns}/${imgname}
$podman push --tls-verify=false localhost/${imgname} ${remote_name}
digest=$(skopeo inspect --tls-verify=false docker://${remote_name} | jq -r .Digest)
imgbuilds[$c]="${digest}"
done

updateimg=${internal_registry_ns}/mcodev:latest
cmd="oc adm release new --from-release ${running_version} --to-image=${updateimg} \
machine-config-operator=${internal_registry_ns}/machine-config-operator:${VERSION} \
machine-config-controller=${internal_registry_ns}/machine-config-controller:${VERSION} \
machine-config-server=${internal_registry_ns}/machine-config-server:${VERSION} \
machine-config-daemon=${internal_registry_ns}/machine-config-daemon:${VERSION} && \
oc adm upgrade --to-image ${updateimg} --force"
cli_image=$(oc -n openshift-cluster-version rsh deploy/cluster-version-operator cluster-version-operator image cli)
oc -n openshift-cluster-version create -f - <<EOF
apiVersion: batch/v1
kind: Job
metadata:
name: mco-build-update-image
spec:
template:
spec:
containers:
- name: mco-build-update-image
image: ${cli_image}
command: ["/bin/sh", "-c", "${cmd}"]
restartPolicy: Never
EOF



1 change: 0 additions & 1 deletion hack/cluster-push-prep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ set -xeuo pipefail

podman=${podman:-podman}

oc -n openshift-cluster-version scale --replicas=0 deploy/cluster-version-operator
if ! oc get -n openshift-image-registry route/image-registry &>/dev/null; then
oc expose -n openshift-image-registry svc/image-registry
fi
Expand Down
2 changes: 2 additions & 0 deletions hack/cluster-push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ if [ "${1:-}" = "-n" ]; then
do_build=0
fi

oc -n openshift-cluster-version scale --replicas=0 deploy/cluster-version-operator

registry=$(oc get -n openshift-image-registry -o json route/image-registry | jq -r ".spec.host")
curl -k --head https://"${registry}" >/dev/null

Expand Down