Skip to content

Commit

Permalink
Merge pull request kubevirt#2071 from davidvossel/install-strategy-v1
Browse files Browse the repository at this point in the history
KubeVirt Updates/Rollbacks Part 2/3 - Decouple Version and Registry Options
  • Loading branch information
davidvossel authored Mar 8, 2019
2 parents da01881 + 584568c commit dcdc067
Show file tree
Hide file tree
Showing 23 changed files with 793 additions and 542 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ bazel-build:
//cmd/..."

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

bazel-tests:
hack/dockerized "bazel test --test_output=errors -- //pkg/... "
Expand Down
13 changes: 8 additions & 5 deletions cluster/ephemeral-provider-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

set -e

_cli="docker run --privileged --net=host --rm ${USE_TTY} -v /var/run/docker.sock:/var/run/docker.sock kubevirtci/gocli@sha256:4a4565eb4487be95f464cb942590bbaa980a5b56acb32d955f7a9f81f4ba843c"
_cli_container="kubevirtci/gocli@sha256:4a4565eb4487be95f464cb942590bbaa980a5b56acb32d955f7a9f81f4ba843c"
_cli_with_tty="docker run --privileged --net=host --rm -t -v /var/run/docker.sock:/var/run/docker.sock ${_cli_container}"
_cli="docker run --privileged --net=host --rm ${USE_TTY} -v /var/run/docker.sock:/var/run/docker.sock ${_cli_container}"

