Modify ONAP verify job to include k8s deployment 95/5595/4
authorafenner <andrew.fenner@est.tech>
Fri, 31 Jul 2020 14:15:27 +0000 (15:15 +0100)
committerafenner <andrew.fenner@est.tech>
Fri, 31 Jul 2020 18:04:01 +0000 (19:04 +0100)
create new properties file to set properties so that K8S deployment can be done as part of ONAP deployment using same scripts

Change-Id: I150a42ffb0a04c7763a8389fd05e320de96ac008
Signed-off-by: afenner <andrew.fenner@est.tech>
jjb/cloud-infra/engine-macros.yaml
jjb/cloud-infra/onap-jobs/onap-verify-deploy-test.yaml
jjb/cloud-infra/scripts/generate-k8sdeployment-environment.sh [new file with mode: 0644]

index 9fe9404f64105614c832da38e728616793b99d3d..27381e033370c03b98abc812148a9deb9850a89a 100644 (file)
     builders:
       - shell:
           !include-raw: ./scripts/generate-release-metadata.sh
+- builder:
+    name: 'generate-k8sdeployment-environment-macro'
+    builders:
+      - shell:
+          !include-raw: ./scripts/generate-k8sdeployment-environment.sh          
 
 - builder:
     name: 'promote-macro'
     builders:
       - shell:
           !include-raw: ./scripts/promote.sh
-
index 167bc7655fe144530bd28b19d2306601092b2c5f..4ac3caf38904ddd905ff9f49f159bc3daf31382a 100644 (file)
     stream:
       - 'master':
           branch: '{stream}'
-          deploy-scenario: 'onap-sdc-full'
+          k8s-version: '1.15'
+          deploy-scenario: 'onap-sdc-nofeature'
       - 'frankfurt':
           branch: '{stream}'
-          deploy-scenario: 'onap-sdc-full'
+          k8s-version: '1.15'
+          deploy-scenario: 'onap-sdc-nofeature'
       - 'elalto':
           branch: '{stream}'
-          deploy-scenario: 'onap-sdc-full'
+          k8s-version: '1.15'
+          deploy-scenario: 'onap-sdc-nofeature'
 
     environment-type:
       - online:
           failed: false
           unstable: false
           notbuilt: false
-
+    # just deploy phase for now and ONAP testing isn't defined yet
     phase:
       - deploy
-      - functest
+
 
     type:
       - cloud:
           provisioner-type: 'heat'
           slave-type: 'jumphost'
           gated-projects: 'infra/stack/onap|infra/installer/oom'
-          pdf: "https://gerrit.nordix.org/gitweb?p=infra/provisioner/heat.git;a=blob_plain;f=playbooks/roles/create-stack/files/heat-environment-ci-city-ubuntu1804.yaml"
+          pdf: "https://gerrit.nordix.org/gitweb?p=infra/provisioner/heat.git;a=blob_plain;f=playbooks/roles/create-stack/files/heat-environment-ci-city-ubuntu1804-onap.yaml"
           idf: "https://gerrit.nordix.org/gitweb?p=infra/provisioner/heat.git;a=blob_plain;f=playbooks/roles/create-stack/files/heat-idf.yaml"
 
     distro:
       - city:
           openrc-credentials-file: 'est-jenkins-openrcfile-city-frankfurt-cicd'
 
+    # This should be
     dependency-jobs: 'onap-verify-package-{distro}-{stream}'
     dependency-job-var: 'TRIGGER_onap_verify_package_{distro}_{stream}_BUILD_RESULT'
 
     jobs:
       - 'onap-verify-{environment-type}-deploy-test-{distro}-{cloud}-{type}-{stream}'
-      - 'onap-verify-{environment-type}-{phase}-{distro}-{cloud}-{type}-{stream}'
 
 - job-template:
     name: 'onap-verify-{environment-type}-deploy-test-{distro}-{cloud}-{type}-{stream}'
           name: DEPLOY_SCENARIO
           default: '{deploy-scenario}'
           description: 'Scenario to test change with.'
+      - string:
+          name: K8S_VERSION
+          default: '{k8s-version}'
+          description: 'K8S version to use for this deployment'
+      - string:
+          name: INVENTORY_INI
+          default: /tmp/inventory.ini
+          description: 'Location of the inventory file. Copied from k8s install'
       - string:
           name: DISTRO
           default: '{distro}'
 
     builders:
       - 'generate-change-metadata-macro'
+      - 'generate-k8sdeployment-environment-macro'
       - multijob:
           name: "{environment-type} deployment on {type} instances"
           condition: SUCCESSFUL
-          execution-type: PARALLEL
+          execution-type: SEQUENTIAL
           projects:
-            - name: 'onap-verify-{environment-type}-deploy-{distro}-city-{type}-{stream}'
+            - name: 'onap-verify-{environment-type}-deployk8s-{distro}-city-{type}-{stream}'
               current-parameters: true
               git-revision: true
               node-parameters: true
               kill-phase-on: FAILURE
               abort-all-job: false
-              property-file: $WORKSPACE/change.properties
-      - multijob:
-          name: "{environment-type} testing on {type} instances"
-          condition: SUCCESSFUL
-          execution-type: PARALLEL
-          projects:
-            - name: 'onap-verify-{environment-type}-functest-{distro}-city-{type}-{stream}'
+              property-file: $WORKSPACE/k8s.properties
+            - name: 'onap-verify-{environment-type}-deploy-{distro}-city-{type}-{stream}'
               current-parameters: true
