Skip to content
Merged
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
63 changes: 45 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,57 +18,84 @@ KUBEVIRT_PROVIDER?=k8s-1.23
HPP_IMAGE?=hostpath-provisioner
HPP_CSI_IMAGE?=hostpath-csi-driver
TAG?=latest
DOCKER_REPO?=kubevirt
DOCKER_REPO?=quay.io/kubevirt
ARTIFACTS_PATH?=_out
GOLANG_VER?=1.18.2
GOOS?=linux
GOARCH?=amd64
BUILDAH_PLATFORM_FLAG?=--platform $(GOOS)/$(GOARCH)
OCI_BIN ?= $(shell if podman ps >/dev/null 2>&1; then echo podman; elif docker ps >/dev/null 2>&1; then echo docker; fi)

export GOLANG_VER
export KUBEVIRT_PROVIDER
export DOCKER_REPO
export GOOS
export GOARCH
export OCI_BIN

all: controller hostpath-provisioner

hostpath-provisioner:
GOLANG_VER=${GOLANG_VER} ./hack/build-provisioner.sh
./hack/build-provisioner.sh

hostpath-csi-driver:
GOLANG_VER=${GOLANG_VER} ./hack/build-csi.sh
./hack/build-csi.sh

image: image-controller image-csi

push: push-controller push-csi
push: clean manifest manifest-push

push-controller: hostpath-provisioner image
docker push $(DOCKER_REPO)/$(HPP_IMAGE):$(TAG)
manifest: manifest-controller manifest-csi

manifest-push: push-csi push-controller

image-controller: hostpath-provisioner
docker build -t $(DOCKER_REPO)/$(HPP_IMAGE):$(TAG) -f Dockerfile.controller .
buildah build $(BUILDAH_PLATFORM_FLAG) -t $(DOCKER_REPO)/$(HPP_IMAGE):$(GOARCH) -f Dockerfile.controller .

image-csi: hostpath-csi-driver
docker build -t $(DOCKER_REPO)/$(HPP_CSI_IMAGE):$(TAG) -f Dockerfile.csi .
buildah build $(BUILDAH_PLATFORM_FLAG) -t $(DOCKER_REPO)/$(HPP_CSI_IMAGE):$(GOARCH) -f Dockerfile.csi .

manifest-controller: image-controller
-buildah manifest create $(DOCKER_REPO)/$(HPP_IMAGE):local
buildah manifest add --arch $(GOARCH) $(DOCKER_REPO)/$(HPP_IMAGE):local containers-storage:$(DOCKER_REPO)/$(HPP_IMAGE):$(GOARCH)

manifest-csi: image-csi
-buildah manifest create $(DOCKER_REPO)/$(HPP_CSI_IMAGE):local
buildah manifest add --arch $(GOARCH) $(DOCKER_REPO)/$(HPP_CSI_IMAGE):local containers-storage:$(DOCKER_REPO)/$(HPP_CSI_IMAGE):$(GOARCH)

push-csi: hostpath-csi-driver image-csi
docker push $(DOCKER_REPO)/$(HPP_CSI_IMAGE):$(TAG)
push-csi:
buildah manifest push $(BUILDAH_PUSH_FLAGS) --all $(DOCKER_REPO)/$(HPP_CSI_IMAGE):local docker://$(DOCKER_REPO)/$(HPP_CSI_IMAGE):$(TAG)

clean:
push-controller:
buildah manifest push $(BUILDAH_PUSH_FLAGS) --all $(DOCKER_REPO)/$(HPP_IMAGE):local docker://$(DOCKER_REPO)/$(HPP_IMAGE):$(TAG)

clean: manifest-clean
rm -rf _out

manifest-clean:
-buildah manifest rm $(DOCKER_REPO)/$(HPP_IMAGE):local
-buildah manifest rm $(DOCKER_REPO)/$(HPP_CSI_IMAGE):local

build: clean hostpath-provisioner hostpath-csi-driver

cluster-up:
KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER} ./cluster-up/up.sh
./cluster-up/up.sh

cluster-down:
KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER} ./cluster-up/down.sh
./cluster-up/down.sh

cluster-sync: cluster-clean
KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER} ./cluster-sync/sync.sh
./cluster-sync/sync.sh

cluster-clean:
KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER} ./cluster-sync/clean.sh
./cluster-sync/clean.sh

test:
GOLANG_VER=${GOLANG_VER} ./hack/run-unit-test.sh
./hack/run-unit-test.sh
hack/language.sh

test-functional:
KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER} gotestsum --format short-verbose --junitfile ${ARTIFACTS_PATH}/junit.functest.xml -- ./tests/... -kubeconfig="../_ci-configs/$(KUBEVIRT_PROVIDER)/.kubeconfig"
gotestsum --format short-verbose --junitfile ${ARTIFACTS_PATH}/junit.functest.xml -- ./tests/... -kubeconfig="../_ci-configs/$(KUBEVIRT_PROVIDER)/.kubeconfig"

test-sanity:
GOLANG_VER=${GOLANG_VER} DOCKER_REPO=${DOCKER_REPO} hack/sanity.sh
hack/sanity.sh
6 changes: 5 additions & 1 deletion cluster-sync/sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ for i in $(seq 1 ${KUBEVIRT_NUM_NODES}); do
done

registry=${IMAGE_REGISTRY:-localhost:$(_port registry)}
DOCKER_REPO=${registry} make push
if [[ ${registry} == localhost* ]]; then
echo "not verifying tls, registry contains localhost"
export BUILDAH_PUSH_FLAGS="--tls-verify=false"
fi
DOCKER_REPO=${registry} make manifest manifest-push

if [ ! -z $UPGRADE_FROM ]; then
_kubectl apply -f https://github.com/kubevirt/hostpath-provisioner-operator/releases/download/$UPGRADE_FROM/namespace.yaml
Expand Down
6 changes: 5 additions & 1 deletion hack/k8s-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ fi
echo "install hpp"
registry=${IMAGE_REGISTRY:-localhost:$(_port registry)}
echo "registry: ${registry}"
DOCKER_REPO=${registry} make push
if [[ ${registry} == localhost* ]]; then
echo "not verifying tls, registry contains localhost"
export BUILDAH_PUSH_FLAGS="--tls-verify=false"
fi
DOCKER_REPO=${registry} make manifest manifest-push

#install hpp
_kubectl apply -f https://raw.githubusercontent.com/kubevirt/hostpath-provisioner-operator/main/deploy/namespace.yaml
Expand Down
6 changes: 3 additions & 3 deletions hack/sanity.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ source "${script_dir}"/common.sh
setGoInProw $GOLANG_VER

echo "docker repo: [$DOCKER_REPO]"
go test -o _out/sanity.test -c -v ./sanity/...
docker build -t ${DOCKER_REPO}/sanity:test -f ./sanity/Dockerfile .
CGO_ENABLED=0 go test -o _out/sanity.test -c -v ./sanity/...
$OCI_BIN build -t ${DOCKER_REPO}/sanity:test -f ./sanity/Dockerfile .
# Need privileged so we can bind mount inside container, and hostpath capacity cannot change, so skipping that test
docker run --privileged ${DOCKER_REPO}/sanity:test -ginkgo.noColor -ginkgo.skip="should fail when requesting to create a volume with already existing name and different capacity"
$OCI_BIN run --privileged ${DOCKER_REPO}/sanity:test -ginkgo.noColor -ginkgo.skip="should fail when requesting to create a volume with already existing name and different capacity"