Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 1 | // Copyright 2017-present Open Networking Foundation |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
Zack Williams | 5ce76d4 | 2020-02-28 15:45:56 -0700 | [diff] [blame] | 15 | node ("${buildNode}") { |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 16 | timeout (100) { |
| 17 | try { |
| 18 | stage ("Parse deployment configuration file") { |
Matteo Scandolo | 9f8056b | 2019-01-17 10:33:51 -0800 | [diff] [blame] | 19 | sh returnStdout: true, script: "rm -rf helm-charts helm-repo-tools ${configBaseDir}" |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 20 | sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/helm-repo-tools" |
Wei-Yu Chen | 1a5f9ff | 2019-02-07 10:18:55 -0800 | [diff] [blame] | 21 | sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/helm-charts" |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 22 | sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}" |
Wei-Yu Chen | ab221cb | 2019-02-15 14:59:31 -0800 | [diff] [blame] | 23 | |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 24 | deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml" |
| 25 | } |
| 26 | stage('Clean up') { |
| 27 | timeout(10) { |
| 28 | sh returnStdout: true, script: """ |
| 29 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
Wei-Yu Chen | 53d303a | 2019-02-19 15:15:27 -0800 | [diff] [blame] | 30 | helm init --upgrade --force-upgrade |
| 31 | """ |
| 32 | |
| 33 | timeout(1) { |
| 34 | waitUntil { |
| 35 | tillerpod_running = sh returnStdout: true, script: """ |
| 36 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
Wei-Yu Chen | a17a279 | 2019-02-19 15:31:03 -0800 | [diff] [blame] | 37 | kubectl -n kube-system get pods | grep tiller-deploy | grep Running | grep 1/1 | wc -l |
Wei-Yu Chen | 53d303a | 2019-02-19 15:15:27 -0800 | [diff] [blame] | 38 | """ |
| 39 | return tillerpod_running.toInteger() == 1 |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | sh returnStdout: true, script: """ |
| 44 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 45 | for hchart in \$(helm list -q | grep -E -v 'docker-registry|mavenrepo|ponnet'); |
| 46 | do |
| 47 | echo "Purging chart: \${hchart}" |
| 48 | helm delete --purge "\${hchart}" |
| 49 | done |
| 50 | """ |
Wei-Yu Chen | a17a279 | 2019-02-19 15:31:03 -0800 | [diff] [blame] | 51 | |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 52 | timeout(5) { |
| 53 | waitUntil { |
| 54 | helm_deleted = sh returnStdout: true, script: """ |
| 55 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 56 | helm ls -q | grep -E -v 'docker-registry|mavenrepo|ponnet' | wc -l |
| 57 | """ |
| 58 | return helm_deleted.toInteger() == 0 |
| 59 | } |
| 60 | } |
Wei-Yu Chen | 9de5f16 | 2019-01-17 10:40:38 -0800 | [diff] [blame] | 61 | timeout(5) { |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 62 | waitUntil { |
| 63 | kubectl_deleted = sh returnStdout: true, script: """ |
| 64 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 65 | kubectl get pods --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l |
| 66 | """ |
| 67 | return kubectl_deleted.toInteger() == 0 |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | } |
Luca Prete | 62a48c8 | 2019-01-16 10:40:01 -0800 | [diff] [blame] | 72 | stage('Add Helm repositories') { |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 73 | sh returnStdout: true, script: """ |
| 74 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 75 | helm repo add cord https://charts.opencord.org |
Luca Prete | 62a48c8 | 2019-01-16 10:40:01 -0800 | [diff] [blame] | 76 | helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubator |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 77 | helm repo update |
| 78 | """ |
| 79 | timeout(1) { |
| 80 | waitUntil { |
Wei-Yu Chen | 76dd793 | 2019-01-18 14:14:23 -0800 | [diff] [blame] | 81 | tillerpod_running = sh returnStdout: true, script: """ |
| 82 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 83 | kubectl -n kube-system get pods | grep tiller-deploy | grep Running | wc -l |
| 84 | """ |
| 85 | return tillerpod_running.toInteger() == 1 |
| 86 | } |
| 87 | } |
| 88 | timeout(1) { |
| 89 | waitUntil { |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 90 | cord_repo_present = sh returnStdout: true, script: """ |
| 91 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 92 | helm repo list | grep cord | wc -l |
| 93 | """ |
| 94 | return cord_repo_present.toInteger() == 1 |
| 95 | } |
| 96 | } |
| 97 | } |
Matteo Scandolo | 08aea47 | 2019-01-23 11:45:37 -0800 | [diff] [blame] | 98 | |
Wei-Yu Chen | 992665b | 2019-01-17 10:21:32 -0800 | [diff] [blame] | 99 | stage("Install M-CORD Control Plane Services") { |
| 100 | sh returnStdout: true, script: """ |
| 101 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
Wei-Yu Chen | 1a5f9ff | 2019-02-07 10:18:55 -0800 | [diff] [blame] | 102 | helm install -n mcord-control-plane --namespace epc -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml --set spgwu_s1u_ip=${dataplane_s1u_ip} --set accelleran_hostname=${accelleran_bbu_ip} cord/mcord-control-plane |
Wei-Yu Chen | 992665b | 2019-01-17 10:21:32 -0800 | [diff] [blame] | 103 | """ |
Wei-Yu Chen | 037762d | 2019-01-24 11:12:39 -0800 | [diff] [blame] | 104 | |
Wei-Yu Chen | 037762d | 2019-01-24 11:12:39 -0800 | [diff] [blame] | 105 | timeout(20) { |
| 106 | control_plane = sh returnStdout: true, script: """ |
| 107 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
Wei-Yu Chen | 1a5f9ff | 2019-02-07 10:18:55 -0800 | [diff] [blame] | 108 | kubectl -n epc get pods | grep -i running | grep 1/1 | wc -l |
Wei-Yu Chen | 037762d | 2019-01-24 11:12:39 -0800 | [diff] [blame] | 109 | """ |
| 110 | // We have 4 pods: cassandra, hss, mme and ngic-cp |
| 111 | return control_plane.toInteger() == 4 |
| 112 | } |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 113 | } |
Wei-Yu Chen | 992665b | 2019-01-17 10:21:32 -0800 | [diff] [blame] | 114 | |
Wei-Yu Chen | 1a5f9ff | 2019-02-07 10:18:55 -0800 | [diff] [blame] | 115 | // TODO: Use --namespace wowz to create the namespace |
| 116 | stage("Install CDN Remote Services") { |
| 117 | sh returnStdout: true, script: """ |
| 118 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
Andy Bavier | 490c819 | 2019-02-15 14:20:25 -0800 | [diff] [blame] | 119 | helm install -n cdn-remote cord/mcord-cdn-remote -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml |
Wei-Yu Chen | 1a5f9ff | 2019-02-07 10:18:55 -0800 | [diff] [blame] | 120 | """ |
| 121 | |
| 122 | timeout(3) { |
| 123 | waitUntil { |
| 124 | mcord_remote_cdn_working = sh returnStdout: true, script: """ |
| 125 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 126 | kubectl -n wowz get pods -o wide | grep -i running | grep 1/1 | wc -l |
| 127 | """ |
Wei-Yu Chen | a17a279 | 2019-02-19 15:31:03 -0800 | [diff] [blame] | 128 | return mcord_remote_cdn_working.toInteger() == 2 |
Wei-Yu Chen | 1a5f9ff | 2019-02-07 10:18:55 -0800 | [diff] [blame] | 129 | } |
| 130 | } |
| 131 | } |
| 132 | |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 133 | currentBuild.result = 'SUCCESS' |
| 134 | } catch (err) { |
Wei-Yu Chen | ab221cb | 2019-02-15 14:59:31 -0800 | [diff] [blame] | 135 | println err.message |
Luca Prete | 45401c8 | 2019-01-15 15:31:22 -0800 | [diff] [blame] | 136 | currentBuild.result = 'FAILURE' |
| 137 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false]) |
| 138 | } |
| 139 | echo "RESULT: ${currentBuild.result}" |
| 140 | } |
| 141 | } |