diff --git a/.travis.yml b/.travis.yml index 4d278106..4e12c971 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,7 +33,7 @@ jobs: name: "Migrate Sanity" - os: linux arch: amd64 - script: echo "TODO Upgrade Sanity tests" + script: ./ci/upgrade/sanity.sh name: "Upgrade Sanity" - stage: "Deploy Images" os: linux diff --git a/build/build.sh b/build/build.sh index b37ede57..07b75e42 100755 --- a/build/build.sh +++ b/build/build.sh @@ -39,7 +39,34 @@ if [[ -n "$TRAVIS_TAG" ]] && [[ $TRAVIS_TAG != *"RC"* ]]; then fi # Get the version details -VERSION="$(cat $GOPATH/src/github.com/openebs/upgrade/VERSION)" +# Determine the current branch +CURRENT_BRANCH="" +if [ -z "${TRAVIS_BRANCH}" ]; +then + CURRENT_BRANCH=$(git branch | grep "\*" | cut -d ' ' -f2) +else + CURRENT_BRANCH="${TRAVIS_BRANCH}" +fi + +## Populate the version based on release tag +## If travis tag is set then assign it as VERSION and +## if travis tag is empty then mark version as ci +if [ -n "$TRAVIS_TAG" ]; then + # Trim the `v` from the TRAVIS_TAG if it exists + # Example: v1.10.0 maps to 1.10.0 + # Example: 1.10.0 maps to 1.10.0 + # Example: v1.10.0-custom maps to 1.10.0-custom + VERSION="${TRAVIS_TAG#v}" +else + ## Marking VERSION as current_branch-dev + ## Example: master branch maps to master-dev + ## Example: v1.11.x-ee branch to 1.11.x-ee-dev + ## Example: v1.10.x branch to 1.10.x-dev + VERSION="${CURRENT_BRANCH#v}-dev" +fi + +echo "Building for ${VERSION} VERSION" + #VERSION=$(git describe --tags --always --dirty) # Determine the arch/os combos we're building for diff --git a/build/deploy.sh b/build/deploy.sh index 565e2077..c42414b7 100755 --- a/build/deploy.sh +++ b/build/deploy.sh @@ -26,6 +26,9 @@ elif [ "${ARCH}" = "aarch64" ]; then MIGRATE_IMG="${IMAGE_ORG}/migrate-arm64" fi +curl https://raw.githubusercontent.com/openebs/charts/gh-pages/scripts/release/buildscripts/push > ./build/push +chmod +x ./build/push + # tag and push all the images DIMAGE="${UPGRADE_IMG}" ./build/push DIMAGE="${MIGRATE_IMG}" ./build/push \ No newline at end of file diff --git a/build/push b/build/push deleted file mode 100755 index 6f2df84b..00000000 --- a/build/push +++ /dev/null @@ -1,126 +0,0 @@ -#!/bin/bash - -# Copyright 2020 The OpenEBS Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -e - -if [ -z ${DIMAGE} ]; -then - echo "Error: DIMAGE is not specified"; - exit 1 -fi - -IMAGEID=$( sudo docker images -q ${DIMAGE}:ci ) -echo "${DIMAGE}:ci -> $IMAGEID" -if [ -z ${IMAGEID} ]; -then - echo "Error: unable to get IMAGEID for ${DIMAGE}:ci"; - exit 1 -fi - -# Generate a unique tag based on the commit and tag -BUILD_ID=$(git describe --tags --always) - -# Determine the current branch -CURRENT_BRANCH="" -if [ -z ${TRAVIS_BRANCH} ]; -then - CURRENT_BRANCH=$(git branch | grep \* | cut -d ' ' -f2) -else - CURRENT_BRANCH=${TRAVIS_BRANCH} -fi - -# Depending on the branch where builds are generated, -# set the tag CI (fixed) and build tags. -BUILD_TAG="${CURRENT_BRANCH}-${BUILD_ID}" -CI_TAG="${CURRENT_BRANCH}-ci" -if [ ${CURRENT_BRANCH} = "master" ]; then - CI_TAG="ci" -fi - -echo "Set the fixed ci image tag as: ${CI_TAG}" -echo "Set the build/unique image tag as: ${BUILD_TAG}" - -function TagAndPushImage() { - REPO="$1" - - # Trim the `v` from the TAG if it exists - # Example: v1.10.0 maps to 1.10.0 - # Example: 1.10.0 maps to 1.10.0 - # Example: v1.10.0-custom maps to 1.10.0-custom - TAG="${2#v}" - - # Add an option to specify a custom TAG_SUFFIX - # via environment variable. Default is no tag. - # Example suffix could be "-debug" of "-dev" - IMAGE_URI="${REPO}:${TAG}${TAG_SUFFIX}"; - - sudo docker tag ${IMAGEID} ${IMAGE_URI}; - echo " push ${IMAGE_URI}"; - sudo docker push ${IMAGE_URI}; -} - - -if [ ! -z "${DNAME}" ] && [ ! -z "${DPASS}" ]; -then - sudo docker login -u "${DNAME}" -p "${DPASS}"; - - # Push CI tagged image - :ci or :branch-ci - TagAndPushImage "${DIMAGE}" "${CI_TAG}" - - # Push unique tagged image - :master- or :branch- - # This unique/build image will be pushed to corresponding ci repo. - TagAndPushImage "${DIMAGE}-ci" "${BUILD_TAG}" - - if [ ! -z "${TRAVIS_TAG}" ] ; - then - # Push with different tags if tagged as a release - # When github is tagged with a release, then Travis will - # set the release tag in env TRAVIS_TAG - TagAndPushImage "${DIMAGE}" "${TRAVIS_TAG}" - TagAndPushImage "${DIMAGE}" "latest" - fi; -else - echo "No docker credentials provided. Skip uploading ${DIMAGE} to docker hub"; -fi; - -# Push ci image to quay.io for security scanning -if [ ! -z "${QNAME}" ] && [ ! -z "${QPASS}" ]; -then - sudo docker login -u "${QNAME}" -p "${QPASS}" quay.io; - - # Push CI tagged image - :ci or :branch-ci - TagAndPushImage "quay.io/${DIMAGE}" "${CI_TAG}" - - if [ ! -z "${TRAVIS_TAG}" ] ; - then - # Push with different tags if tagged as a release - # When github is tagged with a release, then Travis will - # set the release tag in env TRAVIS_TAG - TagAndPushImage "quay.io/${DIMAGE}" "${TRAVIS_TAG}" - TagAndPushImage "quay.io/${DIMAGE}" "latest" - fi; -else - echo "No docker credentials provided. Skip uploading ${DIMAGE} to quay"; -fi; - -#Push image to run openebs-e2e based on git commit -if [ ! -z "${COMMIT}" ]; -then - sudo docker login -u "${GITLAB_DNAME}" -p "${GITLAB_DPASS}"; - - # Push COMMIT tagged image - :COMMIT - TagAndPushImage "${DIMAGE}" "${COMMIT}" -fi; \ No newline at end of file diff --git a/ci/migrate/sanity.sh b/ci/migrate/sanity.sh index d539aa11..1e899b74 100755 --- a/ci/migrate/sanity.sh +++ b/ci/migrate/sanity.sh @@ -5,8 +5,8 @@ make migrate-image.amd64 # setup openebs & cstor v1 for migration -./ci/migrate/setup.sh +./ci/migrate/setup.sh || exit 1 # run migration tests -./ci/migrate/test.sh +./ci/migrate/test.sh || exit 1 rm ./ci/migrate/volume.yaml ./ci/migrate/application.yaml \ No newline at end of file diff --git a/ci/migrate/test.sh b/ci/migrate/test.sh index d5e57e33..b94a8012 100755 --- a/ci/migrate/test.sh +++ b/ci/migrate/test.sh @@ -14,7 +14,7 @@ echo "Migrating pool to cspc" kubectl apply -f ./ci/migrate/pool.yaml sleep 5 kubectl wait --for=condition=complete job/migrate-pool -n openebs --timeout=800s -kubectl logs -l job-name=migrate-pool -n openebs +kubectl logs --tail=50 -l job-name=migrate-pool -n openebs echo "Migrating extetnal volume to csi volume" @@ -23,7 +23,7 @@ sed "s/PVNAME/$pvname/" ./ci/migrate/volume.tmp.yaml > ./ci/migrate/volume.yaml kubectl apply -f ./ci/migrate/volume.yaml sleep 5 kubectl wait --for=condition=complete job/migrate-volume -n openebs --timeout=800s -kubectl logs -l job-name=migrate-volume -n openebs +kubectl logs --tail=50 -l job-name=migrate-volume -n openebs echo "Scaling up application after migration" diff --git a/ci/upgrade/application.tmp.yaml b/ci/upgrade/application.tmp.yaml new file mode 100644 index 00000000..4ab3264b --- /dev/null +++ b/ci/upgrade/application.tmp.yaml @@ -0,0 +1,100 @@ +apiVersion: cstor.openebs.io/v1 +kind: CStorPoolCluster +metadata: + name: cspc-stripe + namespace: openebs +spec: + pools: + - nodeSelector: + kubernetes.io/hostname: "127.0.0.1" + dataRaidGroups: + - blockDevices: + - blockDeviceName: "CSPCBD" + poolConfig: + dataRaidGroupType: "stripe" +--- +kind: StorageClass +apiVersion: storage.k8s.io/v1 +metadata: + name: openebs-cstor-csi +provisioner: cstor.csi.openebs.io +allowVolumeExpansion: true +parameters: + cas-type: cstor + cstorPoolCluster: cspc-stripe + replicaCount: "1" +--- +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: demo-csi-vol-claim +spec: + storageClassName: openebs-cstor-csi + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 5Gi +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: percona + labels: + lkey: lvalue + openebs.io/target-affinity: percona +spec: + replicas: 1 + selector: + matchLabels: + lkey: lvalue + template: + metadata: + labels: + lkey: lvalue + openebs.io/target-affinity: percona + spec: + containers: + - resources: + limits: + cpu: 0.5 + name: percona + image: openebs/tests-custom-percona:latest + imagePullPolicy: IfNotPresent + args: + - "--ignore-db-dir" + - "lost+found" + env: + - name: MYSQL_ROOT_PASSWORD + value: k8sDem0 + ports: + - containerPort: 3306 + name: percona + volumeMounts: + - mountPath: /var/lib/mysql + name: data-vol + # + livenessProbe: + exec: + command: ["bash", "sql-test.sh"] + initialDelaySeconds: 60 + periodSeconds: 1 + timeoutSeconds: 10 + # + volumes: + - name: data-vol + persistentVolumeClaim: + claimName: demo-csi-vol-claim +--- +apiVersion: v1 +kind: Service +metadata: + name: percona-csi-mysql + labels: + lkey: lvalue +spec: + ports: + - port: 3306 + targetPort: 3306 + selector: + lkey: lvalue diff --git a/ci/upgrade/cstor-operator.tmp.yaml b/ci/upgrade/cstor-operator.tmp.yaml new file mode 100644 index 00000000..63d9de5a --- /dev/null +++ b/ci/upgrade/cstor-operator.tmp.yaml @@ -0,0 +1,176 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: cspc-operator + namespace: openebs + labels: + name: cspc-operator + openebs.io/component-name: cspc-operator + openebs.io/version: testversion +spec: + selector: + matchLabels: + name: cspc-operator + openebs.io/component-name: cspc-operator + replicas: 1 + strategy: + type: Recreate + template: + metadata: + labels: + name: cspc-operator + openebs.io/component-name: cspc-operator + openebs.io/version: testversion + spec: + serviceAccountName: openebs-maya-operator + containers: + - name: cspc-operator + imagePullPolicy: IfNotPresent + image: openebs/cspc-operator-amd64:testimage + env: + - name: OPENEBS_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: OPENEBS_SERVICEACCOUNT_NAME + valueFrom: + fieldRef: + fieldPath: spec.serviceAccountName + - name: CSPC_OPERATOR_POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + # OPENEBS_IO_BASE_DIR is used to configure base directory for openebs on host path. + # Where OpenEBS can store required files. Default base path will be /var/openebs + # - name: OPENEBS_IO_BASE_DIR + # value: "/var/openebs" + # OPENEBS_IO_CSTOR_POOL_SPARSE_DIR can be used to specify the hostpath + # to be used for saving the shared content between the side cars + # of cstor pool pod. This ENV is also used to indicate the location + # of the sparse devices. + # The default path used is /var/openebs/sparse + #- name: OPENEBS_IO_CSTOR_POOL_SPARSE_DIR + # value: "/var/openebs/sparse" + - name: OPENEBS_IO_CSPI_MGMT_IMAGE + value: "openebs/cstor-pool-manager-amd64:testimage" + - name: OPENEBS_IO_CSTOR_POOL_IMAGE + value: "openebs/cstor-pool:testimage" + - name: OPENEBS_IO_CSTOR_POOL_EXPORTER_IMAGE + value: "openebs/m-exporter:testimage" + - name: RESYNC_INTERVAL + value: "30" +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: cvc-operator + namespace: openebs + labels: + name: cvc-operator + openebs.io/component-name: cvc-operator + openebs.io/version: testversion +spec: + selector: + matchLabels: + name: cvc-operator + openebs.io/component-name: cvc-operator + replicas: 1 + strategy: + type: Recreate + template: + metadata: + labels: + name: cvc-operator + openebs.io/component-name: cvc-operator + openebs.io/version: testversion + spec: + serviceAccountName: openebs-maya-operator + containers: + - name: cvc-operator + imagePullPolicy: IfNotPresent + image: openebs/cvc-operator-amd64:testimage + env: + # OPENEBS_IO_BASE_DIR is used to configure base directory for openebs on host path. + # Where OpenEBS can store required files. Default base path will be /var/openebs + # - name: OPENEBS_IO_BASE_DIR + # value: "/var/openebs" + # OPENEBS_IO_CSTOR_TARGET_DIR can be used to specify the hostpath + # that to be used for saving the core dump of cstor volume pod. + # The default path used is /var/openebs/sparse + #- name: OPENEBS_IO_CSTOR_TARGET_DIR + # value: "/var/openebs/sparse" + - name: OPENEBS_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: OPENEBS_SERVICEACCOUNT_NAME + valueFrom: + fieldRef: + fieldPath: spec.serviceAccountName + - name: OPENEBS_IO_CSTOR_TARGET_IMAGE + value: "openebs/cstor-istgt:testimage" + - name: OPENEBS_IO_CSTOR_VOLUME_MGMT_IMAGE + value: "openebs/cstor-volume-manager-amd64:testimage" + - name: OPENEBS_IO_VOLUME_MONITOR_IMAGE + value: "openebs/m-exporter:testimage" +--- +apiVersion: v1 +kind: Service +metadata: + name: cvc-operator-service + namespace: openebs + labels: + openebs.io/component-name: cvc-operator-svc +spec: + ports: + - name: api + port: 5757 + protocol: TCP + targetPort: 5757 + selector: + name: cvc-operator + sessionAffinity: None +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: openebs-cstor-admission-server + namespace: openebs + labels: + app: cstor-admission-webhook + openebs.io/component-name: cstor-admission-webhook + openebs.io/version: testversion +spec: + replicas: 1 + strategy: + type: Recreate + rollingUpdate: null + selector: + matchLabels: + app: cstor-admission-webhook + template: + metadata: + labels: + app: cstor-admission-webhook + openebs.io/component-name: cstor-admission-webhook + openebs.io/version: testversion + spec: + serviceAccountName: openebs-maya-operator + containers: + - name: admission-webhook + image: openebs/cstor-webhook-amd64:testimage + imagePullPolicy: IfNotPresent + args: + - -alsologtostderr + - -v=2 + - 2>&1 + env: + - name: OPENEBS_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: ADMISSION_WEBHOOK_NAME + value: "openebs-cstor-admission-server" + - name: ADMISSION_WEBHOOK_FAILURE_POLICY + value: "Fail" diff --git a/ci/upgrade/cstor-operator.yaml b/ci/upgrade/cstor-operator.yaml new file mode 100644 index 00000000..5c02258a --- /dev/null +++ b/ci/upgrade/cstor-operator.yaml @@ -0,0 +1,176 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: cspc-operator + namespace: openebs + labels: + name: cspc-operator + openebs.io/component-name: cspc-operator + openebs.io/version: 1.12.0-RC1 +spec: + selector: + matchLabels: + name: cspc-operator + openebs.io/component-name: cspc-operator + replicas: 1 + strategy: + type: Recreate + template: + metadata: + labels: + name: cspc-operator + openebs.io/component-name: cspc-operator + openebs.io/version: 1.12.0-RC1 + spec: + serviceAccountName: openebs-maya-operator + containers: + - name: cspc-operator + imagePullPolicy: IfNotPresent + image: openebs/cspc-operator-amd64:1.12.0-RC1 + env: + - name: OPENEBS_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: OPENEBS_SERVICEACCOUNT_NAME + valueFrom: + fieldRef: + fieldPath: spec.serviceAccountName + - name: CSPC_OPERATOR_POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + # OPENEBS_IO_BASE_DIR is used to configure base directory for openebs on host path. + # Where OpenEBS can store required files. Default base path will be /var/openebs + # - name: OPENEBS_IO_BASE_DIR + # value: "/var/openebs" + # OPENEBS_IO_CSTOR_POOL_SPARSE_DIR can be used to specify the hostpath + # to be used for saving the shared content between the side cars + # of cstor pool pod. This ENV is also used to indicate the location + # of the sparse devices. + # The default path used is /var/openebs/sparse + #- name: OPENEBS_IO_CSTOR_POOL_SPARSE_DIR + # value: "/var/openebs/sparse" + - name: OPENEBS_IO_CSPI_MGMT_IMAGE + value: "openebs/cstor-pool-manager-amd64:1.12.0-RC1" + - name: OPENEBS_IO_CSTOR_POOL_IMAGE + value: "openebs/cstor-pool:1.12.0-RC1" + - name: OPENEBS_IO_CSTOR_POOL_EXPORTER_IMAGE + value: "openebs/m-exporter:1.12.0-RC1" + - name: RESYNC_INTERVAL + value: "30" +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: cvc-operator + namespace: openebs + labels: + name: cvc-operator + openebs.io/component-name: cvc-operator + openebs.io/version: 1.12.0-RC1 +spec: + selector: + matchLabels: + name: cvc-operator + openebs.io/component-name: cvc-operator + replicas: 1 + strategy: + type: Recreate + template: + metadata: + labels: + name: cvc-operator + openebs.io/component-name: cvc-operator + openebs.io/version: 1.12.0-RC1 + spec: + serviceAccountName: openebs-maya-operator + containers: + - name: cvc-operator + imagePullPolicy: IfNotPresent + image: openebs/cvc-operator-amd64:1.12.0-RC1 + env: + # OPENEBS_IO_BASE_DIR is used to configure base directory for openebs on host path. + # Where OpenEBS can store required files. Default base path will be /var/openebs + # - name: OPENEBS_IO_BASE_DIR + # value: "/var/openebs" + # OPENEBS_IO_CSTOR_TARGET_DIR can be used to specify the hostpath + # that to be used for saving the core dump of cstor volume pod. + # The default path used is /var/openebs/sparse + #- name: OPENEBS_IO_CSTOR_TARGET_DIR + # value: "/var/openebs/sparse" + - name: OPENEBS_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: OPENEBS_SERVICEACCOUNT_NAME + valueFrom: + fieldRef: + fieldPath: spec.serviceAccountName + - name: OPENEBS_IO_CSTOR_TARGET_IMAGE + value: "openebs/cstor-istgt:1.12.0-RC1" + - name: OPENEBS_IO_CSTOR_VOLUME_MGMT_IMAGE + value: "openebs/cstor-volume-manager-amd64:1.12.0-RC1" + - name: OPENEBS_IO_VOLUME_MONITOR_IMAGE + value: "openebs/m-exporter:1.12.0-RC1" +--- +apiVersion: v1 +kind: Service +metadata: + name: cvc-operator-service + namespace: openebs + labels: + openebs.io/component-name: cvc-operator-svc +spec: + ports: + - name: api + port: 5757 + protocol: TCP + targetPort: 5757 + selector: + name: cvc-operator + sessionAffinity: None +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: openebs-cstor-admission-server + namespace: openebs + labels: + app: cstor-admission-webhook + openebs.io/component-name: cstor-admission-webhook + openebs.io/version: 1.12.0-RC1 +spec: + replicas: 1 + strategy: + type: Recreate + rollingUpdate: null + selector: + matchLabels: + app: cstor-admission-webhook + template: + metadata: + labels: + app: cstor-admission-webhook + openebs.io/component-name: cstor-admission-webhook + openebs.io/version: 1.12.0-RC1 + spec: + serviceAccountName: openebs-maya-operator + containers: + - name: admission-webhook + image: openebs/cstor-webhook-amd64:1.12.0-RC1 + imagePullPolicy: IfNotPresent + args: + - -alsologtostderr + - -v=2 + - 2>&1 + env: + - name: OPENEBS_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: ADMISSION_WEBHOOK_NAME + value: "openebs-cstor-admission-server" + - name: ADMISSION_WEBHOOK_FAILURE_POLICY + value: "Fail" diff --git a/ci/upgrade/ndm-operator.yaml b/ci/upgrade/ndm-operator.yaml new file mode 100644 index 00000000..5c3904c6 --- /dev/null +++ b/ci/upgrade/ndm-operator.yaml @@ -0,0 +1,242 @@ +# This is the node-disk-manager related config. +# It can be used to customize the disks probes and filters +apiVersion: v1 +kind: ConfigMap +metadata: + name: openebs-ndm-config + namespace: openebs + labels: + openebs.io/component-name: ndm-config +data: + # udev-probe is default or primary probe which should be enabled to run ndm + # filterconfigs contails configs of filters - in their form fo include + # and exclude comma separated strings + node-disk-manager.config: | + probeconfigs: + - key: udev-probe + name: udev probe + state: true + - key: seachest-probe + name: seachest probe + state: false + - key: smart-probe + name: smart probe + state: true + filterconfigs: + - key: os-disk-exclude-filter + name: os disk exclude filter + state: true + exclude: "/,/etc/hosts,/boot" + - key: vendor-filter + name: vendor filter + state: true + include: "" + exclude: "CLOUDBYT,OpenEBS" + - key: path-filter + name: path filter + state: true + include: "" + exclude: "loop,/dev/fd0,/dev/sr0,/dev/ram,/dev/dm-,/dev/md,/dev/rbd" +--- +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: openebs-ndm + namespace: openebs + labels: + name: openebs-ndm + openebs.io/component-name: ndm + openebs.io/version: 1.10.0 +spec: + selector: + matchLabels: + name: openebs-ndm + openebs.io/component-name: ndm + updateStrategy: + type: RollingUpdate + template: + metadata: + labels: + name: openebs-ndm + openebs.io/component-name: ndm + openebs.io/version: 1.10.0 + spec: + # By default the node-disk-manager will be run on all kubernetes nodes + # If you would like to limit this to only some nodes, say the nodes + # that have storage attached, you could label those node and use + # nodeSelector. + # + # e.g. label the storage nodes with - "openebs.io/nodegroup"="storage-node" + # kubectl label node "openebs.io/nodegroup"="storage-node" + #nodeSelector: + # "openebs.io/nodegroup": "storage-node" + serviceAccountName: openebs-maya-operator + hostNetwork: true + containers: + - name: node-disk-manager + image: quay.io/openebs/node-disk-manager-amd64:0.5.0 + args: + - -v=4 + # The feature-gate is used to enable the new UUID algorithm. + # This is a feature currently in Alpha state + # - --feature-gates="GPTBasedUUID" + imagePullPolicy: IfNotPresent + securityContext: + privileged: true + volumeMounts: + - name: config + mountPath: /host/node-disk-manager.config + subPath: node-disk-manager.config + readOnly: true + - name: udev + mountPath: /run/udev + - name: procmount + mountPath: /host/proc + readOnly: true + - name: basepath + mountPath: /var/openebs/ndm + - name: sparsepath + mountPath: /var/openebs/sparse + env: + # namespace in which NDM is installed will be passed to NDM Daemonset + # as environment variable + - name: NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + # pass hostname as env variable using downward API to the NDM container + - name: NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + # specify the directory where the sparse files need to be created. + # if not specified, then sparse files will not be created. + - name: SPARSE_FILE_DIR + value: "/var/openebs/sparse" + # Size(bytes) of the sparse file to be created. + - name: SPARSE_FILE_SIZE + value: "10737418240" + # Specify the number of sparse files to be created + - name: SPARSE_FILE_COUNT + value: "1" + livenessProbe: + exec: + command: + - pgrep + - "ndm" + initialDelaySeconds: 30 + periodSeconds: 60 + volumes: + - name: config + configMap: + name: openebs-ndm-config + - name: udev + hostPath: + path: /run/udev + type: Directory + # mount /proc (to access mount file of process 1 of host) inside container + # to read mount-point of disks and partitions + - name: procmount + hostPath: + path: /proc + type: Directory + - name: basepath + hostPath: + path: /var/openebs/ndm + type: DirectoryOrCreate + - name: sparsepath + hostPath: + path: /var/openebs/sparse +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: openebs-ndm-operator + namespace: openebs + labels: + name: openebs-ndm-operator + openebs.io/component-name: ndm-operator + openebs.io/version: 1.10.0 +spec: + selector: + matchLabels: + name: openebs-ndm-operator + openebs.io/component-name: ndm-operator + replicas: 1 + strategy: + type: Recreate + template: + metadata: + labels: + name: openebs-ndm-operator + openebs.io/component-name: ndm-operator + openebs.io/version: 1.10.0 + spec: + serviceAccountName: openebs-maya-operator + containers: + - name: node-disk-operator + image: quay.io/openebs/node-disk-operator-amd64:0.5.0 + imagePullPolicy: IfNotPresent + readinessProbe: + exec: + command: + - stat + - /tmp/operator-sdk-ready + initialDelaySeconds: 4 + periodSeconds: 10 + failureThreshold: 1 + env: + - name: WATCH_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + # the service account of the ndm-operator pod + - name: SERVICE_ACCOUNT + valueFrom: + fieldRef: + fieldPath: spec.serviceAccountName + - name: OPERATOR_NAME + value: "node-disk-operator" + - name: CLEANUP_JOB_IMAGE + value: "quay.io/openebs/linux-utils:1.10.0" + # OPENEBS_IO_INSTALL_CRD environment variable is used to enable/disable CRD installation + # from NDM operator. By default the CRDs will be installed + #- name: OPENEBS_IO_INSTALL_CRD + # value: "true" + # Process name used for matching is limited to the 15 characters + # present in the pgrep output. + # So fullname can be used here with pgrep (cmd is < 15 chars). + livenessProbe: + exec: + command: + - pgrep + - "ndo" + initialDelaySeconds: 30 + periodSeconds: 60 +--- +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + # name must match the spec fields below, and be in the form: . + name: upgradetasks.openebs.io +spec: + # group name to use for REST API: /apis// + group: openebs.io + # version name to use for REST API: /apis// + version: v1alpha1 + # either Namespaced or Cluster + scope: Namespaced + names: + # plural name to be used in the URL: /apis/// + plural: upgradetasks + # singular name to be used as an alias on the CLI and for display + singular: upgradetask + # kind is normally the CamelCased singular type. Your resource manifests use this. + kind: UpgradeTask + # shortNames allow shorter string to match your resource on the CLI + shortNames: + - utask \ No newline at end of file diff --git a/ci/upgrade/pool.tmp.yaml b/ci/upgrade/pool.tmp.yaml new file mode 100644 index 00000000..d5fbb444 --- /dev/null +++ b/ci/upgrade/pool.tmp.yaml @@ -0,0 +1,65 @@ +# This is an example YAML for upgrading cstor CSPC. +# Some of the values below needs to be changed to +# match your openebs installation. The fields are +# indicated with VERIFY +--- +apiVersion: batch/v1 +kind: Job +metadata: + # VERIFY that you have provided a unique name for this upgrade job. + # The name can be any valid K8s string for name. + name: upgrade-pool + + # VERIFY the value of namespace is same as the namespace where openebs components + # are installed. You can verify using the command: + # `kubectl get pods -n -l openebs.io/component-name=maya-apiserver` + # The above command should return status of the openebs-apiserver. + namespace: openebs +spec: + backoffLimit: 4 + template: + spec: + # VERIFY the value of serviceAccountName is pointing to service account + # created within openebs namespace. Use the non-default account. + # by running `kubectl get sa -n ` + serviceAccountName: openebs-maya-operator + containers: + - name: upgrade + args: + - "cstor-cspc" + + # --from-version is the current version of the pool + - "--from-version=1.10.0" + + # --to-version is the version desired upgrade version + - "--to-version=testversion" + # if required the image prefix of the pool deployments can be + # changed using the flag below, defaults to whatever was present on old + # deployments. + #- "--to-version-image-prefix=openebs/" + # if required the image tags for pool deployments can be changed + # to a custom image tag using the flag below, + # defaults to the --to-version mentioned above. + - "--to-version-image-tag=testimage" + + # VERIFY that you have provided the correct list of CSPC Names + - "cspc-stripe" + + # Following are optional parameters + # Log Level + - "--v=4" + # DO NOT CHANGE BELOW PARAMETERS + env: + - name: OPENEBS_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + tty: true + + # the image version should be same as the --to-version mentioned above + # in the args of the job + image: openebs/upgrade-amd64:ci + imagePullPolicy: IfNotPresent + restartPolicy: OnFailure +--- + diff --git a/ci/upgrade/pool.yaml b/ci/upgrade/pool.yaml new file mode 100644 index 00000000..c75b9398 --- /dev/null +++ b/ci/upgrade/pool.yaml @@ -0,0 +1,65 @@ +# This is an example YAML for upgrading cstor CSPC. +# Some of the values below needs to be changed to +# match your openebs installation. The fields are +# indicated with VERIFY +--- +apiVersion: batch/v1 +kind: Job +metadata: + # VERIFY that you have provided a unique name for this upgrade job. + # The name can be any valid K8s string for name. + name: upgrade-pool + + # VERIFY the value of namespace is same as the namespace where openebs components + # are installed. You can verify using the command: + # `kubectl get pods -n -l openebs.io/component-name=maya-apiserver` + # The above command should return status of the openebs-apiserver. + namespace: openebs +spec: + backoffLimit: 4 + template: + spec: + # VERIFY the value of serviceAccountName is pointing to service account + # created within openebs namespace. Use the non-default account. + # by running `kubectl get sa -n ` + serviceAccountName: openebs-maya-operator + containers: + - name: upgrade + args: + - "cstor-cspc" + + # --from-version is the current version of the pool + - "--from-version=1.10.0" + + # --to-version is the version desired upgrade version + - "--to-version=1.12.0-RC1" + # if required the image prefix of the pool deployments can be + # changed using the flag below, defaults to whatever was present on old + # deployments. + #- "--to-version-image-prefix=openebs/" + # if required the image tags for pool deployments can be changed + # to a custom image tag using the flag below, + # defaults to the --to-version mentioned above. + - "--to-version-image-tag=1.12.0-RC1" + + # VERIFY that you have provided the correct list of CSPC Names + - "cspc-stripe" + + # Following are optional parameters + # Log Level + - "--v=4" + # DO NOT CHANGE BELOW PARAMETERS + env: + - name: OPENEBS_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + tty: true + + # the image version should be same as the --to-version mentioned above + # in the args of the job + image: openebs/upgrade-amd64:ci + imagePullPolicy: IfNotPresent + restartPolicy: OnFailure +--- + diff --git a/ci/upgrade/sanity.sh b/ci/upgrade/sanity.sh new file mode 100755 index 00000000..6efeb7c4 --- /dev/null +++ b/ci/upgrade/sanity.sh @@ -0,0 +1,43 @@ +# limitations under the License. + +#!/usr/bin/env bash + +# To enable dev upgardes in travis +make upgrade-image.amd64 + +# To test the sanity in different versioned branches +# and travis tags, get the travis version and corresponding +# image tags +# Determine the current branch +CURRENT_BRANCH="" +if [ -z ${TRAVIS_BRANCH} ]; +then + CURRENT_BRANCH=$(git branch | grep \* | cut -d ' ' -f2) +else + CURRENT_BRANCH=${TRAVIS_BRANCH} +fi + +TEST_IMAGE_TAG="${CURRENT_BRANCH}-ci" +if [ ${CURRENT_BRANCH} = "master" ]; then + TEST_IMAGE_TAG="ci" +fi +TEST_VERSION="${CURRENT_BRANCH}-dev" + +if [ -n "$TRAVIS_TAG" ]; then + # Trim the `v` from the TRAVIS_TAG if it exists + # Example: v1.10.0 maps to 1.10.0 + # Example: 1.10.0 maps to 1.10.0 + # Example: v1.10.0-custom maps to 1.10.0-custom + TEST_IMAGE_TAG="${TRAVIS_TAG#v}" + TEST_VERSION="${TRAVIS_TAG#v}" +fi + +export TEST_IMAGE_TAG=${TEST_IMAGE_TAG#v} +export TEST_VERSION=${TEST_VERSION#v} + +# setup openebs & cstor v1 for migration +./ci/upgrade/setup.sh || exit 1 +# run migration tests +./ci/upgrade/test.sh || exit 1 + +rm ./ci/upgrade/volume.yaml ./ci/upgrade/application.yaml \ No newline at end of file diff --git a/ci/upgrade/setup.sh b/ci/upgrade/setup.sh new file mode 100755 index 00000000..a70b992d --- /dev/null +++ b/ci/upgrade/setup.sh @@ -0,0 +1,35 @@ +# limitations under the License. + +#!/usr/bin/env bash + +set -ex + +echo "Install cstor-operators in 1.10.0" + +kubectl create ns openebs + +kubectl apply -f ./ci/upgrade/ndm-operator.yaml \ + -f https://raw.githubusercontent.com/openebs/charts/master/archive/1.10.x/csi-operator-1.10.0-ubuntu-18.04.yaml \ + -f https://raw.githubusercontent.com/openebs/charts/master/archive/1.10.x/cstor-operator-1.10.0.yaml +sleep 100 + +echo "Wait for cspc-operator to start" + +kubectl wait --for=condition=available --timeout=600s deployment/cspc-operator -n openebs + +echo "Create application with cStor volume on CSPC" + +bdname=$(kubectl -n openebs get blockdevices -o jsonpath='{.items[*].metadata.name}') +sed "s/CSPCBD/$bdname/" ./ci/upgrade/application.tmp.yaml > ./ci/upgrade/application.yaml +kubectl apply -f ./ci/upgrade/application.yaml +sleep 10 +kubectl wait --for=condition=available --timeout=600s deployment/percona + +echo "Upgrade control plane to latest version" + +sed "s|testimage|$TEST_IMAGE_TAG|g" ./ci/upgrade/cstor-operator.tmp.yaml | sed "s|testversion|$TEST_VERSION|g" > ./ci/upgrade/cstor-operator.yaml + +kubectl apply -f https://raw.githubusercontent.com/openebs/cstor-operators/master/deploy/csi-operator-ubuntu-18.04.yaml \ + -f ./ci/upgrade/cstor-operator.yaml +sleep 10 +kubectl wait --for=condition=available --timeout=600s deployment/cspc-operator -n openebs \ No newline at end of file diff --git a/ci/upgrade/test.sh b/ci/upgrade/test.sh new file mode 100755 index 00000000..941a56d6 --- /dev/null +++ b/ci/upgrade/test.sh @@ -0,0 +1,22 @@ +# limitations under the License. + +#!/usr/bin/env bash + +set -ex + +echo "Upgrading CSPC pool" + +sed "s|testimage|$TEST_IMAGE_TAG|g" ./ci/upgrade/pool.tmp.yaml | sed "s|testversion|$TEST_VERSION|g" > ./ci/upgrade/pool.yaml +kubectl apply -f ./ci/upgrade/pool.yaml +sleep 5 +kubectl wait --for=condition=complete job/upgrade-pool -n openebs --timeout=800s +kubectl logs --tail=50 -l job-name=upgrade-pool -n openebs + +echo "Upgrading CSI volume" + +pvname=$(kubectl get pvc demo-csi-vol-claim -o jsonpath="{.spec.volumeName}") +sed "s|PVNAME|$pvname|g" ./ci/upgrade/volume.tmp.yaml | sed "s|testimage|$TEST_IMAGE_TAG|g" | sed "s|testversion|$TEST_VERSION|g" > ./ci/upgrade/volume.yaml +kubectl apply -f ./ci/upgrade/volume.yaml +sleep 5 +kubectl wait --for=condition=complete job/upgrade-volume -n openebs --timeout=800s +kubectl logs --tail=50 -l job-name=upgrade-volume -n openebs diff --git a/ci/upgrade/volume.tmp.yaml b/ci/upgrade/volume.tmp.yaml new file mode 100644 index 00000000..436bc71e --- /dev/null +++ b/ci/upgrade/volume.tmp.yaml @@ -0,0 +1,65 @@ +# This is an example YAML for upgrading cstor volume. +# Some of the values below needs to be changed to +# match your openebs installation. The fields are +# indicated with VERIFY +--- +apiVersion: batch/v1 +kind: Job +metadata: + # VERIFY that you have provided a unique name for this upgrade job. + # The name can be any valid K8s string for name. + name: upgrade-volume + + # VERIFY the value of namespace is same as the namespace where openebs components + # are installed. You can verify using the command: + # `kubectl get pods -n -l openebs.io/component-name=maya-apiserver` + # The above command should return status of the openebs-apiserver. + namespace: openebs +spec: + backoffLimit: 4 + template: + spec: + # VERIFY the value of serviceAccountName is pointing to service account + # created within openebs namespace. Use the non-default account. + # by running `kubectl get sa -n ` + serviceAccountName: openebs-maya-operator + containers: + - name: upgrade + args: + - "cstor-volume" + + # --from-version is the current version of the volume + - "--from-version=1.10.0" + + # --to-version is the version desired upgrade version + - "--to-version=testversion" + # if required the image prefix of the volume deployments can be + # changed using the flag below, defaults to whatever was present on old + # deployments. + #- "--to-version-image-prefix=openebs/" + # if required the image tags for volume deployments can be changed + # to a custom image tag using the flag below, + # defaults to the --to-version mentioned above. + - "--to-version-image-tag=testimage" + + # VERIFY that you have provided the correct list of volume Names + - "PVNAME" + + # Following are optional parameters + # Log Level + - "--v=4" + # DO NOT CHANGE BELOW PARAMETERS + env: + - name: OPENEBS_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + tty: true + + # the image version should be same as the --to-version mentioned above + # in the args of the job + image: openebs/upgrade-amd64:ci + imagePullPolicy: IfNotPresent + restartPolicy: OnFailure +--- + diff --git a/pkg/version/util.go b/pkg/version/util.go index 33e62575..c8ffb3c5 100644 --- a/pkg/version/util.go +++ b/pkg/version/util.go @@ -7,8 +7,9 @@ import ( var ( validCurrentVersions = map[string]bool{ "1.9.0": true, "1.10.0": true, "1.11.0": true, "1.12.0": true, + "1.13.0": true, } - validDesiredVersion = GetVersion() + validDesiredVersion = strings.Split(GetVersion(), "-")[0] ) // IsCurrentVersionValid verifies if the current version is valid or not