From e80b6900030c786d6ae79b89df98e75b6b1c6441 Mon Sep 17 00:00:00 2001 From: shubham Date: Fri, 24 Jul 2020 12:11:13 +0530 Subject: [PATCH] chore(migrate): add travis sanity test Signed-off-by: shubham --- .travis.yml | 20 +- ci/migrate/application.tmp.yaml | 126 ++++++ ci/migrate/openebs-operator.yaml | 754 +++++++++++++++++++++++++++++++ ci/migrate/pool.yaml | 36 ++ ci/migrate/sanity.sh | 8 + ci/migrate/setup.sh | 33 ++ ci/migrate/test.sh | 30 ++ ci/migrate/volume.tmp.yaml | 38 ++ 8 files changed, 1044 insertions(+), 1 deletion(-) create mode 100644 ci/migrate/application.tmp.yaml create mode 100644 ci/migrate/openebs-operator.yaml create mode 100644 ci/migrate/pool.yaml create mode 100755 ci/migrate/sanity.sh create mode 100755 ci/migrate/setup.sh create mode 100755 ci/migrate/test.sh create mode 100644 ci/migrate/volume.tmp.yaml diff --git a/.travis.yml b/.travis.yml index 8cbca670..05e11c1f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,12 @@ go: env: global: - ARCH=$(go env GOARCH) + - CHANGE_MINIKUBE_NONE_USER=true + - MINIKUBE_WANTUPDATENOTIFICATION=false + - MINIKUBE_WANTREPORTERRORPROMPT=false + - MINIKUBE_HOME=$HOME + - CHANGE_MINIKUBE_NONE_USER=true + - KUBECONFIG=$HOME/.kube/config sudo: required @@ -33,12 +39,24 @@ install: before_script: # TODO add golangci yaml config - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.25.0 + - if [ "$TRAVIS_CPU_ARCH" == "amd64" ]; then + curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.18.1/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/; + curl -Lo minikube https://storage.googleapis.com/minikube/releases/v1.8.1/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/; + mkdir -p $HOME/.kube $HOME/.minikube; + touch $KUBECONFIG; + sudo minikube start --vm-driver=none --kubernetes-version=v1.16.0; + sudo chown -R travis /home/travis/.minikube/; + JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 1; done; + fi` script: - make test - if [ "$TRAVIS_CPU_ARCH" == "amd64" ]; then - make all.amd64; + make all.amd64 || exit 1; fi + # run cstor v1 migration sanity test + - ./ci/migrate/sanity.sh + after_success: - make deploy-images diff --git a/ci/migrate/application.tmp.yaml b/ci/migrate/application.tmp.yaml new file mode 100644 index 00000000..6230747a --- /dev/null +++ b/ci/migrate/application.tmp.yaml @@ -0,0 +1,126 @@ +--- +#Use the following YAMLs to create a cStor Storage Pool. +apiVersion: openebs.io/v1alpha1 +kind: StoragePoolClaim +metadata: + name: sparse-claim + annotations: + cas.openebs.io/config: | + - name: PoolResourceRequests + value: |- + memory: 2Gi + - name: PoolResourceLimits + value: |- + memory: 4Gi +spec: + name: sparse-claim + type: sparse + poolSpec: + poolType: striped + blockDevices: + blockDeviceList: + - SPCBD +--- +apiVersion: storage.k8s.io/v1 +kind: StorageClass +metadata: + name: openebs-cstor-sparse + annotations: + openebs.io/cas-type: cstor + cas.openebs.io/config: | + - name: StoragePoolClaim + value: "sparse-claim" + - name: ReplicaCount + value: "1" + - name: TargetResourceLimits + value: |- + memory: 1Gi + cpu: 200m + - name: TargetResourceRequests + value: |- + memory: 500Mi + cpu: 100m + - name: AuxResourceLimits + value: |- + memory: 1Gi + cpu: 200m + - name: AuxResourceRequests + value: |- + memory: 500Mi + cpu: 100m + - name: TargetTolerations + value: |- + t1: + key: "key1" + operator: "Equal" + value: "value1" + effect: "NoSchedule" + t2: + key: "key1" + operator: "Equal" + value: "value1" + effect: "NoExecute" + - name: TargetNodeSelector + value: |- + nodetype: storage + - name: QueueDepth + value: "32" + - name: Luworkers + value: "6" + - name: ZvolWorkers + value: "1" +provisioner: openebs.io/provisioner-iscsi +--- +apiVersion: v1 +kind: Service +metadata: + labels: + lkey: lvalue + name: busybox +spec: + clusterIP: None + selector: + lkey: lvalue +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: busybox + labels: + lkey: lvalue +spec: + serviceName: busybox + replicas: 1 + selector: + matchLabels: + lkey: lvalue + #The Label "openebs.io/replica-anti-affinity" + #needs to be added in order to distribute volume replicas. + affinity_label: busybox + template: + metadata: + labels: + lkey: lvalue + affinity_label: busybox + spec: + containers: + - name: busybox + image: busybox + imagePullPolicy: IfNotPresent + command: + - sh + - -c + - 'date > /busybox/date.txt; sync; sleep 5; sync; tail -f /dev/null;' + volumeMounts: + - name: testclaim + mountPath: /busybox + volumeClaimTemplates: + - metadata: + name: testclaim + spec: + accessModes: [ "ReadWriteOnce" ] + storageClassName: openebs-cstor-sparse + resources: + requests: + storage: 2G + diff --git a/ci/migrate/openebs-operator.yaml b/ci/migrate/openebs-operator.yaml new file mode 100644 index 00000000..71cf6bf3 --- /dev/null +++ b/ci/migrate/openebs-operator.yaml @@ -0,0 +1,754 @@ +# This manifest deploys the OpenEBS control plane components, with associated CRs & RBAC rules +# NOTE: On GKE, deploy the openebs-operator.yaml in admin context + +# Create the OpenEBS namespace +apiVersion: v1 +kind: Namespace +metadata: + name: openebs +--- +# Create Maya Service Account +apiVersion: v1 +kind: ServiceAccount +metadata: + name: openebs-maya-operator + namespace: openebs +--- +# Define Role that allows operations on K8s pods/deployments +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1beta1 +metadata: + name: openebs-maya-operator +rules: +- apiGroups: ["*"] + resources: ["nodes", "nodes/proxy"] + verbs: ["*"] +- apiGroups: ["*"] + resources: ["namespaces", "services", "pods", "pods/exec", "deployments", "deployments/finalizers", "replicationcontrollers", "replicasets", "events", "endpoints", "configmaps", "secrets", "jobs", "cronjobs"] + verbs: ["*"] +- apiGroups: ["*"] + resources: ["statefulsets", "daemonsets"] + verbs: ["*"] +- apiGroups: ["*"] + resources: ["resourcequotas", "limitranges"] + verbs: ["list", "watch"] +- apiGroups: ["*"] + resources: ["ingresses", "horizontalpodautoscalers", "verticalpodautoscalers", "certificatesigningrequests"] + verbs: ["list", "watch"] +- apiGroups: ["*"] + resources: ["storageclasses", "persistentvolumeclaims", "persistentvolumes"] + verbs: ["*"] +- apiGroups: ["volumesnapshot.external-storage.k8s.io"] + resources: ["volumesnapshots", "volumesnapshotdatas"] + verbs: ["get", "list", "watch", "create", "update", "patch", "delete"] +- apiGroups: ["apiextensions.k8s.io"] + resources: ["customresourcedefinitions"] + verbs: [ "get", "list", "create", "update", "delete", "patch"] +- apiGroups: ["openebs.io"] + resources: [ "*"] + verbs: ["*" ] +- apiGroups: ["cstor.openebs.io"] + resources: [ "*"] + verbs: ["*" ] +- apiGroups: ["coordination.k8s.io"] + resources: ["leases"] + verbs: ["get", "watch", "list", "delete", "update", "create"] +- apiGroups: ["admissionregistration.k8s.io"] + resources: ["validatingwebhookconfigurations", "mutatingwebhookconfigurations"] + verbs: ["get", "create", "list", "delete", "update", "patch"] +- nonResourceURLs: ["/metrics"] + verbs: ["get"] +- apiGroups: ["*"] + resources: ["poddisruptionbudgets"] + verbs: ["get", "list", "create", "delete", "watch"] +--- +# Bind the Service Account with the Role Privileges. +# TODO: Check if default account also needs to be there +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1beta1 +metadata: + name: openebs-maya-operator +subjects: +- kind: ServiceAccount + name: openebs-maya-operator + namespace: openebs +roleRef: + kind: ClusterRole + name: openebs-maya-operator + apiGroup: rbac.authorization.k8s.io +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: maya-apiserver + namespace: openebs + labels: + name: maya-apiserver + openebs.io/component-name: maya-apiserver + openebs.io/version: 1.11.0 +spec: + selector: + matchLabels: + name: maya-apiserver + openebs.io/component-name: maya-apiserver + replicas: 1 + strategy: + type: Recreate + rollingUpdate: null + template: + metadata: + labels: + name: maya-apiserver + openebs.io/component-name: maya-apiserver + openebs.io/version: 1.11.0 + spec: + serviceAccountName: openebs-maya-operator + containers: + - name: maya-apiserver + imagePullPolicy: IfNotPresent + image: quay.io/openebs/m-apiserver:1.11.0 + ports: + - containerPort: 5656 + env: + # OPENEBS_IO_KUBE_CONFIG enables maya api service to connect to K8s + # based on this config. This is ignored if empty. + # This is supported for maya api server version 0.5.2 onwards + #- name: OPENEBS_IO_KUBE_CONFIG + # value: "/home/ubuntu/.kube/config" + # OPENEBS_IO_K8S_MASTER enables maya api service to connect to K8s + # based on this address. This is ignored if empty. + # This is supported for maya api server version 0.5.2 onwards + #- name: OPENEBS_IO_K8S_MASTER + # value: "http://172.28.128.3:8080" + # OPENEBS_NAMESPACE provides the namespace of this deployment as an + # environment variable + - name: OPENEBS_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + # OPENEBS_SERVICE_ACCOUNT provides the service account of this pod as + # environment variable + - name: OPENEBS_SERVICE_ACCOUNT + valueFrom: + fieldRef: + fieldPath: spec.serviceAccountName + # OPENEBS_MAYA_POD_NAME provides the name of this pod as + # environment variable + - name: OPENEBS_MAYA_POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + # If OPENEBS_IO_CREATE_DEFAULT_STORAGE_CONFIG is false then OpenEBS default + # storageclass and storagepool will not be created. + - name: OPENEBS_IO_CREATE_DEFAULT_STORAGE_CONFIG + value: "true" + # OPENEBS_IO_INSTALL_DEFAULT_CSTOR_SPARSE_POOL decides whether default cstor sparse pool should be + # configured as a part of openebs installation. + # If "true" a default cstor sparse pool will be configured, if "false" it will not be configured. + # This value takes effect only if OPENEBS_IO_CREATE_DEFAULT_STORAGE_CONFIG + # is set to true + - name: OPENEBS_IO_INSTALL_DEFAULT_CSTOR_SPARSE_POOL + value: "false" + # OPENEBS_IO_INSTALL_CRD environment variable is used to enable/disable CRD installation + # from Maya API server. By default the CRDs will be installed + # - name: OPENEBS_IO_INSTALL_CRD + # value: "true" + # 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 + # to be used for saving the shared content between the side cars + # of cstor volume pod. + # The default path used is /var/openebs/sparse + #- name: OPENEBS_IO_CSTOR_TARGET_DIR + # value: "/var/openebs/sparse" + # 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" + # OPENEBS_IO_JIVA_POOL_DIR can be used to specify the hostpath + # to be used for default Jiva StoragePool loaded by OpenEBS + # The default path used is /var/openebs + # This value takes effect only if OPENEBS_IO_CREATE_DEFAULT_STORAGE_CONFIG + # is set to true + #- name: OPENEBS_IO_JIVA_POOL_DIR + # value: "/var/openebs" + # OPENEBS_IO_LOCALPV_HOSTPATH_DIR can be used to specify the hostpath + # to be used for default openebs-hostpath storageclass loaded by OpenEBS + # The default path used is /var/openebs/local + # This value takes effect only if OPENEBS_IO_CREATE_DEFAULT_STORAGE_CONFIG + # is set to true + #- name: OPENEBS_IO_LOCALPV_HOSTPATH_DIR + # value: "/var/openebs/local" + - name: OPENEBS_IO_JIVA_CONTROLLER_IMAGE + value: "quay.io/openebs/jiva:1.11.0" + - name: OPENEBS_IO_JIVA_REPLICA_IMAGE + value: "quay.io/openebs/jiva:1.11.0" + - name: OPENEBS_IO_JIVA_REPLICA_COUNT + value: "3" + - name: OPENEBS_IO_CSTOR_TARGET_IMAGE + value: "quay.io/openebs/cstor-istgt:1.11.0" + - name: OPENEBS_IO_CSTOR_POOL_IMAGE + value: "quay.io/openebs/cstor-pool:1.11.0" + - name: OPENEBS_IO_CSTOR_POOL_MGMT_IMAGE + value: "quay.io/openebs/cstor-pool-mgmt:1.11.0" + - name: OPENEBS_IO_CSTOR_VOLUME_MGMT_IMAGE + value: "quay.io/openebs/cstor-volume-mgmt:1.11.0" + - name: OPENEBS_IO_VOLUME_MONITOR_IMAGE + value: "quay.io/openebs/m-exporter:1.11.0" + - name: OPENEBS_IO_CSTOR_POOL_EXPORTER_IMAGE + value: "quay.io/openebs/m-exporter:1.11.0" + - name: OPENEBS_IO_HELPER_IMAGE + value: "quay.io/openebs/linux-utils:1.11.0" + # OPENEBS_IO_ENABLE_ANALYTICS if set to true sends anonymous usage + # events to Google Analytics + - name: OPENEBS_IO_ENABLE_ANALYTICS + value: "true" + - name: OPENEBS_IO_INSTALLER_TYPE + value: "openebs-operator" + # OPENEBS_IO_ANALYTICS_PING_INTERVAL can be used to specify the duration (in hours) + # for periodic ping events sent to Google Analytics. + # Default is 24h. + # Minimum is 1h. You can convert this to weekly by setting 168h + #- name: OPENEBS_IO_ANALYTICS_PING_INTERVAL + # value: "24h" + livenessProbe: + exec: + command: + - /usr/local/bin/mayactl + - version + initialDelaySeconds: 30 + periodSeconds: 60 + readinessProbe: + exec: + command: + - /usr/local/bin/mayactl + - version + initialDelaySeconds: 30 + periodSeconds: 60 +--- +apiVersion: v1 +kind: Service +metadata: + name: maya-apiserver-service + namespace: openebs + labels: + openebs.io/component-name: maya-apiserver-svc +spec: + ports: + - name: api + port: 5656 + protocol: TCP + targetPort: 5656 + selector: + name: maya-apiserver + sessionAffinity: None +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: openebs-provisioner + namespace: openebs + labels: + name: openebs-provisioner + openebs.io/component-name: openebs-provisioner + openebs.io/version: 1.11.0 +spec: + selector: + matchLabels: + name: openebs-provisioner + openebs.io/component-name: openebs-provisioner + replicas: 1 + strategy: + type: Recreate + rollingUpdate: null + template: + metadata: + labels: + name: openebs-provisioner + openebs.io/component-name: openebs-provisioner + openebs.io/version: 1.11.0 + spec: + serviceAccountName: openebs-maya-operator + containers: + - name: openebs-provisioner + imagePullPolicy: IfNotPresent + image: quay.io/openebs/openebs-k8s-provisioner:1.11.0 + env: + # OPENEBS_IO_K8S_MASTER enables openebs provisioner to connect to K8s + # based on this address. This is ignored if empty. + # This is supported for openebs provisioner version 0.5.2 onwards + #- name: OPENEBS_IO_K8S_MASTER + # value: "http://10.128.0.12:8080" + # OPENEBS_IO_KUBE_CONFIG enables openebs provisioner to connect to K8s + # based on this config. This is ignored if empty. + # This is supported for openebs provisioner version 0.5.2 onwards + #- name: OPENEBS_IO_KUBE_CONFIG + # value: "/home/ubuntu/.kube/config" + - name: NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: OPENEBS_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + # OPENEBS_MAYA_SERVICE_NAME provides the maya-apiserver K8s service name, + # that provisioner should forward the volume create/delete requests. + # If not present, "maya-apiserver-service" will be used for lookup. + # This is supported for openebs provisioner version 0.5.3-RC1 onwards + #- name: OPENEBS_MAYA_SERVICE_NAME + # value: "maya-apiserver-apiservice" + # Process name used for matching is limited to the 15 characters + # present in the pgrep output. + # So fullname can't be used here with pgrep (>15 chars).A regular expression + # that matches the entire command name has to specified. + # Anchor `^` : matches any string that starts with `openebs-provis` + # `.*`: matches any string that has `openebs-provis` followed by zero or more char + livenessProbe: + exec: + command: + - sh + - -c + - test `pgrep -c "^openebs-provisi.*"` = 1 + initialDelaySeconds: 30 + periodSeconds: 60 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: openebs-snapshot-operator + namespace: openebs + labels: + name: openebs-snapshot-operator + openebs.io/component-name: openebs-snapshot-operator + openebs.io/version: 1.11.0 +spec: + selector: + matchLabels: + name: openebs-snapshot-operator + openebs.io/component-name: openebs-snapshot-operator + replicas: 1 + strategy: + type: Recreate + template: + metadata: + labels: + name: openebs-snapshot-operator + openebs.io/component-name: openebs-snapshot-operator + openebs.io/version: 1.11.0 + spec: + serviceAccountName: openebs-maya-operator + containers: + - name: snapshot-controller + image: quay.io/openebs/snapshot-controller:1.11.0 + imagePullPolicy: IfNotPresent + env: + - name: OPENEBS_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + # Process name used for matching is limited to the 15 characters + # present in the pgrep output. + # So fullname can't be used here with pgrep (>15 chars).A regular expression + # that matches the entire command name has to specified. + # Anchor `^` : matches any string that starts with `snapshot-contro` + # `.*`: matches any string that has `snapshot-contro` followed by zero or more char + livenessProbe: + exec: + command: + - sh + - -c + - test `pgrep -c "^snapshot-contro.*"` = 1 + initialDelaySeconds: 30 + periodSeconds: 60 + # OPENEBS_MAYA_SERVICE_NAME provides the maya-apiserver K8s service name, + # that snapshot controller should forward the snapshot create/delete requests. + # If not present, "maya-apiserver-service" will be used for lookup. + # This is supported for openebs provisioner version 0.5.3-RC1 onwards + #- name: OPENEBS_MAYA_SERVICE_NAME + # value: "maya-apiserver-apiservice" + - name: snapshot-provisioner + image: quay.io/openebs/snapshot-provisioner:1.11.0 + imagePullPolicy: IfNotPresent + env: + - name: OPENEBS_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + # OPENEBS_MAYA_SERVICE_NAME provides the maya-apiserver K8s service name, + # that snapshot provisioner should forward the clone create/delete requests. + # If not present, "maya-apiserver-service" will be used for lookup. + # This is supported for openebs provisioner version 0.5.3-RC1 onwards + #- name: OPENEBS_MAYA_SERVICE_NAME + # value: "maya-apiserver-apiservice" + # Process name used for matching is limited to the 15 characters + # present in the pgrep output. + # So fullname can't be used here with pgrep (>15 chars).A regular expression + # that matches the entire command name has to specified. + # Anchor `^` : matches any string that starts with `snapshot-provis` + # `.*`: matches any string that has `snapshot-provis` followed by zero or more char + livenessProbe: + exec: + command: + - sh + - -c + - test `pgrep -c "^snapshot-provis.*"` = 1 + initialDelaySeconds: 30 + periodSeconds: 60 +--- +# 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.11.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.11.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.6.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.11.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.11.0 + spec: + serviceAccountName: openebs-maya-operator + containers: + - name: node-disk-operator + image: quay.io/openebs/node-disk-operator-amd64:0.6.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.11.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: apps/v1 +kind: Deployment +metadata: + name: openebs-admission-server + namespace: openebs + labels: + app: admission-webhook + openebs.io/component-name: admission-webhook + openebs.io/version: 1.11.0 +spec: + replicas: 1 + strategy: + type: Recreate + rollingUpdate: null + selector: + matchLabels: + app: admission-webhook + template: + metadata: + labels: + app: admission-webhook + openebs.io/component-name: admission-webhook + openebs.io/version: 1.11.0 + spec: + serviceAccountName: openebs-maya-operator + containers: + - name: admission-webhook + image: quay.io/openebs/admission-server:1.11.0 + imagePullPolicy: IfNotPresent + args: + - -alsologtostderr + - -v=2 + - 2>&1 + env: + - name: OPENEBS_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: ADMISSION_WEBHOOK_NAME + value: "openebs-admission-server" + # Process name used for matching is limited to the 15 characters + # present in the pgrep output. + # So fullname can't be used here with pgrep (>15 chars).A regular expression + # Anchor `^` : matches any string that starts with `admission-serve` + # `.*`: matche any string that has `admission-serve` followed by zero or more char + # that matches the entire command name has to specified. + livenessProbe: + exec: + command: + - sh + - -c + - test `pgrep -c "^admission-serve.*"` = 1 + initialDelaySeconds: 30 + periodSeconds: 60 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: openebs-localpv-provisioner + namespace: openebs + labels: + name: openebs-localpv-provisioner + openebs.io/component-name: openebs-localpv-provisioner + openebs.io/version: 1.11.0 +spec: + selector: + matchLabels: + name: openebs-localpv-provisioner + openebs.io/component-name: openebs-localpv-provisioner + replicas: 1 + strategy: + type: Recreate + template: + metadata: + labels: + name: openebs-localpv-provisioner + openebs.io/component-name: openebs-localpv-provisioner + openebs.io/version: 1.11.0 + spec: + serviceAccountName: openebs-maya-operator + containers: + - name: openebs-provisioner-hostpath + imagePullPolicy: IfNotPresent + image: quay.io/openebs/provisioner-localpv:1.11.0 + env: + # OPENEBS_IO_K8S_MASTER enables openebs provisioner to connect to K8s + # based on this address. This is ignored if empty. + # This is supported for openebs provisioner version 0.5.2 onwards + #- name: OPENEBS_IO_K8S_MASTER + # value: "http://10.128.0.12:8080" + # OPENEBS_IO_KUBE_CONFIG enables openebs provisioner to connect to K8s + # based on this config. This is ignored if empty. + # This is supported for openebs provisioner version 0.5.2 onwards + #- name: OPENEBS_IO_KUBE_CONFIG + # value: "/home/ubuntu/.kube/config" + - name: NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: OPENEBS_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + # OPENEBS_SERVICE_ACCOUNT provides the service account of this pod as + # environment variable + - name: OPENEBS_SERVICE_ACCOUNT + valueFrom: + fieldRef: + fieldPath: spec.serviceAccountName + - name: OPENEBS_IO_ENABLE_ANALYTICS + value: "true" + - name: OPENEBS_IO_INSTALLER_TYPE + value: "openebs-operator" + - name: OPENEBS_IO_HELPER_IMAGE + value: "quay.io/openebs/linux-utils:1.11.0" + # Process name used for matching is limited to the 15 characters + # present in the pgrep output. + # So fullname can't be used here with pgrep (>15 chars).A regular expression + # that matches the entire command name has to specified. + # Anchor `^` : matches any string that starts with `provisioner-loc` + # `.*`: matches any string that has `provisioner-loc` followed by zero or more char + livenessProbe: + exec: + command: + - sh + - -c + - test `pgrep -c "^provisioner-loc.*"` = 1 + initialDelaySeconds: 30 + periodSeconds: 60 +--- + diff --git a/ci/migrate/pool.yaml b/ci/migrate/pool.yaml new file mode 100644 index 00000000..5a7cb4d7 --- /dev/null +++ b/ci/migrate/pool.yaml @@ -0,0 +1,36 @@ +apiVersion: batch/v1 +kind: Job +metadata: + # the name can be of the form migrate- + name: migrate-pool + namespace: openebs +spec: + backoffLimit: 0 + 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: migrate + args: + - "cstor-spc" + # name of the spc that is to be migrated + - "--spc-name=sparse-claim" + # optional flag to rename the spc to a specific name + # - "--cspc-name=sparse-claim-migrated" + #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 version of the image should be same the + # version of cstor-operator installed. + image: openebs/migrate-amd64:ci + restartPolicy: Never diff --git a/ci/migrate/sanity.sh b/ci/migrate/sanity.sh new file mode 100755 index 00000000..ce85ec26 --- /dev/null +++ b/ci/migrate/sanity.sh @@ -0,0 +1,8 @@ +# limitations under the License. + +#!/usr/bin/env bash + +# setup openebs & cstor v1 for migration +./ci/migrate/setup.sh +# run migration tests +./ci/migrate/test.sh \ No newline at end of file diff --git a/ci/migrate/setup.sh b/ci/migrate/setup.sh new file mode 100755 index 00000000..3824eb6c --- /dev/null +++ b/ci/migrate/setup.sh @@ -0,0 +1,33 @@ +# limitations under the License. + +#!/usr/bin/env bash + +set -ex + +echo "Install openebs-operator 1.11.0" + +kubectl apply -f ./ci/migrate/openebs-operator.yaml +sleep 5 + +echo "Wait for maya-apiserver to start" + +kubectl wait --for=condition=available --timeout=600s deployment/maya-apiserver -n openebs + +echo "Label the node" + +kubectl label nodes --all nodetype=storage + +echo "Create application with cStor volume on SPC" + +bdname=$(kubectl -n openebs get blockdevices -o jsonpath='{.items[*].metadata.name}') +sed "s/SPCBD/$bdname/" ./ci/migrate/application.tmp.yaml > ./ci/migrate/application.yaml +kubectl apply -f ./ci/migrate/application.yaml +sleep 5 +kubectl wait --for=condition=Ready pod -l lkey=lvalue --timeout=600s + +echo "Install cstor & csi operators" + +kubectl apply -f https://raw.githubusercontent.com/openebs/charts/gh-pages/csi-operator-ubuntu-18.04.yaml \ + -f https://raw.githubusercontent.com/openebs/charts/gh-pages/cstor-operator.yaml +sleep 5 +kubectl wait --for=condition=available --timeout=600s deployment/cspc-operator -n openebs \ No newline at end of file diff --git a/ci/migrate/test.sh b/ci/migrate/test.sh new file mode 100755 index 00000000..feff61da --- /dev/null +++ b/ci/migrate/test.sh @@ -0,0 +1,30 @@ +# limitations under the License. + +#!/usr/bin/env bash + +set -ex + +echo "Scaling down application before migration" + +kubectl scale statefulset busybox --replicas=0 +kubectl wait --for=delete pod -l lkey=lvalue --timeout=600s + +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 + +echo "Migrating extetnal volume to csi volume" + +pvname=$(kubectl get pvc testclaim-busybox-0 -o jsonpath="{.spec.volumeName}") +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 + +echo "Scaling up application after migration" + +kubectl scale statefulset busybox --replicas=1 +sleep 5 +kubectl wait --for=condition=Ready pod -l lkey=lvalue --timeout=600s \ No newline at end of file diff --git a/ci/migrate/volume.tmp.yaml b/ci/migrate/volume.tmp.yaml new file mode 100644 index 00000000..a7999c29 --- /dev/null +++ b/ci/migrate/volume.tmp.yaml @@ -0,0 +1,38 @@ +--- +apiVersion: batch/v1 +kind: Job +metadata: + # the name can be of the form migrate-cstor- + name: migrate-volume + 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: migrate + args: + - "cstor-volume" + # name of the pv that is to be migrated + - "--pv-name=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 version of the image should be same the + # version of cstor-operator installed. + image: openebs/migrate-amd64:ci + restartPolicy: OnFailure +--- +