Skip to content

Commit

Permalink
Added possibilty to add a prefix to virt image names
Browse files Browse the repository at this point in the history
- updated operator for dealing with the prefix (taken from own image name env var) for deployments
- added prefix flags for CSV and manifest generators
- added test for a temporary kubevirt deployment with a prefix

Signed-off-by: Marc Sluiter <[email protected]>
  • Loading branch information
slintes committed Oct 3, 2019
1 parent 67b0662 commit 97e2f1c
Show file tree
Hide file tree
Showing 24 changed files with 272 additions and 104 deletions.
38 changes: 19 additions & 19 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -176,27 +176,27 @@ container_bundle(
name = "build-images",
images = {
# cmd images
"$(container_prefix)/example-hook-sidecar:$(container_tag)": "//cmd/example-hook-sidecar:example-hook-sidecar-image",
"$(container_prefix)/example-cloudinit-hook-sidecar:$(container_tag)": "//cmd/example-cloudinit-hook-sidecar:example-cloudinit-hook-sidecar-image",
"$(container_prefix)/subresource-access-test:$(container_tag)": "//cmd/subresource-access-test:subresource-access-test-image",
"$(container_prefix)/virt-controller:$(container_tag)": "//cmd/virt-controller:virt-controller-image",
"$(container_prefix)/virt-launcher:$(container_tag)": "//cmd/virt-launcher:virt-launcher-image",
"$(container_prefix)/virt-handler:$(container_tag)": "//cmd/virt-handler:virt-handler-image",
"$(container_prefix)/virt-api:$(container_tag)": "//cmd/virt-api:virt-api-image",
"$(container_prefix)/virt-operator:$(container_tag)": "//cmd/virt-operator:virt-operator-image",
"$(container_prefix)/$(image_prefix)example-hook-sidecar:$(container_tag)": "//cmd/example-hook-sidecar:example-hook-sidecar-image",
"$(container_prefix)/$(image_prefix)example-cloudinit-hook-sidecar:$(container_tag)": "//cmd/example-cloudinit-hook-sidecar:example-cloudinit-hook-sidecar-image",
"$(container_prefix)/$(image_prefix)subresource-access-test:$(container_tag)": "//cmd/subresource-access-test:subresource-access-test-image",
"$(container_prefix)/$(image_prefix)virt-controller:$(container_tag)": "//cmd/virt-controller:virt-controller-image",
"$(container_prefix)/$(image_prefix)virt-launcher:$(container_tag)": "//cmd/virt-launcher:virt-launcher-image",
"$(container_prefix)/$(image_prefix)virt-handler:$(container_tag)": "//cmd/virt-handler:virt-handler-image",
"$(container_prefix)/$(image_prefix)virt-api:$(container_tag)": "//cmd/virt-api:virt-api-image",
"$(container_prefix)/$(image_prefix)virt-operator:$(container_tag)": "//cmd/virt-operator:virt-operator-image",
# container-disk images
"$(container_prefix)/alpine-container-disk-demo:$(container_tag)": "//cmd/container-disk-v2alpha:alpine-container-disk-image",
"$(container_prefix)/cirros-container-disk-demo:$(container_tag)": "//cmd/container-disk-v2alpha:cirros-container-disk-image",
"$(container_prefix)/cirros-custom-container-disk-demo:$(container_tag)": "//cmd/container-disk-v2alpha:cirros-custom-container-disk-image",
"$(container_prefix)/fedora-cloud-container-disk-demo:$(container_tag)": "//cmd/container-disk-v2alpha:fedora-cloud-container-disk-image",
"$(container_prefix)/fedora30-cloud-container-disk-demo:$(container_tag)": "//cmd/container-disk-v2alpha:fedora30-cloud-container-disk-image",
"$(container_prefix)/virtio-container-disk:$(container_tag)": "//cmd/container-disk-v2alpha:virtio-container-disk-image",
"$(container_prefix)/$(image_prefix)alpine-container-disk-demo:$(container_tag)": "//cmd/container-disk-v2alpha:alpine-container-disk-image",
"$(container_prefix)/$(image_prefix)cirros-container-disk-demo:$(container_tag)": "//cmd/container-disk-v2alpha:cirros-container-disk-image",
"$(container_prefix)/$(image_prefix)cirros-custom-container-disk-demo:$(container_tag)": "//cmd/container-disk-v2alpha:cirros-custom-container-disk-image",
"$(container_prefix)/$(image_prefix)fedora-cloud-container-disk-demo:$(container_tag)": "//cmd/container-disk-v2alpha:fedora-cloud-container-disk-image",
"$(container_prefix)/$(image_prefix)fedora30-cloud-container-disk-demo:$(container_tag)": "//cmd/container-disk-v2alpha:fedora30-cloud-container-disk-image",
"$(container_prefix)/$(image_prefix)virtio-container-disk:$(container_tag)": "//cmd/container-disk-v2alpha:virtio-container-disk-image",
# testing images
"$(container_prefix)/disks-images-provider:$(container_tag)": "//images/disks-images-provider:disks-images-provider-image",
"$(container_prefix)/cdi-http-import-server:$(container_tag)": "//images/cdi-http-import-server:cdi-http-import-server-image",
"$(container_prefix)/nfs-server:$(container_tag)": "//images/nfs-server:nfs-server-image",
"$(container_prefix)/vm-killer:$(container_tag)": "//images/vm-killer:vm-killer-image",
"$(container_prefix)/winrmcli:$(container_tag)": "//images/winrmcli:winrmcli-image",
"$(container_prefix)/$(image_prefix)disks-images-provider:$(container_tag)": "//images/disks-images-provider:disks-images-provider-image",
"$(container_prefix)/$(image_prefix)cdi-http-import-server:$(container_tag)": "//images/cdi-http-import-server:cdi-http-import-server-image",
"$(container_prefix)/$(image_prefix)nfs-server:$(container_tag)": "//images/nfs-server:nfs-server-image",
"$(container_prefix)/$(image_prefix)vm-killer:$(container_tag)": "//images/vm-killer:vm-killer-image",
"$(container_prefix)/$(image_prefix)winrmcli:$(container_tag)": "//images/winrmcli:winrmcli-image",
},
)

Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ bazel-build:
hack/dockerized "hack/bazel-fmt.sh && hack/bazel-build.sh"

