Jeremy Ronquillo | 1b9581f | 2020-03-20 10:37:59 -0700 | [diff] [blame^] | 1 | // Copyright 2020-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 | |
| 15 | // Jenkinsfile-omec-deploy-staging.groovy: Changes staging images in |
| 16 | // omec-cp.yaml and omec-dp.yaml based on params and deploys omec staging. |
| 17 | // Mainly triggered from omec-postmerge after publishing docker images. |
| 18 | |
| 19 | pipeline { |
| 20 | |
| 21 | /* executor is determined by parameter */ |
| 22 | agent { |
| 23 | label "${params.buildNode}" |
| 24 | } |
| 25 | |
| 26 | /* locations of omec-cp.yaml and omec-dp.yaml */ |
| 27 | environment { |
| 28 | omec_cp = "~/pod-configs/deployment-configs/aether/apps/gcp-stg/omec-cp.yaml" |
| 29 | omec_dp = "~/pod-configs/deployment-configs/aether/apps/menlo-stg/omec-dp.yaml" |
| 30 | } |
| 31 | |
| 32 | stages { |
| 33 | stage('Change Staging Images Config') { |
| 34 | steps { |
| 35 | sh label: 'Change Staging Images Config', script: """ |
| 36 | ssh comac@192.168.122.57 ' |
| 37 | |
| 38 | # if hssdb tag is provided, change hssdb tag in omec_cp.yaml. |
| 39 | if [ ! -z "${params.hssdb_tag}" ] |
| 40 | then |
| 41 | sed -i "s;hssdb: .*;hssdb: \\"${params.registry}/c3po-hssdb:${params.hssdb_tag}\\";" ${env.omec_cp} |
| 42 | echo "Changed hssdb tag." |
| 43 | else |
| 44 | echo "hssdb tag not provided. Not changing." |
| 45 | fi |
| 46 | |
| 47 | # if hss tag is provided, change hss tag in omec_cp.yaml. |
| 48 | if [ ! -z "${params.hss_tag}" ] |
| 49 | then |
| 50 | sed -i "s;hss: .*;hss: \\"${params.registry}/c3po-hss:${params.hss_tag}\\";" ${env.omec_cp} |
| 51 | echo "Changed hss tag." |
| 52 | else |
| 53 | echo "hss tag not provided. Not changing." |
| 54 | fi |
| 55 | |
| 56 | # if mme tag is provided, change mme tag in omec_cp.yaml. |
| 57 | if [ ! -z "${params.mme_tag}" ] |
| 58 | then |
| 59 | sed -i "s;mme: .*;mme: \\"${params.registry}/openmme:${params.mme_tag}\\";" ${env.omec_cp} |
| 60 | echo "Changed mme tag." |
| 61 | else |
| 62 | echo "mme tag not provided. Not changing." |
| 63 | fi |
| 64 | |
| 65 | # if mmeExporter tag is provided, change mmeExporter tag in omec_cp.yaml. |
| 66 | if [ ! -z "${params.mmeExporter_tag}" ] |
| 67 | then |
| 68 | sed -i "s;mmeExporter: .*;mmeExporter: \\"${params.registry}/mme-exporter:${params.mmeExporter_tag}\\";" ${env.omec_cp} |
| 69 | echo "Changed mmeExporter tag." |
| 70 | else |
| 71 | echo "mmeExporter tag not provided. Not changing." |
| 72 | fi |
| 73 | |
| 74 | # if spgwc tag is provided, change spgwc tag in omec_cp.yaml. |
| 75 | if [ ! -z "${params.spgwc_tag}" ] |
| 76 | then |
| 77 | sed -i "s;spgwc: .*;spgwc: \\"${params.registry}/ngic-cp:${params.spgwc_tag}\\";" ${env.omec_cp} |
| 78 | echo "Changed spgwc tag." |
| 79 | else |
| 80 | echo "spgwc tag not provided. Not changing." |
| 81 | fi |
| 82 | |
| 83 | # if spgwu tag is provided, change spgwu tag in omec_dp.yaml. |
| 84 | if [ ! -z "${params.spgwu_tag}" ] |
| 85 | then |
| 86 | sed -i "s;spgwu: .*;spgwu: \\"${params.registry}/ngic-dp:${params.spgwu_tag}\\";" ${env.omec_dp} |
| 87 | echo "Changed spgwu tag." |
| 88 | else |
| 89 | echo "spgwu tag not provided. Not changing." |
| 90 | fi |
| 91 | |
| 92 | # display omec-cp.yaml |
| 93 | echo "omec_cp:" |
| 94 | cat ${env.omec_cp} |
| 95 | |
| 96 | # display omec-dp.yaml |
| 97 | echo "omec_dp:" |
| 98 | cat ${env.omec_dp} |
| 99 | ' |
| 100 | """ |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | stage('Deploy: staging-central-gcp') { |
| 105 | steps { |
| 106 | sh label: 'staging-central-gcp', script: ''' |
| 107 | ssh comac@192.168.122.57 ' |
| 108 | kubectl config use-context staging-central-gcp |
| 109 | |
| 110 | helm del --purge omec-control-plane | true |
| 111 | |
| 112 | helm install --kube-context staging-central-gcp \ |
| 113 | --name omec-control-plane \ |
| 114 | --namespace omec \ |
| 115 | --values pod-configs/deployment-configs/aether/apps/gcp-stg/omec-cp.yaml \ |
| 116 | cord/omec-control-plane |
| 117 | |
| 118 | kubectl --context staging-central-gcp -n omec wait \ |
| 119 | --for=condition=Ready \ |
| 120 | --timeout=300s \ |
| 121 | pod -l app=spgwc |
| 122 | ' |
| 123 | ''' |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | stage('Deploy: omec-data-plane') { |
| 128 | steps { |
| 129 | sh label: 'staging-edge-onf-menlo', script: ''' |
| 130 | ssh comac@192.168.122.57 ' |
| 131 | kubectl config use-context staging-edge-onf-menlo |
| 132 | |
| 133 | helm del --purge omec-data-plane | true |
| 134 | |
| 135 | helm install --kube-context staging-edge-onf-menlo \ |
| 136 | --name omec-data-plane \ |
| 137 | --namespace omec \ |
| 138 | --values pod-configs/deployment-configs/aether/apps/menlo-stg/omec-dp.yaml \ |
| 139 | cord/omec-data-plane |
| 140 | |
| 141 | kubectl --context staging-edge-onf-menlo -n omec wait \ |
| 142 | --for=condition=Ready \ |
| 143 | --timeout=300s \ |
| 144 | pod -l app=spgwu |
| 145 | ' |
| 146 | ''' |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | stage('Deploy: accelleran-cbrs') { |
| 151 | steps { |
| 152 | sh label: 'accelleran-cbrs-common', script: ''' |
| 153 | ssh comac@192.168.122.57 ' |
| 154 | kubectl config use-context staging-edge-onf-menlo |
| 155 | |
| 156 | helm del --purge accelleran-cbrs-common | true |
| 157 | helm del --purge accelleran-cbrs-cu | true |
| 158 | |
| 159 | helm install --kube-context staging-edge-onf-menlo \ |
| 160 | --name accelleran-cbrs-common \ |
| 161 | --namespace omec \ |
| 162 | --values pod-configs/deployment-configs/aether/apps/menlo-stg/accelleran-cbrs-common.yaml \ |
| 163 | cord/accelleran-cbrs-common |
| 164 | |
| 165 | helm install --kube-context staging-edge-onf-menlo \ |
| 166 | --name accelleran-cbrs-cu \ |
| 167 | --namespace omec \ |
| 168 | --values pod-configs/deployment-configs/aether/apps/menlo-stg/accelleran-cbrs-cu.yaml \ |
| 169 | cord/accelleran-cbrs-cu |
| 170 | |
| 171 | kubectl --context staging-edge-onf-menlo -n omec wait \ |
| 172 | --for=condition=Ready \ |
| 173 | --timeout=300s \ |
| 174 | pod -l app=accelleran-cbrs-cu |
| 175 | ' |
| 176 | ''' |
| 177 | } |
| 178 | } |
| 179 | } |
| 180 | } |