Skip to content

Commit

Permalink
[Release 0.64] OCI: Support podman (#1145)
Browse files Browse the repository at this point in the history
* cluster: Bump kubevirtci

In order to use podman, use the latest kubevirtci

Signed-off-by: Or Shoval <[email protected]>

* multiarch build: Use buildah

When using podman, use buildah for multi arch build

Signed-off-by: Or Shoval <[email protected]>

* podman: Adapt automation scripts to support podman

Signed-off-by: Or Shoval <[email protected]>

Signed-off-by: Or Shoval <[email protected]>
  • Loading branch information
oshoval authored Jan 26, 2023
1 parent ecb47b5 commit be44204
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 20 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export HANDLER_NAMESPACE ?= nmstate
export OPERATOR_NAMESPACE ?= $(HANDLER_NAMESPACE)
HANDLER_PULL_POLICY ?= Always
OPERATOR_PULL_POLICY ?= Always
export IMAGE_BUILDER ?= docker
export IMAGE_BUILDER ?= $(shell if podman ps >/dev/null 2>&1; then echo podman; elif docker ps >/dev/null 2>&1; then echo docker; fi)

WHAT ?= ./pkg/... ./controllers/...

Expand Down Expand Up @@ -145,13 +145,13 @@ handler: SKIP_PUSH=true
handler: push-handler

push-handler: handler-manager
SKIP_PUSH=$(SKIP_PUSH) SKIP_IMAGE_BUILD=$(SKIP_IMAGE_BUILD) IMAGE=${HANDLER_IMAGE} hack/build-push-container.${IMAGE_BUILDER}.sh . -f build/$(HANDLER_DOCKERFILE)
SKIP_PUSH=$(SKIP_PUSH) SKIP_IMAGE_BUILD=$(SKIP_IMAGE_BUILD) IMAGE=${HANDLER_IMAGE} hack/build-push-container.${IMAGE_BUILDER}.sh -f build/$(HANDLER_DOCKERFILE)

operator: SKIP_PUSH=true
operator: push-operator

push-operator: operator-manager
SKIP_PUSH=$(SKIP_PUSH) SKIP_IMAGE_BUILD=$(SKIP_IMAGE_BUILD) IMAGE=${OPERATOR_IMAGE} hack/build-push-container.${IMAGE_BUILDER}.sh . -f build/Dockerfile.operator
SKIP_PUSH=$(SKIP_PUSH) SKIP_IMAGE_BUILD=$(SKIP_IMAGE_BUILD) IMAGE=${OPERATOR_IMAGE} hack/build-push-container.${IMAGE_BUILDER}.sh -f build/Dockerfile.operator

push: push-handler push-operator

Expand Down
4 changes: 3 additions & 1 deletion automation/check-patch.docs.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#!/bin/bash -xe

IMAGE_BUILDER=${IMAGE_BUILDER:-$(./hack/detect_cri.sh)}

# Change url to point to google storage
url="https://storage.googleapis.com"
baseurl="kubevirt-prow/pr-logs/pull/nmstate_kubernetes-nmstate/${PULL_NUMBER}/pull-kubernetes-nmstate-docs/${BUILD_ID}/artifacts/gh-pages/"
sed -i "s#^url:.*#url: \"$url\"#" docs/_config.yaml
sed -i "s#^baseurl:.*#baseurl: \"$baseurl\"#" docs/_config.yaml


docker run -v $(pwd)/docs:/docs/ ruby make -C docs install check
${IMAGE_BUILDER} run -v $(pwd)/docs:/docs/ ruby make -C docs install check

# Copy the docs to the artifacts
mkdir -p $ARTIFACTS/gh-pages
Expand Down
2 changes: 1 addition & 1 deletion automation/check-patch.e2e-k8s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# This script should be able to execute functional tests against Kubernetes
# cluster on any environment with basic dependencies listed in
# check-patch.packages installed and docker running.
# check-patch.packages installed and podman / docker running.
#
# yum -y install automation/check-patch.packages
# automation/check-patch.e2e-k8s.sh
Expand Down
2 changes: 1 addition & 1 deletion automation/check-patch.e2e-operator-k8s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# This script should be able to execute functional tests against Kubernetes
# cluster on any environment with basic dependencies listed in
# check-patch.packages installed and docker running.
# check-patch.packages installed and podman / docker running.
#
# yum -y install automation/check-patch.packages
# automation/check-patch.e2e-k8s.sh
Expand Down
2 changes: 1 addition & 1 deletion automation/check-patch.unit-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# This script should be able to execute functional tests against Kubernetes
# cluster on any environment with basic dependencies listed in
# check-patch.packages installed and docker running.
# check-patch.packages installed and podman / docker running.
#
# yum -y install automation/check-patch.packages
# automation/check-patch.e2e-k8s.sh
Expand Down
4 changes: 3 additions & 1 deletion automation/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# IMAGE_REPO
# To run it just do proper docker login and automation/publish.sh

IMAGE_BUILDER=${IMAGE_BUILDER:-$(./hack/detect_cri.sh)}

image_registry=${IMAGE_REGISTRY:-quay.io}
image_repo=${IMAGE_REPO:-nmstate}

Expand All @@ -23,7 +25,7 @@ push_knmstate_containers() {

publish_docs() {
# Update gh-pages branch with the generated documentation
docker run -v $(pwd)/docs:/docs/ ruby make -C /docs install build
${IMAGE_BUILDER} run -v $(pwd)/docs:/docs/ ruby make -C /docs install build
rm -rf /tmp/gh-pages
git clone --single-branch http://github.com/nmstate/kubernetes-nmstate -b gh-pages /tmp/gh-pages
rsync -rt --links --cvs-exclude docs/build/kubernetes-nmstate/* /tmp/gh-pages
Expand Down
2 changes: 1 addition & 1 deletion cluster/kubevirtci.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER:-'k8s-1.23'}
export KUBEVIRTCI_TAG='2203222209-7c38b02'
export KUBEVIRTCI_TAG=2205030954-99bd4d1

KUBEVIRTCI_REPO='https://github.com/kubevirt/kubevirtci.git'
KUBEVIRTCI_PATH="${PWD}/_kubevirtci"
Expand Down
2 changes: 1 addition & 1 deletion hack/build-push-container.docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ PUSH=--push
if [ "$SKIP_PUSH" == "true" ]; then
PUSH=""
fi
docker buildx build --progress plain --platform ${PLATFORM} $@ -t ${IMAGE} $PUSH
docker buildx build --progress plain --platform ${PLATFORM} . $@ -t ${IMAGE} $PUSH

19 changes: 9 additions & 10 deletions hack/build-push-container.podman.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,18 @@ fi

ARCHS=${ARCHS:-$(go env GOARCH)}

podman rmi ${IMAGE} || true
podman manifest rm ${IMAGE} || true
podman manifest create ${IMAGE}
buildah rmi ${IMAGE} 2>/dev/null || true
buildah manifest rm ${IMAGE} 2>/dev/null || true
buildah manifest create ${IMAGE}
IMAGES=${IMAGE}
for arch in $ARCHS; do
podman build --arch $arch --build-arg TARGETARCH=$arch -t $IMAGE.$arch $@
podman manifest add --tls-verify=$TLS_VERIFY ${IMAGE} docker://${IMAGE}.$arch

if [ ! "$SKIP_PUSH" == "true" ]; then
podman push --tls-verify=$TLS_VERIFY ${IMAGE}.$arch
fi
buildah bud \
--manifest ${IMAGE} \
--arch ${arch} --build-arg TARGETARCH=${arch} $@ --tag ${IMAGE}.${arch}
done

if [ ! "$SKIP_PUSH" == "true" ]; then
podman manifest push --tls-verify=$TLS_VERIFY ${IMAGE} docker://${IMAGE}
buildah manifest push --all \
${IMAGE} \
docker://${IMAGE} --tls-verify=${TLS_VERIFY}
fi
15 changes: 15 additions & 0 deletions hack/detect_cri.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

set -e

determine_cri_bin() {
if podman ps >/dev/null 2>&1; then
echo podman
elif docker ps >/dev/null 2>&1; then
echo docker
else
echo ""
fi
}

determine_cri_bin

0 comments on commit be44204

Please sign in to comment.