From d2670cad958c533b15a393bbaed531f3edc9c302 Mon Sep 17 00:00:00 2001 From: Quique Llorente Date: Wed, 8 Jul 2020 11:50:23 +0200 Subject: [PATCH 01/15] Pass k8s provider shas as gocli build flags Also use default for registry organization so cluster can be started with `./cli run k8s-1.17` Signed-off-by: Quique Llorente --- cluster-provision/gocli/Makefile | 18 +++++++++++++++++- cluster-provision/gocli/cmd/run.go | 24 +++++++++++++++++++++--- cluster-provision/gocli/images/images.go | 20 ++++++++++++++++++++ 3 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 cluster-provision/gocli/images/images.go diff --git a/cluster-provision/gocli/Makefile b/cluster-provision/gocli/Makefile index 259a81b32d..71023440ae 100644 --- a/cluster-provision/gocli/Makefile +++ b/cluster-provision/gocli/Makefile @@ -1,5 +1,13 @@ SHELL := /bin/bash + +K8S118SHA ?= c41e3d9adb756b60e1fbce2ffd774c66c99fdde7ee337460c472ee92868e579e +K8S117SHA ?= 7506c49307944d2bbbf6486bc9c9aa4496694d3284143a51ee87333c1a0ab7f0 +K8S116SHA ?= 1e153fb62c9a30ce6bc6ddc1af21bb28a56b780ec93ab15e113d729bf664469a +K8S115SHA ?= c58cb9d79968590f24e070bc2517088d44fa2f83ba73e989a7e0f690ad08460b +K8S114SHA ?= 46e449b292dcb420f0944cac0a7a5c667c6f19bba2a4192737380e8e77f27ed0 + + BIN_DIR = $(CURDIR)/build GO ?= go @@ -13,7 +21,15 @@ all: container-run .PHONY: gocli cli: fmt - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build -o $(BIN_DIR)/cli ./cmd/cli + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build \ + -ldflags "\ + -X 'kubevirt.io/kubevirtci/cluster-provision/gocli/images.K8S118SHA=$(K8S118SHA)'\ + -X 'kubevirt.io/kubevirtci/cluster-provision/gocli/images.K8S117SHA=$(K8S117SHA)'\ + -X 'kubevirt.io/kubevirtci/cluster-provision/gocli/images.K8S116SHA=$(K8S116SHA)'\ + -X 'kubevirt.io/kubevirtci/cluster-provision/gocli/images.K8S115SHA=$(K8S115SHA)'\ + -X 'kubevirt.io/kubevirtci/cluster-provision/gocli/images.K8S114SHA=$(K8S114SHA)'\ + " \ + -o $(BIN_DIR)/cli ./cmd/cli .PHONY: fmt fmt: diff --git a/cluster-provision/gocli/cmd/run.go b/cluster-provision/gocli/cmd/run.go index 14db7e02c8..f6b527f753 100644 --- a/cluster-provision/gocli/cmd/run.go +++ b/cluster-provision/gocli/cmd/run.go @@ -23,6 +23,7 @@ import ( "kubevirt.io/kubevirtci/cluster-provision/gocli/cmd/utils" "kubevirt.io/kubevirtci/cluster-provision/gocli/docker" + "kubevirt.io/kubevirtci/cluster-provision/gocli/images" ) const proxySettings = ` @@ -72,6 +73,7 @@ func NewRunCommand() *cobra.Command { run.Flags().Bool("enable-ceph", false, "enables dynamic storage provisioning using Ceph") run.Flags().String("docker-proxy", "", "sets network proxy for docker daemon") run.Flags().String("container-registry", "docker.io", "the registry to pull cluster container from") + run.Flags().String("container-org", "kubevirtci", "the organization at the registry to pull the container from") return run } @@ -163,6 +165,11 @@ func run(cmd *cobra.Command, args []string) (err error) { return err } + containerOrg, err := cmd.Flags().GetString("container-org") + if err != nil { + return err + } + cli, err := client.NewEnvClient() if err != nil { return err @@ -185,8 +192,19 @@ func run(cmd *cobra.Command, args []string) (err error) { done <- fmt.Errorf("Interrupt received, clean up") }() + clusterImage := cluster + + // Check if default shas has to be used + clusterSHA, found := images.SHAByProvider[cluster] + if found { + if len(clusterSHA) == 0 { + return fmt.Errorf("Empty SHA for %s provider", cluster) + } + clusterImage = fmt.Sprintf("%s/%s@sha256:%s", containerOrg, cluster, clusterSHA) + } + if len(containerRegistry) > 0 { - imageRef := path.Join(containerRegistry, cluster) + imageRef := path.Join(containerRegistry, clusterImage) fmt.Printf("Download the image %s\n", imageRef) err = docker.ImagePull(cli, ctx, imageRef, types.ImagePullOptions{}) if err != nil { @@ -196,7 +214,7 @@ func run(cmd *cobra.Command, args []string) (err error) { // Start dnsmasq dnsmasq, err := cli.ContainerCreate(ctx, &container.Config{ - Image: cluster, + Image: clusterImage, Env: []string{ fmt.Sprintf("NUM_NODES=%d", nodes), fmt.Sprintf("NUM_SECONDARY_NICS=%d", secondaryNics), @@ -416,7 +434,7 @@ func run(cmd *cobra.Command, args []string) (err error) { volumes <- vol.Name node, err := cli.ContainerCreate(ctx, &container.Config{ - Image: cluster, + Image: clusterImage, Env: []string{ fmt.Sprintf("NODE_NUM=%s", nodeNum), }, diff --git a/cluster-provision/gocli/images/images.go b/cluster-provision/gocli/images/images.go new file mode 100644 index 0000000000..12a48c8ce5 --- /dev/null +++ b/cluster-provision/gocli/images/images.go @@ -0,0 +1,20 @@ +package images + +var ( + K8S118SHA = "" + K8S117SHA = "" + K8S116SHA = "" + K8S115SHA = "" + K8S114SHA = "" + SHAByProvider map[string]string +) + +func init() { + SHAByProvider = map[string]string{ + "k8s-1.18": K8S118SHA, + "k8s-1.17": K8S117SHA, + "k8s-1.16": K8S116SHA, + "k8s-1.15": K8S115SHA, + "k8s-1.14": K8S114SHA, + } +} From 872b2be4305bbeacf0a12b36e22a15bbb4d5ac7c Mon Sep 17 00:00:00 2001 From: Quique Llorente Date: Thu, 9 Jul 2020 10:28:10 +0200 Subject: [PATCH 02/15] Remove images.sh from cluster-up Now the hashes for k8s are at gocli binary, also okd/ocp providers can be deprectated. Signed-off-by: Quique Llorente --- cluster-provision/gocli/cmd/run.go | 2 ++ .../cluster/ephemeral-provider-common.sh | 6 +++--- cluster-up/cluster/images.sh | 18 ------------------ 3 files changed, 5 insertions(+), 21 deletions(-) delete mode 100644 cluster-up/cluster/images.sh diff --git a/cluster-provision/gocli/cmd/run.go b/cluster-provision/gocli/cmd/run.go index f6b527f753..44f0d124bb 100644 --- a/cluster-provision/gocli/cmd/run.go +++ b/cluster-provision/gocli/cmd/run.go @@ -201,6 +201,8 @@ func run(cmd *cobra.Command, args []string) (err error) { return fmt.Errorf("Empty SHA for %s provider", cluster) } clusterImage = fmt.Sprintf("%s/%s@sha256:%s", containerOrg, cluster, clusterSHA) + } else { + clusterImage = path.Join(containerOrg, cluster) } if len(containerRegistry) > 0 { diff --git a/cluster-up/cluster/ephemeral-provider-common.sh b/cluster-up/cluster/ephemeral-provider-common.sh index 8bbed465c2..4e94d14d2e 100644 --- a/cluster-up/cluster/ephemeral-provider-common.sh +++ b/cluster-up/cluster/ephemeral-provider-common.sh @@ -2,12 +2,12 @@ set -e -source ${KUBEVIRTCI_PATH}/cluster/images.sh +gocli_image="gocli@sha256:2ce75db868bbf2811395dfe4f73a68160d2ad700b1e08aeee6956b4943ceb237" if [ "${KUBEVIRTCI_RUNTIME}" = "podman" ]; then _cli="pack8s" else - _cli_container="${KUBEVIRTCI_GOCLI_CONTAINER:-kubevirtci/${IMAGES[gocli]}}" + _cli_container="${KUBEVIRTCI_GOCLI_CONTAINER:-kubevirtci/$gocli_image}" _cli="docker run --privileged --net=host --rm ${USE_TTY} -v /var/run/docker.sock:/var/run/docker.sock ${_cli_container}" fi @@ -36,7 +36,7 @@ function _registry_volume() { } function _add_common_params() { - local params="--nodes ${KUBEVIRT_NUM_NODES} --memory ${KUBEVIRT_MEMORY_SIZE} --cpu 6 --secondary-nics ${KUBEVIRT_NUM_SECONDARY_NICS} --random-ports --background --prefix $provider_prefix --registry-volume $(_registry_volume) kubevirtci/${image} ${KUBEVIRT_PROVIDER_EXTRA_ARGS}" + local params="--nodes ${KUBEVIRT_NUM_NODES} --memory ${KUBEVIRT_MEMORY_SIZE} --cpu 6 --secondary-nics ${KUBEVIRT_NUM_SECONDARY_NICS} --random-ports --background --prefix $provider_prefix --registry-volume $(_registry_volume) $KUBEVIRT_PROVIDER ${KUBEVIRT_PROVIDER_EXTRA_ARGS}" if [[ $TARGET =~ windows.* ]] && [ -n "$WINDOWS_NFS_DIR" ]; then params=" --nfs-data $WINDOWS_NFS_DIR $params" elif [[ $TARGET =~ os-.* ]] && [ -n "$RHEL_NFS_DIR" ]; then diff --git a/cluster-up/cluster/images.sh b/cluster-up/cluster/images.sh deleted file mode 100644 index bda87aadb2..0000000000 --- a/cluster-up/cluster/images.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -set -e - -declare -A IMAGES -IMAGES[gocli]="gocli@sha256:0cec3163e5f8b050f129fa795b76c20cb1eb27c91564c63663160b095064a1f9" -if [ -z $KUBEVIRTCI_PROVISION_CHECK ]; then - IMAGES[k8s-fedora-1.17.0]="k8s-fedora-1.17.0@sha256:aebf67b8b1b499c721f4d98a7ab9542c680553a14cbc144d1fa701fe611f3c0d" - IMAGES[k8s-1.18]="k8s-1.18@sha256:fcf196a188cdb600d35e594b26b39804106e4ad263deea012a8a9a863232c4e4" - IMAGES[k8s-1.17]="k8s-1.17@sha256:789c57e011101c1ba3840809898c17a7e108a20c95a12f6a713ea1d98fa0a19c" - IMAGES[k8s-1.16]="k8s-1.16@sha256:1e153fb62c9a30ce6bc6ddc1af21bb28a56b780ec93ab15e113d729bf664469a" - IMAGES[k8s-1.15]="k8s-1.15@sha256:c58cb9d79968590f24e070bc2517088d44fa2f83ba73e989a7e0f690ad08460b" - IMAGES[k8s-1.14]="k8s-1.14@sha256:46e449b292dcb420f0944cac0a7a5c667c6f19bba2a4192737380e8e77f27ed0" -fi -export IMAGES - -image="${IMAGES[$KUBEVIRT_PROVIDER]:-${KUBEVIRT_PROVIDER}${IMAGE_SUFFIX}:latest}" -export image From 2fcf26b63543b5f8917b587d8d4aec1081ae6d36 Mon Sep 17 00:00:00 2001 From: Quique Llorente Date: Thu, 9 Jul 2020 13:23:47 +0200 Subject: [PATCH 03/15] Use gocli binary directly Signed-off-by: Quique Llorente --- cluster-provision/gocli/Makefile | 6 +++--- cluster-up/cluster/ephemeral-provider-common.sh | 11 +++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cluster-provision/gocli/Makefile b/cluster-provision/gocli/Makefile index 71023440ae..29d633a8f5 100644 --- a/cluster-provision/gocli/Makefile +++ b/cluster-provision/gocli/Makefile @@ -21,7 +21,7 @@ all: container-run .PHONY: gocli cli: fmt - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build \ + @CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build \ -ldflags "\ -X 'kubevirt.io/kubevirtci/cluster-provision/gocli/images.K8S118SHA=$(K8S118SHA)'\ -X 'kubevirt.io/kubevirtci/cluster-provision/gocli/images.K8S117SHA=$(K8S117SHA)'\ @@ -33,8 +33,8 @@ cli: fmt .PHONY: fmt fmt: - $(GO) fmt ./cmd/... - $(GO) fmt ./docker/... + @$(GO) fmt ./cmd/... + @$(GO) fmt ./docker/... .PHONY: container container: cli diff --git a/cluster-up/cluster/ephemeral-provider-common.sh b/cluster-up/cluster/ephemeral-provider-common.sh index 4e94d14d2e..af03bc813c 100644 --- a/cluster-up/cluster/ephemeral-provider-common.sh +++ b/cluster-up/cluster/ephemeral-provider-common.sh @@ -2,13 +2,16 @@ set -e -gocli_image="gocli@sha256:2ce75db868bbf2811395dfe4f73a68160d2ad700b1e08aeee6956b4943ceb237" - if [ "${KUBEVIRTCI_RUNTIME}" = "podman" ]; then _cli="pack8s" else - _cli_container="${KUBEVIRTCI_GOCLI_CONTAINER:-kubevirtci/$gocli_image}" - _cli="docker run --privileged --net=host --rm ${USE_TTY} -v /var/run/docker.sock:/var/run/docker.sock ${_cli_container}" + _cli=./cli + # If this is not kubevirtci release tarball build gocli and use, it will + # Use :latest providers + if [ ! -f $_cli ]; then + make -C $KUBEVIRTCI_PATH/../cluster-provision/gocli cli + _cli="$KUBEVIRTCI_PATH/../cluster-provision/gocli/build/cli" + fi fi function _main_ip() { From dd89586c3b0897e5af8e30c3d38f1c6f558c7bc8 Mon Sep 17 00:00:00 2001 From: Quique Llorente Date: Thu, 9 Jul 2020 13:27:35 +0200 Subject: [PATCH 04/15] Use :latest providers doing cluster-up from kubevirtci repo Signed-off-by: Quique Llorente --- cluster-provision/gocli/Makefile | 20 ++++++++++---------- cluster-provision/gocli/cmd/run.go | 8 ++++---- cluster-provision/gocli/images/images.go | 24 ++++++++++++------------ 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/cluster-provision/gocli/Makefile b/cluster-provision/gocli/Makefile index 29d633a8f5..24ce52afb7 100644 --- a/cluster-provision/gocli/Makefile +++ b/cluster-provision/gocli/Makefile @@ -1,11 +1,11 @@ SHELL := /bin/bash -K8S118SHA ?= c41e3d9adb756b60e1fbce2ffd774c66c99fdde7ee337460c472ee92868e579e -K8S117SHA ?= 7506c49307944d2bbbf6486bc9c9aa4496694d3284143a51ee87333c1a0ab7f0 -K8S116SHA ?= 1e153fb62c9a30ce6bc6ddc1af21bb28a56b780ec93ab15e113d729bf664469a -K8S115SHA ?= c58cb9d79968590f24e070bc2517088d44fa2f83ba73e989a7e0f690ad08460b -K8S114SHA ?= 46e449b292dcb420f0944cac0a7a5c667c6f19bba2a4192737380e8e77f27ed0 +K8S118SUFFIX ?= :latest +K8S117SUFFIX ?= :latest +K8S116SUFFIX ?= :latest +K8S115SUFFIX ?= :latest +K8S114SIFFUX ?= :latest BIN_DIR = $(CURDIR)/build @@ -23,11 +23,11 @@ all: container-run cli: fmt @CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build \ -ldflags "\ - -X 'kubevirt.io/kubevirtci/cluster-provision/gocli/images.K8S118SHA=$(K8S118SHA)'\ - -X 'kubevirt.io/kubevirtci/cluster-provision/gocli/images.K8S117SHA=$(K8S117SHA)'\ - -X 'kubevirt.io/kubevirtci/cluster-provision/gocli/images.K8S116SHA=$(K8S116SHA)'\ - -X 'kubevirt.io/kubevirtci/cluster-provision/gocli/images.K8S115SHA=$(K8S115SHA)'\ - -X 'kubevirt.io/kubevirtci/cluster-provision/gocli/images.K8S114SHA=$(K8S114SHA)'\ + -X 'kubevirt.io/kubevirtci/cluster-provision/gocli/images.K8S118SUFFIX=$(K8S118SUFFIX)'\ + -X 'kubevirt.io/kubevirtci/cluster-provision/gocli/images.K8S117SUFFIX=$(K8S117SUFFIX)'\ + -X 'kubevirt.io/kubevirtci/cluster-provision/gocli/images.K8S116SUFFIX=$(K8S116SUFFIX)'\ + -X 'kubevirt.io/kubevirtci/cluster-provision/gocli/images.K8S115SUFFIX=$(K8S115SUFFIX)'\ + -X 'kubevirt.io/kubevirtci/cluster-provision/gocli/images.K8S114SUFFIX=$(K8S114SUFFIX)'\ " \ -o $(BIN_DIR)/cli ./cmd/cli diff --git a/cluster-provision/gocli/cmd/run.go b/cluster-provision/gocli/cmd/run.go index 44f0d124bb..11606896ee 100644 --- a/cluster-provision/gocli/cmd/run.go +++ b/cluster-provision/gocli/cmd/run.go @@ -195,12 +195,12 @@ func run(cmd *cobra.Command, args []string) (err error) { clusterImage := cluster // Check if default shas has to be used - clusterSHA, found := images.SHAByProvider[cluster] + clusterSuffix, found := images.SuffixByProvider[cluster] if found { - if len(clusterSHA) == 0 { - return fmt.Errorf("Empty SHA for %s provider", cluster) + if len(clusterSuffix) == 0 { + return fmt.Errorf("Empty Suffix for %s provider", cluster) } - clusterImage = fmt.Sprintf("%s/%s@sha256:%s", containerOrg, cluster, clusterSHA) + clusterImage = fmt.Sprintf("%s/%s%s", containerOrg, cluster, clusterSuffix) } else { clusterImage = path.Join(containerOrg, cluster) } diff --git a/cluster-provision/gocli/images/images.go b/cluster-provision/gocli/images/images.go index 12a48c8ce5..13c1340188 100644 --- a/cluster-provision/gocli/images/images.go +++ b/cluster-provision/gocli/images/images.go @@ -1,20 +1,20 @@ package images var ( - K8S118SHA = "" - K8S117SHA = "" - K8S116SHA = "" - K8S115SHA = "" - K8S114SHA = "" - SHAByProvider map[string]string + K8S118SUFFIX = "" + K8S117SUFFIX = "" + K8S116SUFFIX = "" + K8S115SUFFIX = "" + K8S114SUFFIX = "" + SuffixByProvider map[string]string ) func init() { - SHAByProvider = map[string]string{ - "k8s-1.18": K8S118SHA, - "k8s-1.17": K8S117SHA, - "k8s-1.16": K8S116SHA, - "k8s-1.15": K8S115SHA, - "k8s-1.14": K8S114SHA, + SuffixByProvider = map[string]string{ + "k8s-1.18": K8S118SUFFIX, + "k8s-1.17": K8S117SUFFIX, + "k8s-1.16": K8S116SUFFIX, + "k8s-1.15": K8S115SUFFIX, + "k8s-1.14": K8S114SUFFIX, } } From c65cfc4131e4599addf1fcc4fa36d68d8967667a Mon Sep 17 00:00:00 2001 From: Quique Llorente Date: Thu, 9 Jul 2020 14:28:44 +0200 Subject: [PATCH 05/15] Add kubevirtci release script Signed-off-by: Quique Llorente --- .gitignore | 3 ++ automation/release.sh | 43 +++++++++++++++++++ cluster-provision/gocli/Makefile | 6 +-- .../cluster/ephemeral-provider-common.sh | 4 +- 4 files changed, 52 insertions(+), 4 deletions(-) create mode 100755 automation/release.sh diff --git a/.gitignore b/.gitignore index 765047a5a3..9d16ffcd4c 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,6 @@ sonobuoy* # Bazel directories cluster-provision/gocli/bazel-* + +# Artifacts after releasing +kubevirtci.tar.gz diff --git a/automation/release.sh b/automation/release.sh new file mode 100755 index 0000000000..563965a3fc --- /dev/null +++ b/automation/release.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +set -euxo pipefail + +workdir=$(mktemp -d) + +end() { + rm -rf $workdir +} +trap end EXIT + + +function get_latest_digest_suffix() { + local provider=$1 + local latest_digest=$(docker run alexeiled/skopeo skopeo inspect docker://docker.io/kubevirtci/$provider:latest | docker run -i imega/jq -r -c .Digest) + echo "@$latest_digest" +} + +#TODO: discover what providers has changed and re-provision there +#pushd cluster-provision/k8s/1.18 +# ../provision.sh +# ..publish.sh +#popd + +pushd cluster-provision/gocli + make cli \ + K8S118SUFFIX="$(get_latest_digest_suffix k8s-1.18)" \ + K8S117SUFFIX="$(get_latest_digest_suffix k8s-1.17)" \ + K8S116SUFFIX="$(get_latest_digest_suffix k8s-1.16)" \ + K8S115SUFFIX="$(get_latest_digest_suffix k8s-1.15)" \ + K8S114SUFFIX="$(get_latest_digest_suffix k8s-1.14)" +popd + +# Install cluster-up +cp -rf cluster-up/* $workdir + +# Install gocli +cp -f cluster-provision/gocli/build/cli $workdir + +# Create the tarball +tar -C $workdir -cvzf kubevirtci.tar.gz . + +# TODO release tarball diff --git a/cluster-provision/gocli/Makefile b/cluster-provision/gocli/Makefile index 24ce52afb7..62cf5e825f 100644 --- a/cluster-provision/gocli/Makefile +++ b/cluster-provision/gocli/Makefile @@ -21,7 +21,7 @@ all: container-run .PHONY: gocli cli: fmt - @CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build \ + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build \ -ldflags "\ -X 'kubevirt.io/kubevirtci/cluster-provision/gocli/images.K8S118SUFFIX=$(K8S118SUFFIX)'\ -X 'kubevirt.io/kubevirtci/cluster-provision/gocli/images.K8S117SUFFIX=$(K8S117SUFFIX)'\ @@ -33,8 +33,8 @@ cli: fmt .PHONY: fmt fmt: - @$(GO) fmt ./cmd/... - @$(GO) fmt ./docker/... + $(GO) fmt ./cmd/... + $(GO) fmt ./docker/... .PHONY: container container: cli diff --git a/cluster-up/cluster/ephemeral-provider-common.sh b/cluster-up/cluster/ephemeral-provider-common.sh index af03bc813c..bc5ebcfcc3 100644 --- a/cluster-up/cluster/ephemeral-provider-common.sh +++ b/cluster-up/cluster/ephemeral-provider-common.sh @@ -2,10 +2,12 @@ set -e +script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + if [ "${KUBEVIRTCI_RUNTIME}" = "podman" ]; then _cli="pack8s" else - _cli=./cli + _cli="$KUBEVIRTCI_PATH/cli" # If this is not kubevirtci release tarball build gocli and use, it will # Use :latest providers if [ ! -f $_cli ]; then From e70f25a7c76431e4796cb739c3a44f657c9b0983 Mon Sep 17 00:00:00 2001 From: Quique Llorente Date: Tue, 21 Jul 2020 16:07:42 +0200 Subject: [PATCH 06/15] Store kubevirtci tarball at ARTIFACTS to inspect at prow Signed-off-by: Quique Llorente --- automation/release.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/automation/release.sh b/automation/release.sh index 563965a3fc..230d16cbb2 100755 --- a/automation/release.sh +++ b/automation/release.sh @@ -3,6 +3,7 @@ set -euxo pipefail workdir=$(mktemp -d) +ARTIFACTS=${ARTIFACTS:-/tmp} end() { rm -rf $workdir @@ -38,6 +39,6 @@ cp -rf cluster-up/* $workdir cp -f cluster-provision/gocli/build/cli $workdir # Create the tarball -tar -C $workdir -cvzf kubevirtci.tar.gz . +tar -C $workdir -cvzf $ARTIFACTS/kubevirtci.tar.gz . # TODO release tarball From 71278cb6c0eb67f2e47d53ac10a2acca47e8207b Mon Sep 17 00:00:00 2001 From: Quique Llorente Date: Tue, 21 Jul 2020 16:21:46 +0200 Subject: [PATCH 07/15] Provision k8s-1.18 as an example Signed-off-by: Quique Llorente --- automation/release.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/automation/release.sh b/automation/release.sh index 230d16cbb2..10bb1ab101 100755 --- a/automation/release.sh +++ b/automation/release.sh @@ -18,10 +18,10 @@ function get_latest_digest_suffix() { } #TODO: discover what providers has changed and re-provision there -#pushd cluster-provision/k8s/1.18 -# ../provision.sh -# ..publish.sh -#popd +pushd cluster-provision/k8s/1.18 + ../provision.sh + ..publish.sh +popd pushd cluster-provision/gocli make cli \ @@ -32,11 +32,14 @@ pushd cluster-provision/gocli K8S114SUFFIX="$(get_latest_digest_suffix k8s-1.14)" popd +# Create kubevirtci dir inside the tarball +mkdir $workdir/kubevirtci + # Install cluster-up -cp -rf cluster-up/* $workdir +cp -rf cluster-up/* $workdir/kubevirtci # Install gocli -cp -f cluster-provision/gocli/build/cli $workdir +cp -f cluster-provision/gocli/build/cli $workdir/kubevirtci # Create the tarball tar -C $workdir -cvzf $ARTIFACTS/kubevirtci.tar.gz . From 7b5aa5d2efc3b60c0c17a85226d8931b40fe666d Mon Sep 17 00:00:00 2001 From: Quique Llorente Date: Tue, 21 Jul 2020 16:57:11 +0200 Subject: [PATCH 08/15] Integrate github-release Signed-off-by: Quique Llorente --- automation/release.sh | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/automation/release.sh b/automation/release.sh index 10bb1ab101..01509c59f9 100755 --- a/automation/release.sh +++ b/automation/release.sh @@ -44,4 +44,25 @@ cp -f cluster-provision/gocli/build/cli $workdir/kubevirtci # Create the tarball tar -C $workdir -cvzf $ARTIFACTS/kubevirtci.tar.gz . -# TODO release tarball +# Install github-release tool +# TODO: Vendor this +go get github.com/github-release/github-release@v0.8.1 + +# Create the release +tag $(git rev-parse --short HEAD) +github-release release \ + -u kubevirt \ + -r kubevirtci \ + --tag $tag \ + --name $tag \ + --description "Follow instructions at kubevirtci.tar.gz README" + +# Upload tarball +github-release upload \ + -u kubevirt \ + -r kubevirtci \ + --name kubevirtci.tar.gz \ + --tag $tag\ + --file $ARTIFACTS/kubevirtci.tar.gz + + From 472269a1fab37e5fed9dda8b969c38c7981c31f8 Mon Sep 17 00:00:00 2001 From: Quique Llorente Date: Wed, 22 Jul 2020 13:25:21 +0200 Subject: [PATCH 09/15] Rename base images to centos7 and centos8 and use :latest at k8s providers They are going to be build but automatization so using latest is fine so we don't have to update those hashes. Signed-off-by: Quique Llorente --- automation/release.sh | 18 +++++++++++++----- cluster-provision/centos7/build.sh | 2 +- cluster-provision/centos7/publish.sh | 8 ++------ cluster-provision/centos8/build.sh | 2 +- cluster-provision/centos8/publish.sh | 6 ++---- cluster-provision/k8s/1.14/base | 2 +- cluster-provision/k8s/1.15/base | 2 +- cluster-provision/k8s/1.16/base | 2 +- cluster-provision/k8s/1.17/base | 2 +- cluster-provision/k8s/1.18/base | 2 +- 10 files changed, 24 insertions(+), 22 deletions(-) diff --git a/automation/release.sh b/automation/release.sh index 01509c59f9..737574a9d2 100755 --- a/automation/release.sh +++ b/automation/release.sh @@ -17,11 +17,19 @@ function get_latest_digest_suffix() { echo "@$latest_digest" } -#TODO: discover what providers has changed and re-provision there -pushd cluster-provision/k8s/1.18 - ../provision.sh - ..publish.sh -popd +#TODO: Discover what base images need to be build +for base in "centos7 centos8"; do + cluster-provision/$base/build.sh + cluster-provision/$base/publish.sh +done + +#TODO: Discover what providers need to be build +for provider in "1.14 1.15 1.16 1.17 1.18"; do + pushd cluster-provision/k8s/$provider + ../provision.sh + ..publish.sh + popd +done pushd cluster-provision/gocli make cli \ diff --git a/cluster-provision/centos7/build.sh b/cluster-provision/centos7/build.sh index 0e75a469f6..d08c0e6c4d 100755 --- a/cluster-provision/centos7/build.sh +++ b/cluster-provision/centos7/build.sh @@ -4,4 +4,4 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" centos_version="$(cat $DIR/version | tr -d '\n')" -docker build --build-arg centos_version=$centos_version . -t kubevirtci/centos:$centos_version +docker build --build-arg centos_version=$centos_version . -t kubevirtci/centos7 diff --git a/cluster-provision/centos7/publish.sh b/cluster-provision/centos7/publish.sh index f9f4759551..91bee32e53 100755 --- a/cluster-provision/centos7/publish.sh +++ b/cluster-provision/centos7/publish.sh @@ -1,8 +1,4 @@ #!/bin/bash -e -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -centos_version="$(cat $DIR/version | tr -d '\n')" - -docker tag kubevirtci/centos:$centos_version docker.io/kubevirtci/centos:$centos_version -docker push docker.io/kubevirtci/centos:$centos_version +docker tag kubevirtci/centos7 docker.io/kubevirtci/centos7 +docker push docker.io/kubevirtci/centos7 diff --git a/cluster-provision/centos8/build.sh b/cluster-provision/centos8/build.sh index 0e75a469f6..6ce545261e 100755 --- a/cluster-provision/centos8/build.sh +++ b/cluster-provision/centos8/build.sh @@ -4,4 +4,4 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" centos_version="$(cat $DIR/version | tr -d '\n')" -docker build --build-arg centos_version=$centos_version . -t kubevirtci/centos:$centos_version +docker build --build-arg centos_version=$centos_version . -t kubevirtci/centos8 diff --git a/cluster-provision/centos8/publish.sh b/cluster-provision/centos8/publish.sh index f9f4759551..79cd7406b6 100755 --- a/cluster-provision/centos8/publish.sh +++ b/cluster-provision/centos8/publish.sh @@ -2,7 +2,5 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -centos_version="$(cat $DIR/version | tr -d '\n')" - -docker tag kubevirtci/centos:$centos_version docker.io/kubevirtci/centos:$centos_version -docker push docker.io/kubevirtci/centos:$centos_version +docker tag kubevirtci/centos8 docker.io/kubevirtci/centos8 +docker push docker.io/kubevirtci/centos8 diff --git a/cluster-provision/k8s/1.14/base b/cluster-provision/k8s/1.14/base index 5d669c35e3..4dc5d3e003 100644 --- a/cluster-provision/k8s/1.14/base +++ b/cluster-provision/k8s/1.14/base @@ -1 +1 @@ -centos@sha256:4f105ae5eb0aa3bb034fa24591ea80bf67701b1bc6449d40aa1bec33bc6a4e9a +centos7:latest diff --git a/cluster-provision/k8s/1.15/base b/cluster-provision/k8s/1.15/base index 5d669c35e3..4dc5d3e003 100644 --- a/cluster-provision/k8s/1.15/base +++ b/cluster-provision/k8s/1.15/base @@ -1 +1 @@ -centos@sha256:4f105ae5eb0aa3bb034fa24591ea80bf67701b1bc6449d40aa1bec33bc6a4e9a +centos7:latest diff --git a/cluster-provision/k8s/1.16/base b/cluster-provision/k8s/1.16/base index 5d669c35e3..4dc5d3e003 100644 --- a/cluster-provision/k8s/1.16/base +++ b/cluster-provision/k8s/1.16/base @@ -1 +1 @@ -centos@sha256:4f105ae5eb0aa3bb034fa24591ea80bf67701b1bc6449d40aa1bec33bc6a4e9a +centos7:latest diff --git a/cluster-provision/k8s/1.17/base b/cluster-provision/k8s/1.17/base index 55efa708d2..61091e1fb4 100644 --- a/cluster-provision/k8s/1.17/base +++ b/cluster-provision/k8s/1.17/base @@ -1 +1 @@ -centos@sha256:6822c8300b50695896333b53dd5e2aafe9f69ba51b1c89d529740a7f601f6b1b +centos8:latest diff --git a/cluster-provision/k8s/1.18/base b/cluster-provision/k8s/1.18/base index 55efa708d2..61091e1fb4 100644 --- a/cluster-provision/k8s/1.18/base +++ b/cluster-provision/k8s/1.18/base @@ -1 +1 @@ -centos@sha256:6822c8300b50695896333b53dd5e2aafe9f69ba51b1c89d529740a7f601f6b1b +centos8:latest From 464d57463af30685ac6b0beef338391e4c63a689 Mon Sep 17 00:00:00 2001 From: Quique Llorente Date: Wed, 22 Jul 2020 14:05:43 +0200 Subject: [PATCH 10/15] Use a array for base and providers Signed-off-by: Quique Llorente --- automation/release.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/automation/release.sh b/automation/release.sh index 737574a9d2..bcc16ff185 100755 --- a/automation/release.sh +++ b/automation/release.sh @@ -4,6 +4,8 @@ set -euxo pipefail workdir=$(mktemp -d) ARTIFACTS=${ARTIFACTS:-/tmp} +base_images=(centos7 centos8) +k8s_providers=(1.14 1.15 1.16 1.17 1.18) end() { rm -rf $workdir @@ -17,17 +19,20 @@ function get_latest_digest_suffix() { echo "@$latest_digest" } + #TODO: Discover what base images need to be build -for base in "centos7 centos8"; do - cluster-provision/$base/build.sh - cluster-provision/$base/publish.sh +for base_image in $base_images; do + pushd cluster-provision/$base_image + ./build.sh + ./publish.sh + popd done #TODO: Discover what providers need to be build -for provider in "1.14 1.15 1.16 1.17 1.18"; do - pushd cluster-provision/k8s/$provider +for k8s_provider in $k8s_providers; do + pushd cluster-provision/k8s/$k8s_provider ../provision.sh - ..publish.sh + ../publish.sh popd done From 2490555352e075dacbdd23f612d11122a117b9b0 Mon Sep 17 00:00:00 2001 From: Quique Llorente Date: Thu, 23 Jul 2020 09:19:40 +0200 Subject: [PATCH 11/15] Reduce to centos8, k8s-1.17 and k8s-1.18 Signed-off-by: Quique Llorente --- automation/release.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/automation/release.sh b/automation/release.sh index bcc16ff185..1347e0af0d 100755 --- a/automation/release.sh +++ b/automation/release.sh @@ -4,8 +4,8 @@ set -euxo pipefail workdir=$(mktemp -d) ARTIFACTS=${ARTIFACTS:-/tmp} -base_images=(centos7 centos8) -k8s_providers=(1.14 1.15 1.16 1.17 1.18) +base_images=(centos8) +k8s_providers=(1.17 1.18) end() { rm -rf $workdir From 122807c2cb15f4d7280219cb9e8b48b9eab93c1b Mon Sep 17 00:00:00 2001 From: Quique Llorente Date: Thu, 23 Jul 2020 15:26:41 +0200 Subject: [PATCH 12/15] Skip container build provision to test github-release only Signed-off-by: Quique Llorente --- automation/release.sh | 50 +++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/automation/release.sh b/automation/release.sh index 1347e0af0d..9fc90928db 100755 --- a/automation/release.sh +++ b/automation/release.sh @@ -20,21 +20,29 @@ function get_latest_digest_suffix() { } -#TODO: Discover what base images need to be build -for base_image in $base_images; do - pushd cluster-provision/$base_image - ./build.sh - ./publish.sh - popd -done - -#TODO: Discover what providers need to be build -for k8s_provider in $k8s_providers; do - pushd cluster-provision/k8s/$k8s_provider - ../provision.sh - ../publish.sh - popd -done +function build_and_publish_base_images() { + #TODO: Discover what base images need to be build + for base_image in $base_images; do + pushd cluster-provision/$base_image + ./build.sh + ./publish.sh + popd + done +} + +function provision_and_publish_providers() { + #TODO: Discover what providers need to be build + for k8s_provider in $k8s_providers; do + pushd cluster-provision/k8s/$k8s_provider + ../provision.sh + ../publish.sh + popd + done +} + +#build_and_publish_base_images + +#provision_and_publish_providers pushd cluster-provision/gocli make cli \ @@ -59,12 +67,18 @@ tar -C $workdir -cvzf $ARTIFACTS/kubevirtci.tar.gz . # Install github-release tool # TODO: Vendor this +export GO111MODULE=on +export GOFLAGS="" go get github.com/github-release/github-release@v0.8.1 # Create the release -tag $(git rev-parse --short HEAD) +tag="v0.0.1" +org=kubevirt + +git tag $tag +git push git@github.com:$org/kubevirtci.git $tag github-release release \ - -u kubevirt \ + -u $org \ -r kubevirtci \ --tag $tag \ --name $tag \ @@ -72,7 +86,7 @@ github-release release \ # Upload tarball github-release upload \ - -u kubevirt \ + -u $org \ -r kubevirtci \ --name kubevirtci.tar.gz \ --tag $tag\ From 730023cda26ef14bead3a603a283e24b2e58ea0c Mon Sep 17 00:00:00 2001 From: Quique Llorente Date: Thu, 23 Jul 2020 15:35:41 +0200 Subject: [PATCH 13/15] Check remotes Signed-off-by: Quique Llorente --- automation/release.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/automation/release.sh b/automation/release.sh index 9fc90928db..24e96dc47a 100755 --- a/automation/release.sh +++ b/automation/release.sh @@ -76,6 +76,9 @@ tag="v0.0.1" org=kubevirt git tag $tag + +git remote -v + git push git@github.com:$org/kubevirtci.git $tag github-release release \ -u $org \ From de3123a46d62a8e3972e0619ac6fbb9c48c50872 Mon Sep 17 00:00:00 2001 From: Quique Llorente Date: Fri, 24 Jul 2020 08:26:08 +0200 Subject: [PATCH 14/15] Tag with epoch and push using https Signed-off-by: Quique Llorente --- automation/release.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/automation/release.sh b/automation/release.sh index 24e96dc47a..6ba53979a9 100755 --- a/automation/release.sh +++ b/automation/release.sh @@ -72,14 +72,17 @@ export GOFLAGS="" go get github.com/github-release/github-release@v0.8.1 # Create the release -tag="v0.0.1" +tag=$(date +%s) org=kubevirt git tag $tag -git remote -v +# To pass user/password from automations, idea is taken from [1] +# [1] https://stackoverflow.com/questions/8536732/can-i-hold-git-credentials-in-environment-variables +git config credential.helper '!f() { sleep 1; echo "username=${GITHUB_USER}"; echo "password=${GITHUB_TOKEN}"; }; f' -git push git@github.com:$org/kubevirtci.git $tag + +git push https://github.com/$org/kubevirtci.git $tag github-release release \ -u $org \ -r kubevirtci \ From cc9ecdf477fc871a898f5690a721f14884673682 Mon Sep 17 00:00:00 2001 From: Quique Llorente Date: Fri, 24 Jul 2020 11:04:07 +0200 Subject: [PATCH 15/15] Populate base and providers Signed-off-by: Quique Llorente --- automation/release.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/automation/release.sh b/automation/release.sh index 6ba53979a9..4b062b42cf 100755 --- a/automation/release.sh +++ b/automation/release.sh @@ -40,9 +40,9 @@ function provision_and_publish_providers() { done } -#build_and_publish_base_images +build_and_publish_base_images -#provision_and_publish_providers +provision_and_publish_providers pushd cluster-provision/gocli make cli \ @@ -82,7 +82,7 @@ git tag $tag git config credential.helper '!f() { sleep 1; echo "username=${GITHUB_USER}"; echo "password=${GITHUB_TOKEN}"; }; f' -git push https://github.com/$org/kubevirtci.git $tag +git push https://github.com/$org/kubevirtci $tag github-release release \ -u $org \ -r kubevirtci \