function _main_ip() {
echo 127.0.0.1
Expand All @@ -17,6 +19,7 @@ function prepare_config() {
cat >hack/config-provider-$KUBEVIRT_PROVIDER.sh <<EOF
master_ip=$(_main_ip)
docker_tag=devel
docker_tag_alt=devel_alt
kubeconfig=${BASE_PATH}/cluster/$KUBEVIRT_PROVIDER/.kubeconfig
kubectl=${BASE_PATH}/cluster/$KUBEVIRT_PROVIDER/.kubectl
docker_prefix=localhost:$(_port registry)/kubevirt
Expand All @@ -41,19 +44,19 @@ function _add_common_params() {
function build() {
# Build everyting and publish it
${KUBEVIRT_PATH}hack/dockerized "DOCKER_PREFIX=${DOCKER_PREFIX} DOCKER_TAG=${DOCKER_TAG} KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER} IMAGE_PULL_POLICY=${IMAGE_PULL_POLICY} VERBOSITY=${VERBOSITY} ./hack/build-manifests.sh"
hack/dockerized "DOCKER_PREFIX=${DOCKER_PREFIX} DOCKER_TAG=${DOCKER_TAG} KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER} ./hack/bazel-push-images.sh"
${KUBEVIRT_PATH}hack/dockerized "DOCKER_PREFIX=${DOCKER_PREFIX} DOCKER_TAG=${DOCKER_TAG} DOCKER_TAG_ALT=${DOCKER_TAG_ALT} KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER} ./hack/bazel-push-images.sh"

# Make sure that all nodes use the newest images
container=""
container_alias=""
for arg in ${docker_images}; do
local name=$(basename $arg)
container="${container} ${manifest_docker_prefix}/${name}:${docker_tag}"
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
for i in $(seq 1 ${KUBEVIRT_NUM_NODES}); do
${_cli} ssh --prefix $provider_prefix "node$(printf "%02d" ${i})" "echo \"${container}\" | xargs \-\-max-args=1 sudo docker pull"
${_cli} ssh --prefix $provider_prefix "node$(printf "%02d" ${i})" "echo \"${container_alias}\" | xargs \-\-max-args=2 sudo docker tag"
${_cli_with_tty} ssh --prefix $provider_prefix "node$(printf "%02d" ${i})" "echo \"${container}\" | xargs \-\-max-args=1 sudo docker pull"
${_cli_with_tty} ssh --prefix $provider_prefix "node$(printf "%02d" ${i})" "echo \"${container_alias}\" | xargs \-\-max-args=2 sudo docker tag"
done
}

Expand Down
9 changes: 9 additions & 0 deletions hack/bazel-push-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,12 @@ bazel run \
--define container_prefix=${docker_prefix} \
--define container_tag=${docker_tag} \
//:push-images

if [ -n "$docker_tag_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 container_tag=${docker_tag_alt} \
//:push-images
fi
1 change: 1 addition & 0 deletions hack/config-default.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ 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 cmd/subresource-access-test images/winrmcli cmd/example-hook-sidecar cmd/example-cloudinit-hook-sidecar images/cdi-http-import-server cmd/container-disk-v1alpha"
docker_prefix=${DOCKER_PREFIX:-kubevirt}
docker_tag=${DOCKER_TAG:-latest}
docker_tag_alt=${DOCKER_TAG_ALT}
master_ip=192.168.200.2
network_provider=flannel
namespace=kubevirt
Expand Down
4 changes: 2 additions & 2 deletions hack/config.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
unset binaries docker_images docker_prefix docker_tag manifest_templates \
unset binaries docker_images docker_prefix docker_tag docker_tag_alt manifest_templates \
master_ip network_provider kubeconfig manifest_docker_prefix namespace image_pull_policy verbosity

KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER:-${PROVIDER}}
Expand All @@ -12,5 +12,5 @@ test -f "hack/config-provider-${KUBEVIRT_PROVIDER}.sh" && source hack/config-pro
# to change the version controlled config-default.sh file
test -f "hack/config-local.sh" && source hack/config-local.sh

export binaries docker_images docker_prefix docker_tag manifest_templates \
export binaries docker_images docker_prefix docker_tag docker_tag_alt manifest_templates \
master_ip network_provider kubeconfig namespace image_pull_policy verbosity
2 changes: 1 addition & 1 deletion hack/functests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ if [[ ${TARGET} == openshift* ]]; then
oc=${kubectl}
fi

${TESTS_OUT_DIR}/tests.test -kubeconfig=${kubeconfig} -container-tag=${docker_tag} -container-prefix=${functest_docker_prefix} -oc-path=${oc} -kubectl-path=${kubectl} -test.timeout 180m ${FUNC_TEST_ARGS} -installed-namespace=${namespace}
${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 180m ${FUNC_TEST_ARGS} -installed-namespace=${namespace}
26 changes: 26 additions & 0 deletions pkg/api/v1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 21 additions & 7 deletions pkg/api/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,13 @@ const (
// This label will be set on all resources created by the operator
ManagedByLabel = "app.kubernetes.io/managed-by"
ManagedByLabelOperatorValue = "kubevirt-operator"
// This label represents the kubevirt version for an install strategy configmap.
InstallStrategyVersionLabel = "kubevirt.io/install-strategy-version"
// This annotation represents the kubevirt version for an install strategy configmap.
InstallStrategyVersionAnnotation = "kubevirt.io/install-strategy-version"
// This annotation represents the kubevirt registry used for an install strategy configmap.
InstallStrategyRegistryAnnotation = "kubevirt.io/install-strategy-registry"

// This label indicates the object is a part of the install strategy retrieval process.
InstallStrategyLabel = "kubevirt.io/install-strategy"

VirtualMachineInstanceFinalizer string = "foregroundDeleteVirtualMachine"
CPUManager string = "cpumanager"
Expand Down Expand Up @@ -1050,6 +1055,13 @@ func (kl *KubeVirtList) GetListMeta() meta.List {
// ---
// +k8s:openapi-gen=true
type KubeVirtSpec struct {
// The image tag to use for the continer images installed.
// Defaults to the same tag as the operator's container image.
ImageTag string `json:"imageTag,omitempty"`
// The image registry to pull the container images from
// Defaults to the same registry the operator's container image is pulled from.
ImageRegistry string `json:"imageRegistry,omitempty"`

// The ImagePullPolicy to use.
ImagePullPolicy k8sv1.PullPolicy `json:"imagePullPolicy,omitempty" valid:"required"`
}
Expand All @@ -1058,11 +1070,13 @@ type KubeVirtSpec struct {
// ---
// +k8s:openapi-gen=true
type KubeVirtStatus struct {
Phase KubeVirtPhase `json:"phase,omitempty"`
Conditions []KubeVirtCondition `json:"conditions,omitempty" optional:"true"`
OperatorVersion string `json:"operatorVersion,omitempty" optional:"true"`
TargetKubeVirtVersion string `json:"targetKubeVirtVersion,omitempty" optional:"true"`
ObservedKubeVirtVersion string `json:"observedKubeVirtVersion,omitempty" optional:"true"`
Phase KubeVirtPhase `json:"phase,omitempty"`
Conditions []KubeVirtCondition `json:"conditions,omitempty" optional:"true"`
OperatorVersion string `json:"operatorVersion,omitempty" optional:"true"`
TargetKubeVirtVersion string `json:"targetKubeVirtVersion,omitempty" optional:"true"`
TargetKubeVirtRegistry string `json:"targetKubeVirtRegistry,omitempty" optional:"true"`
ObservedKubeVirtVersion string `json:"observedKubeVirtVersion,omitempty" optional:"true"`
ObservedKubeVirtRegistry string `json:"observedKubeVirtRegistry,omitempty" optional:"true"`
}

// KubeVirtPhase is a label for the phase of a KubeVirt deployment at the current time.
Expand Down
2 changes: 2 additions & 0 deletions pkg/api/v1/types_swagger_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/controller/virtinformers.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ func (f *kubeInformerFactory) DummyOperatorSCC() cache.SharedIndexInformer {

func (f *kubeInformerFactory) OperatorInstallStrategyConfigMaps() cache.SharedIndexInformer {
return f.getInformer("installStrategyConfigMapInformer", func() cache.SharedIndexInformer {
labelSelector, err := labels.Parse(kubev1.InstallStrategyVersionLabel)
labelSelector, err := labels.Parse(kubev1.InstallStrategyLabel)
if err != nil {
panic(err)
}
Expand All @@ -441,7 +441,7 @@ func (f *kubeInformerFactory) OperatorInstallStrategyConfigMaps() cache.SharedIn

func (f *kubeInformerFactory) OperatorInstallStrategyJob() cache.SharedIndexInformer {
return f.getInformer("installStrategyJobsInformer", func() cache.SharedIndexInformer {
labelSelector, err := labels.Parse(kubev1.InstallStrategyVersionLabel)
labelSelector, err := labels.Parse(kubev1.InstallStrategyLabel)
if err != nil {
panic(err)
}
Expand Down
5 changes: 1 addition & 4 deletions pkg/virt-operator/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ go_library(
"//pkg/log:go_default_library",
"//pkg/service:go_default_library",
"//pkg/util:go_default_library",
"//pkg/virt-operator/creation:go_default_library",
"//pkg/virt-operator/deletion:go_default_library",
"//pkg/virt-operator/install-strategy:go_default_library",
"//pkg/virt-operator/util:go_default_library",
"//vendor/github.com/prometheus/client_golang/prometheus/promhttp:go_default_library",
Expand Down Expand Up @@ -48,6 +46,7 @@ go_test(
"//pkg/kubecli:go_default_library",
"//pkg/log:go_default_library",
"//pkg/testutils:go_default_library",
"//pkg/version:go_default_library",
"//pkg/virt-operator/creation/components:go_default_library",
"//pkg/virt-operator/creation/rbac:go_default_library",
"//pkg/virt-operator/install-strategy:go_default_library",
Expand All @@ -63,10 +62,8 @@ go_test(
"//vendor/k8s.io/api/rbac/v1:go_default_library",
"//vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1:go_default_library",
"//vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/fake:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/client-go/kubernetes/fake:go_default_library",
"//vendor/k8s.io/client-go/testing:go_default_library",
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
Expand Down
15 changes: 0 additions & 15 deletions pkg/virt-operator/creation/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,15 +0,0 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
srcs = ["all.go"],
importpath = "kubevirt.io/kubevirt/pkg/virt-operator/creation",
visibility = ["//visibility:public"],
deps = [
"//pkg/api/v1:go_default_library",
"//pkg/kubecli:go_default_library",
"//pkg/log:go_default_library",
"//pkg/virt-operator/install-strategy:go_default_library",
"//pkg/virt-operator/util:go_default_library",
],
)
45 changes: 0 additions & 45 deletions pkg/virt-operator/creation/all.go

This file was deleted.

20 changes: 0 additions & 20 deletions pkg/virt-operator/deletion/BUILD.bazel

This file was deleted.

Loading

0 comments on commit dcdc067

Please sign in to comment.