bazel-build-images:
hack/dockerized "DOCKER_PREFIX=${DOCKER_PREFIX} DOCKER_TAG=${DOCKER_TAG} DOCKER_TAG_ALT=${DOCKER_TAG_ALT} ./hack/bazel-build-images.sh"
hack/dockerized "DOCKER_PREFIX=${DOCKER_PREFIX} DOCKER_TAG=${DOCKER_TAG} DOCKER_TAG_ALT=${DOCKER_TAG_ALT} IMAGE_PREFIX=${IMAGE_PREFIX} IMAGE_PREFIX_ALT=${IMAGE_PREFIX_ALT} ./hack/bazel-build-images.sh"

bazel-push-images:
hack/dockerized "hack/bazel-fmt.sh && DOCKER_PREFIX=${DOCKER_PREFIX} DOCKER_TAG=${DOCKER_TAG} DOCKER_TAG_ALT=${DOCKER_TAG_ALT} PUSH_LOG_FILE=${PUSH_LOG_FILE} KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER} ./hack/bazel-push-images.sh"
hack/dockerized "hack/bazel-fmt.sh && DOCKER_PREFIX=${DOCKER_PREFIX} DOCKER_TAG=${DOCKER_TAG} DOCKER_TAG_ALT=${DOCKER_TAG_ALT} IMAGE_PREFIX=${IMAGE_PREFIX} IMAGE_PREFIX_ALT=${IMAGE_PREFIX_ALT} PUSH_LOG_FILE=${PUSH_LOG_FILE} KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER} ./hack/bazel-push-images.sh"

push: bazel-push-images

Expand Down Expand Up @@ -103,7 +103,7 @@ cluster-down:
./cluster-up/down.sh

cluster-build:
PUSH_LOG_FILE=${PUSH_LOG_FILE} ./hack/cluster-build.sh
./hack/cluster-build.sh

cluster-clean:
./hack/cluster-clean.sh
Expand Down
12 changes: 12 additions & 0 deletions hack/bazel-build-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ for tag in ${docker_tag} ${docker_tag_alt}; do
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 \
--workspace_status_command=./hack/print-workspace-status.sh \
--define container_prefix=${docker_prefix} \
--define image_prefix=${image_prefix} \
--define container_tag=${tag} \
//:build-images
done