-              git-revision: false
+              git-revision: true
               node-parameters: true
               kill-phase-on: FAILURE
               abort-all-job: false
               property-file: $WORKSPACE/change.properties
-
     publishers:
       - postbuildscript:
           builders:
                 - 'delete-stack-macro'
 
 - job-template:
-    name: 'onap-verify-{environment-type}-{phase}-{distro}-{cloud}-{type}-{stream}'
+    name: 'onap-verify-{environment-type}-deploy-{distro}-{cloud}-{type}-{stream}'
+
+    disabled: '{obj:disabled}'
+
+    concurrent: true
+
+    properties:
+      - logrotate
+      - throttle:
+          max-per-node: 1
+          max-total: 3
+          option: project
+
+    scm:
+      - git-scm-gerrit:
+          ssh-credentials-id: nordixinfra-nordix-gerrit-ssh
+          branch: $GERRIT_BRANCH
+          refspec: $GERRIT_REFSPEC
+          wipe_workspace: true
+          clean_before: false
+
+    wrappers:
+      - build-timeout:
+          timeout: 180
+      - credentials-binding:
+          - file:
+              credential-id: '{openrc-credentials-file}'
+              variable: OPENRC_FILE
+          - username-password-separated:
+              credential-id: 'nordix-cicd-arm-credentials'
+              username: NORDIX_ARM_USERNAME
+              password: NORDIX_ARM_TOKEN
+      - mask-passwords
+      - fix-workspace-permissions
+
+    builders:
+      - 'generate-ssh-keypair-macro'
+      - 'wait-pkg-mgr-macro'
+      - 'download-deploy-artifact-macro'
+      - 'deploy-macro'
+
+- job-template:
+    name: 'onap-verify-{environment-type}-deployk8s-{distro}-{cloud}-{type}-{stream}'
 
     disabled: '{obj:disabled}'
 
     builders:
       - 'generate-ssh-keypair-macro'
       - 'wait-pkg-mgr-macro'
-      - 'download-{phase}-artifact-macro'
-      - '{phase}-macro'
+      - 'download-deploy-artifact-macro'
+      - 'deploy-macro'
diff --git a/jjb/cloud-infra/scripts/generate-k8sdeployment-environment.sh b/jjb/cloud-infra/scripts/generate-k8sdeployment-environment.sh
new file mode 100644 (file)
index 0000000..0098c9d
--- /dev/null
@@ -0,0 +1,74 @@
+#!/bin/bash
+
+# ============LICENSE_START=======================================================
+#  Copyright (C) 2019 The Nordix Foundation. 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.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+
+
+set -o nounset
+set -o errexit
+set -o pipefail
+
+# file to record k8s properties
+export K8S_DEPLOYMENT_FILE="$WORKSPACE/k8s.properties"
+/bin/rm -f "$K8S_DEPLOYMENT_FILE"
+
+echo "Info  : Generating k8s properties"
+
+# determine the project
+# this scripts is used by all engine repos so we need to determine what this change is for
+export ENGINE_COMPONENT="${GERRIT_PROJECT//*\//}"
+
+echo "Info  : Setting STACK_TYPE and STACK_VERSION"
+
+export STACK_TYPE="kubernetes"
+export STACK_VERSION="$K8S_VERSION"
+
+# record vars to properties file
+echo "STACK_TYPE=$STACK_TYPE" >> "$K8S_DEPLOYMENT_FILE"
+echo "DEPLOY_SCENARIO=k8-calico-nofeature" >> "$K8S_DEPLOYMENT_FILE"
+echo "STACK_VERSION=$STACK_VERSION" >> "$K8S_DEPLOYMENT_FILE"
+echo "NORDIX_STACK_VERSION=$K8S_VERSION" >> "$K8S_DEPLOYMENT_FILE"
+
+# global vars
+export NORDIX_ARM_HTTPS_URL="https://artifactory.nordix.org/artifactory"
+export ARTIFACT_ARM_FOLDER="release"
+export BUILD_IDENTIFIER="latest"
+export OFFLINE_INSTALLER_FILE="/tmp/${STACK_TYPE}-${K8S_VERSION}-${DISTRO}.bsx"
+export BUILD_ARTIFACTS="/tmp/${STACK_TYPE}-${K8S_VERSION}-${DISTRO}.bsx"
+export NORDIX_ARM_REPO="nordix-${STACK_TYPE}"
+export NORDIX_ARTIFACT_URL="$NORDIX_ARM_HTTPS_URL/$NORDIX_ARM_REPO/oss/$ARTIFACT_ARM_FOLDER/$BUILD_IDENTIFIER"
+
+cat << EOF >> "$K8S_DEPLOYMENT_FILE"
+BUILD_IDENTIFIER=$BUILD_IDENTIFIER
+BUILD_DATE=$(date '+%Y%m%d%H%M')
+BUILT_BY=$BUILD_URL
+DISTRO=$DISTRO
+CI_LOOP=$CI_LOOP
+ENGINE_SHA=$(git rev-parse HEAD)
+OFFLINE_INSTALLER_FILE=$OFFLINE_INSTALLER_FILE
+BUILD_ARTIFACTS=$BUILD_ARTIFACTS
+NORDIX_ARM_REPO=nordix-${STACK_TYPE}
+NORDIX_ARTIFACT_URL=$NORDIX_ARTIFACT_URL
+EOF
+
+echo "Info  : K8S properties"
+echo "-------------------------------------------------------------------------"
+cat "$K8S_DEPLOYMENT_FILE"
+echo "-------------------------------------------------------------------------"
+
+# vim: set ts=2 sw=2 expandtab: