Skip to content

Commit

Permalink
oci: Support podman (#229)
Browse files Browse the repository at this point in the history
* cluster: Bump kubevirtci

Bump kubevirtci to have
latest podman support fixes.

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

* makefile: Support podman OCI

Use export OCI_BIN=podman in order to use podman OCI.

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

* podman: Update dockerized scripts to support podman

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

* OCI: Support auto detect

Signed-off-by: Or Shoval <[email protected]>
  • Loading branch information
oshoval authored May 25, 2022
1 parent a1f771a commit 9c96f06
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 17 deletions.
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ export PATH := $(GOBIN):$(PATH):$(BIN_DIR)
GOPATH = $(CURDIR)/.gopath
ORG_PATH = github.com/k8snetworkplumbingwg
PACKAGE = ovs-cni
OCI_BIN ?= $(shell if podman ps >/dev/null 2>&1; then echo podman; elif docker ps >/dev/null 2>&1; then echo docker; fi)
REPO_PATH = $(ORG_PATH)/$(PACKAGE)
BASE = $(GOPATH)/src/$(REPO_PATH)
PKGS = $(or $(PKG),$(shell cd $(BASE) && env GOPATH=$(GOPATH) $(GO) list ./... | grep -v "$(PACKAGE)/vendor/" | grep -v "$(PACKAGE)/tests/cluster" | grep -v "$(PACKAGE)/tests/node"))
V = 0
Q = $(if $(filter 1,$V),,@)
TLS_SETTING := $(if $(filter $(OCI_BIN),podman),--tls-verify=false,)

all: lint build

Expand Down Expand Up @@ -78,14 +80,14 @@ functest: $(GO)
docker-build: $(patsubst %, docker-build-%, $(COMPONENTS))

docker-build-%: build-%
docker build -t ${REGISTRY}/ovs-cni-$*:${IMAGE_TAG} ./cmd/$(subst -,/,$*)
$(OCI_BIN) build -t ${REGISTRY}/ovs-cni-$*:${IMAGE_TAG} ./cmd/$(subst -,/,$*)

docker-push: $(patsubst %, docker-push-%, $(COMPONENTS))

docker-push-%:
docker push ${REGISTRY}/ovs-cni-$*:${IMAGE_TAG}
docker tag ${REGISTRY}/ovs-cni-$*:${IMAGE_TAG} ${REGISTRY}/ovs-cni-$*:${IMAGE_GIT_TAG}
docker push ${REGISTRY}/ovs-cni-$*:${IMAGE_GIT_TAG}
$(OCI_BIN) push ${TLS_SETTING} ${REGISTRY}/ovs-cni-$*:${IMAGE_TAG}
$(OCI_BIN) tag ${REGISTRY}/ovs-cni-$*:${IMAGE_TAG} ${REGISTRY}/ovs-cni-$*:${IMAGE_GIT_TAG}
$(OCI_BIN) push ${TLS_SETTING} ${REGISTRY}/ovs-cni-$*:${IMAGE_GIT_TAG}

dep: $(GO)
$(GO) mod tidy
Expand Down
2 changes: 1 addition & 1 deletion automation/check-patch.e2e.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.sh
Expand Down
2 changes: 1 addition & 1 deletion cluster/cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

export KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER:-'k8s-1.23'}
export KUBEVIRTCI_TAG='2202081102-e8daf721'
export KUBEVIRTCI_TAG=2205030954-99bd4d1

KUBEVIRTCI_REPO='https://github.com/kubevirt/kubevirtci.git'
# The CLUSTER_PATH var is used in cluster folder and points to the _kubevirtci where the cluster is deployed from.
Expand Down
10 changes: 10 additions & 0 deletions hack/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,13 @@ function kubevirt_version() {
fi
}
KUBEVIRT_VERSION="$(kubevirt_version)"

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
}
19 changes: 10 additions & 9 deletions hack/dockerized
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -e
source $(dirname "$0")/common.sh

DOCKER_DIR=${KUBEVIRT_DIR}/hack/docker-builder
OCI_BIN=${OCI_BIN:-$(determine_cri_bin)}

SYNC_OUT=${SYNC_OUT:-true}

Expand All @@ -20,26 +21,26 @@ if [ -n "$JOB_NAME" -o -n "$TRAVIS_BUILD_ID" ]; then
fi

# Build the build container
(cd ${DOCKER_DIR} && docker build . ${BUILD_QUIET} -t ${BUILDER})
(cd ${DOCKER_DIR} && ${OCI_BIN} build . ${BUILD_QUIET} -t ${BUILDER})