# for the imagePrefix operator test
if [[ $image_prefix_alt ]]; then
bazel build \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 \
--workspace_status_command=./hack/print-workspace-status.sh \
--define container_prefix=${docker_prefix} \
--define image_prefix=${image_prefix_alt} \
--define container_tag=${docker_tag} \
//:build-images
fi
12 changes: 12 additions & 0 deletions hack/bazel-push-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ for tag in ${docker_tag} ${docker_tag_alt}; do
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 \
--workspace_status_command=./hack/print-workspace-status.sh \
--define container_prefix=${docker_prefix} \
--define image_prefix=${image_prefix} \
--define container_tag=${tag} \
//:push-images | tee $push_log_file
done

# for the imagePrefix operator test
if [[ $image_prefix_alt ]]; then
bazel run \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 \
--workspace_status_command=./hack/print-workspace-status.sh \
--define container_prefix=${docker_prefix} \
--define image_prefix=${image_prefix_alt} \
--define container_tag=${docker_tag} \
//:push-images
fi
1 change: 1 addition & 0 deletions hack/build-manifests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ for arg in $args; do
--cdi-namespace=${cdi_namespace} \
--csv-namespace=${csv_namespace} \
--container-prefix=${manifest_docker_prefix} \
--image-prefix=${image_prefix} \
--container-tag=${docker_tag} \
--image-pull-policy=${image_pull_policy} \
--verbosity=${verbosity} \
Expand Down
14 changes: 11 additions & 3 deletions hack/cluster-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,26 @@ echo "Building ..."

# Build everyting and publish it
${KUBEVIRT_PATH}hack/dockerized "DOCKER_PREFIX=${DOCKER_PREFIX} DOCKER_TAG=${DOCKER_TAG} KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER} ./hack/bazel-build.sh"
${KUBEVIRT_PATH}hack/dockerized "DOCKER_PREFIX=${DOCKER_PREFIX} DOCKER_TAG=${DOCKER_TAG} DOCKER_TAG_ALT=${DOCKER_TAG_ALT} KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER} PUSH_LOG_FILE=${PUSH_LOG_FILE} ./hack/bazel-push-images.sh"
${KUBEVIRT_PATH}hack/dockerized "DOCKER_PREFIX=${DOCKER_PREFIX} DOCKER_TAG=${DOCKER_TAG} KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER} IMAGE_PULL_POLICY=${IMAGE_PULL_POLICY} VERBOSITY=${VERBOSITY} PUSH_LOG_FILE=${PUSH_LOG_FILE} ./hack/build-manifests.sh"
${KUBEVIRT_PATH}hack/dockerized "DOCKER_PREFIX=${DOCKER_PREFIX} DOCKER_TAG=${DOCKER_TAG} DOCKER_TAG_ALT=${DOCKER_TAG_ALT} KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER} PUSH_LOG_FILE=${PUSH_LOG_FILE} IMAGE_PREFIX=${IMAGE_PREFIX} IMAGE_PREFIX_ALT=${IMAGE_PREFIX_ALT} ./hack/bazel-push-images.sh"
${KUBEVIRT_PATH}hack/dockerized "DOCKER_PREFIX=${DOCKER_PREFIX} DOCKER_TAG=${DOCKER_TAG} KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER} IMAGE_PULL_POLICY=${IMAGE_PULL_POLICY} VERBOSITY=${VERBOSITY} PUSH_LOG_FILE=${PUSH_LOG_FILE} IMAGE_PREFIX=${IMAGE_PREFIX} IMAGE_PREFIX_ALT=${IMAGE_PREFIX_ALT} ./hack/build-manifests.sh"

# Make sure that all nodes use the newest images
container=""
container_alias=""
for arg in ${docker_images}; do
name=$(basename $arg)
name=${image_prefix}$(basename $arg)
container="${container} ${manifest_docker_prefix}/${name}:${docker_tag} ${manifest_docker_prefix}/${name}:${docker_tag_alt}"
container_alias="${container_alias} ${manifest_docker_prefix}/${name}:${docker_tag} kubevirt/${name}:${docker_tag}"
done

if [[ $image_prefix_alt ]]; then
for arg in ${docker_images}; do
name=${image_prefix_alt}$(basename $arg)
container="${container} ${manifest_docker_prefix}/${name}:${docker_tag}"
container_alias="${container_alias} ${manifest_docker_prefix}/${name}:${docker_tag} kubevirt/${name}:${docker_tag}"
done
fi

# OKD provider has different node names and does not have docker
if [[ $KUBEVIRT_PROVIDER =~ okd.* ]]; then
nodes=("master-0" "worker-0")
Expand Down
2 changes: 2 additions & 0 deletions hack/config-default.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ binaries="cmd/virt-operator cmd/virt-controller cmd/virt-launcher cmd/virt-handl
docker_images="cmd/virt-operator cmd/virt-controller cmd/virt-launcher cmd/virt-handler cmd/virt-api images/disks-images-provider images/vm-killer images/nfs-server cmd/subresource-access-test images/winrmcli cmd/example-hook-sidecar cmd/example-cloudinit-hook-sidecar images/cdi-http-import-server"
docker_tag=${DOCKER_TAG:-latest}
docker_tag_alt=${DOCKER_TAG_ALT}
image_prefix=${IMAGE_PREFIX}
image_prefix_alt=${IMAGE_PREFIX_ALT:-kv-}
namespace=kubevirt
csv_namespace=placeholder
cdi_namespace=cdi
Expand Down
4 changes: 2 additions & 2 deletions hack/config.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
unset binaries docker_images docker_tag docker_tag_alt manifest_templates \
unset binaries docker_images docker_tag docker_tag_alt image_prefix image_prefix_alt manifest_templates \
namespace image_pull_policy verbosity \
csv_version package_name push_log_file

source ${KUBEVIRT_PATH}hack/config-default.sh
source ${KUBEVIRT_PATH}cluster-up/hack/config.sh

export binaries docker_images docker_tag docker_tag_alt manifest_templates \
export binaries docker_images docker_tag docker_tag_alt image_prefix image_prefix_alt manifest_templates \
namespace image_pull_policy verbosity \
csv_version package_name push_log_file
3 changes: 2 additions & 1 deletion hack/functests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ set -e

DOCKER_TAG=${DOCKER_TAG:-devel}
DOCKER_TAG_ALT=${DOCKER_TAG_ALT:-devel_alt}

export ARTIFACTS=${ARTIFACTS:-_out/artifacts}

source hack/common.sh
Expand All @@ -44,4 +45,4 @@ if [[ ${KUBEVIRT_PROVIDER} == os-* ]] || [[ ${KUBEVIRT_PROVIDER} == okd-* ]]; th
oc=${kubectl}
fi

${TESTS_OUT_DIR}/tests.test -kubeconfig=${kubeconfig} -container-tag=${docker_tag} -container-tag-alt=${docker_tag_alt} -container-prefix=${functest_docker_prefix} -oc-path=${oc} -kubectl-path=${kubectl} -test.timeout 360m ${FUNC_TEST_ARGS} -installed-namespace=${namespace} -previous-release-tag=${previous_release_tag} -previous-release-registry=${previous_release_registry}
${TESTS_OUT_DIR}/tests.test -kubeconfig=${kubeconfig} -container-tag=${docker_tag} -container-tag-alt=${docker_tag_alt} -container-prefix=${functest_docker_prefix} -image-prefix-alt=${image_prefix_alt} -oc-path=${oc} -kubectl-path=${kubectl} -test.timeout 360m ${FUNC_TEST_ARGS} -installed-namespace=${namespace} -previous-release-tag=${previous_release_tag} -previous-release-registry=${previous_release_registry}
1 change: 0 additions & 1 deletion pkg/virt-operator/creation/components/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ go_library(
"//vendor/github.com/coreos/prometheus-operator/pkg/apis/monitoring:go_default_library",
"//vendor/github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1:go_default_library",
"//vendor/github.com/openshift/api/security/v1:go_default_library",
"//vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1:go_default_library",
"//vendor/k8s.io/api/apps/v1:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/api/policy/v1beta1:go_default_library",
Expand Down
Loading

0 comments on commit 97e2f1c

Please sign in to comment.