# Create the persistent docker volume
if [ -z "$(docker volume list | grep ${BUILDER})" ]; then
docker volume create --name ${BUILDER}
if [ -z "$($OCI_BIN volume list | grep ${BUILDER})" ]; then
${OCI_BIN} volume create ${BUILDER}
fi

# Make sure that the output directory exists
docker run -v "${BUILDER}:/root:rw,z" --security-opt label:disable --rm ${BUILDER} mkdir -p /root/go/src/github.com/k8snetworkplumbingwg/ovs-cni/_out
${OCI_BIN} run -v "${BUILDER}:/root:rw,z" --security-opt label=disable --rm ${BUILDER} mkdir -p /root/go/src/github.com/k8snetworkplumbingwg/ovs-cni/_out

# Start an rsyncd instance and make sure it gets stopped after the script exits
RSYNC_CID=$(docker run -d -v "${BUILDER}:/root:rw,z" --security-opt label:disable --expose 873 -P ${BUILDER} /usr/bin/rsync --no-detach --daemon --verbose)
RSYNC_CID=$($OCI_BIN run -d -v "${BUILDER}:/root:rw,z" --security-opt label=disable --expose 873 -P ${BUILDER} /usr/bin/rsync --no-detach --daemon --verbose)

function finish() {
docker stop ${RSYNC_CID} >/dev/null 2>&1 &
docker rm -f ${RSYNC_CID} >/dev/null 2>&1 &
${OCI_BIN} stop ${RSYNC_CID} >/dev/null 2>&1 &
${OCI_BIN} rm -f ${RSYNC_CID} >/dev/null 2>&1 &
}
trap finish EXIT

RSYNCD_PORT=$(docker port $RSYNC_CID 873 | cut -d':' -f2)
RSYNCD_PORT=$($OCI_BIN port $RSYNC_CID 873 | cut -d':' -f2)

rsynch_fail_count=0

Expand Down Expand Up @@ -70,7 +71,7 @@ _rsync --delete --exclude 'cluster/**/.kubectl' --exclude 'cluster/**/.oc' --exc

# Run the command
test -t 1 && USE_TTY="-it"
docker run --rm -v "${BUILDER}:/root:rw,z" --security-opt label:disable ${USE_TTY} -w "/root/go/src/github.com/k8snetworkplumbingwg/ovs-cni" ${BUILDER} "$@"
${OCI_BIN} run --rm -v "${BUILDER}:/root:rw,z" --security-opt label=disable ${USE_TTY} -w "/root/go/src/github.com/k8snetworkplumbingwg/ovs-cni" ${BUILDER} "$@"

# Copy the whole kubevirt data out to get generated sources and formatting changes
_rsync --exclude 'cluster/**/.kubectl' --exclude 'cluster/**/.oc' --exclude 'cluster/**/.kubeconfig' --exclude "_out" --exclude "vendor" --exclude ".git" "rsync://[email protected]:${RSYNCD_PORT}/build" ${KUBEVIRT_DIR}/
Expand Down
5 changes: 3 additions & 2 deletions hack/test-dockerized.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ set -e
source $(dirname "$0")/common.sh

DOCKER_DIR=${KUBEVIRT_DIR}/hack/docker-builder
OCI_BIN=${OCI_BIN:-$(determine_cri_bin)}

SYNC_OUT=${SYNC_OUT:-true}

Expand All @@ -37,6 +38,6 @@ if [ -n "$JOB_NAME" -o -n "$TRAVIS_BUILD_ID" ]; then
fi

# Build the build container
(cd ${DOCKER_DIR} && docker build . ${BUILD_QUIET} -t ${BUILDER})
(cd ${DOCKER_DIR} && ${OCI_BIN} build . ${BUILD_QUIET} -t ${BUILDER})

docker run --rm --privileged --network host --cap-add ALL -v /lib/modules:/lib/modules -v `pwd`:/root/go/src/github.com/k8snetworkplumbingwg/ovs-cni -w "/root/go/src/github.com/k8snetworkplumbingwg/ovs-cni" ${BUILDER} make test
${OCI_BIN} run --rm --privileged --network host -v /lib/modules:/lib/modules -v `pwd`:/root/go/src/github.com/k8snetworkplumbingwg/ovs-cni -w "/root/go/src/github.com/k8snetworkplumbingwg/ovs-cni" ${BUILDER} make test

0 comments on commit 9c96f06

Please sign in to comment.