blob: 87f8aa3cfa16c5a509bbf4795c4f245eae1b00c2 [file] [log] [blame]
Jeremy Ronquillo1b9581f2020-03-20 10:37:59 -07001// 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.
Jeremy Ronquillo0d731d32020-04-09 12:20:53 -070018// Can deploy in production (manual trigger only).
19
20dp_context = ""
21omec_cp = ""
22omec_dp = ""
23accelleran_cbrs_common = ""
24accelleran_cbrs_cu = ""
Jeremy Ronquillo1b9581f2020-03-20 10:37:59 -070025
26pipeline {
27
28 /* executor is determined by parameter */
29 agent {
30 label "${params.buildNode}"
31 }
32
Jeremy Ronquillo1b9581f2020-03-20 10:37:59 -070033 environment {
Jeremy Ronquillo0d731d32020-04-09 12:20:53 -070034 vm = "comac@192.168.122.57"
Jeremy Ronquillo1b9581f2020-03-20 10:37:59 -070035 }
36
37 stages {
Jeremy Ronquillo0d731d32020-04-09 12:20:53 -070038 stage('Environment Setup') {
39 steps {
40 script {
41 if (params.useProductionCluster) {
42 dp_context = "production-edge-demo"
43 omec_cp = "~/pod-configs/deployment-configs/aether/apps/gcp-prd/omec-cp.yaml"
44 omec_dp = "~/pod-configs/deployment-configs/aether/apps/menlo-demo/omec-dp-cbrs.yaml"
45 accelleran_cbrs_common = "~/pod-configs/deployment-configs/aether/apps/menlo-demo/accelleran-cbrs-common.yaml"
46 accelleran_cbrs_cu = "~/pod-configs/deployment-configs/aether/apps/menlo-demo/accelleran-cbrs-cu.yaml"
47 sh script: "ssh ${env.vm} 'cp ~/.kube/omec_production_config ~/.kube/config'"
48 println "Using PRODUCTION cluster."
49 } else {
50 dp_context = "staging-edge-onf-menlo"
51 omec_cp = "~/pod-configs/deployment-configs/aether/apps/gcp-stg/omec-cp.yaml"
52 omec_dp = "~/pod-configs/deployment-configs/aether/apps/menlo-stg/omec-dp.yaml"
53 accelleran_cbrs_common = "~/pod-configs/deployment-configs/aether/apps/menlo-stg/accelleran-cbrs-common.yaml"
54 accelleran_cbrs_cu = "~/pod-configs/deployment-configs/aether/apps/menlo-stg/accelleran-cbrs-cu.yaml"
55 sh script: "ssh ${env.vm} 'cp ~/.kube/omec_staging_config ~/.kube/config'"
56 println "Using STAGING cluster."
57 }
58 }
59 }
60 }
61 stage('Reset Staging') {
62 steps {
63 sh label: 'Reset Deployment', script: """
64 ssh ${env.vm} '
65 helm delete --purge --kube-context staging-edge-onf-menlo accelleran-cbrs-cu | true
66 helm delete --purge --kube-context staging-edge-onf-menlo accelleran-cbrs-common | true
67 helm delete --purge --kube-context staging-edge-onf-menlo omec-data-plane | true
68 helm delete --purge --kube-context staging-central-gcp omec-control-plane | true
69 '
70 """
71 }
72 }
Jeremy Ronquillo1b9581f2020-03-20 10:37:59 -070073 stage('Change Staging Images Config') {
74 steps {
75 sh label: 'Change Staging Images Config', script: """
Jeremy Ronquillo0d731d32020-04-09 12:20:53 -070076 ssh ${env.vm} '
Jeremy Ronquillo1b9581f2020-03-20 10:37:59 -070077
78 # if hssdb tag is provided, change hssdb tag in omec_cp.yaml.
79 if [ ! -z "${params.hssdb_tag}" ]
80 then
Jeremy Ronquillo0d731d32020-04-09 12:20:53 -070081 sed -i "s;hssdb: .*;hssdb: \\"${params.registry}/c3po-hssdb:${params.hssdb_tag}\\";" ${omec_cp}
Jeremy Ronquillo1b9581f2020-03-20 10:37:59 -070082 echo "Changed hssdb tag."
83 else
84 echo "hssdb tag not provided. Not changing."
85 fi
86
87 # if hss tag is provided, change hss tag in omec_cp.yaml.
88 if [ ! -z "${params.hss_tag}" ]
89 then
Jeremy Ronquillo0d731d32020-04-09 12:20:53 -070090 sed -i "s;hss: .*;hss: \\"${params.registry}/c3po-hss:${params.hss_tag}\\";" ${omec_cp}
Jeremy Ronquillo1b9581f2020-03-20 10:37:59 -070091 echo "Changed hss tag."
92 else
93 echo "hss tag not provided. Not changing."
94 fi
95
96 # if mme tag is provided, change mme tag in omec_cp.yaml.
97 if [ ! -z "${params.mme_tag}" ]
98 then
Jeremy Ronquillo0d731d32020-04-09 12:20:53 -070099 sed -i "s;mme: .*;mme: \\"${params.registry}/openmme:${params.mme_tag}\\";" ${omec_cp}
Jeremy Ronquillo1b9581f2020-03-20 10:37:59 -0700100 echo "Changed mme tag."
101 else
102 echo "mme tag not provided. Not changing."
103 fi
104
105 # if mmeExporter tag is provided, change mmeExporter tag in omec_cp.yaml.
106 if [ ! -z "${params.mmeExporter_tag}" ]
107 then
Jeremy Ronquillo0d731d32020-04-09 12:20:53 -0700108 sed -i "s;mmeExporter: .*;mmeExporter: \\"${params.registry}/mme-exporter:${params.mmeExporter_tag}\\";" ${omec_cp}
Jeremy Ronquillo1b9581f2020-03-20 10:37:59 -0700109 echo "Changed mmeExporter tag."
110 else
111 echo "mmeExporter tag not provided. Not changing."
112 fi
113
114 # if spgwc tag is provided, change spgwc tag in omec_cp.yaml.
115 if [ ! -z "${params.spgwc_tag}" ]
116 then
Jeremy Ronquillo0d731d32020-04-09 12:20:53 -0700117 sed -i "s;spgwc: .*;spgwc: \\"${params.registry}/ngic-cp:${params.spgwc_tag}\\";" ${omec_cp}
Jeremy Ronquillo1b9581f2020-03-20 10:37:59 -0700118 echo "Changed spgwc tag."
119 else
120 echo "spgwc tag not provided. Not changing."
121 fi
122
123 # if spgwu tag is provided, change spgwu tag in omec_dp.yaml.
124 if [ ! -z "${params.spgwu_tag}" ]
125 then
Jeremy Ronquillo0d731d32020-04-09 12:20:53 -0700126 sed -i "s;spgwu: .*;spgwu: \\"${params.registry}/ngic-dp:${params.spgwu_tag}\\";" ${omec_dp}
Jeremy Ronquillo1b9581f2020-03-20 10:37:59 -0700127 echo "Changed spgwu tag."
128 else
129 echo "spgwu tag not provided. Not changing."
130 fi
131
132 # display omec-cp.yaml
133 echo "omec_cp:"
Jeremy Ronquillo0d731d32020-04-09 12:20:53 -0700134 cat ${omec_cp}
Jeremy Ronquillo1b9581f2020-03-20 10:37:59 -0700135
136 # display omec-dp.yaml
137 echo "omec_dp:"
Jeremy Ronquillo0d731d32020-04-09 12:20:53 -0700138 cat ${omec_dp}
Jeremy Ronquillo1b9581f2020-03-20 10:37:59 -0700139 '
140 """
141 }
142 }
143
Jeremy Ronquillo0d731d32020-04-09 12:20:53 -0700144 stage('Deploy Control Plane') {
Jeremy Ronquillo1b9581f2020-03-20 10:37:59 -0700145 steps {
Jeremy Ronquillo0d731d32020-04-09 12:20:53 -0700146 sh label: 'staging-central-gcp', script: """
147 ssh ${env.vm} '
Jeremy Ronquillo1b9581f2020-03-20 10:37:59 -0700148 kubectl config use-context staging-central-gcp
149
150 helm del --purge omec-control-plane | true
151
152 helm install --kube-context staging-central-gcp \
153 --name omec-control-plane \
154 --namespace omec \
Jeremy Ronquillo0d731d32020-04-09 12:20:53 -0700155 --values ${omec_cp} \
Jeremy Ronquillo1b9581f2020-03-20 10:37:59 -0700156 cord/omec-control-plane
157
158 kubectl --context staging-central-gcp -n omec wait \
159 --for=condition=Ready \
160 --timeout=300s \
161 pod -l app=spgwc
162 '
Jeremy Ronquillo0d731d32020-04-09 12:20:53 -0700163 """
Jeremy Ronquillo1b9581f2020-03-20 10:37:59 -0700164 }
165 }
166
Jeremy Ronquillo0d731d32020-04-09 12:20:53 -0700167 stage('Deploy Data Plane') {
Jeremy Ronquillo1b9581f2020-03-20 10:37:59 -0700168 steps {
Jeremy Ronquillo0d731d32020-04-09 12:20:53 -0700169 sh label: 'dp_context', script: """
170 ssh ${env.vm} '
171 kubectl config use-context ${dp_context}
Jeremy Ronquillo1b9581f2020-03-20 10:37:59 -0700172
173 helm del --purge omec-data-plane | true
174
Jeremy Ronquillo0d731d32020-04-09 12:20:53 -0700175 helm install --kube-context ${dp_context} \
Jeremy Ronquillo1b9581f2020-03-20 10:37:59 -0700176 --name omec-data-plane \
177 --namespace omec \
Jeremy Ronquillo0d731d32020-04-09 12:20:53 -0700178 --values ${omec_dp} \
Jeremy Ronquillo1b9581f2020-03-20 10:37:59 -0700179 cord/omec-data-plane
180
Jeremy Ronquillo0d731d32020-04-09 12:20:53 -0700181 kubectl --context ${dp_context} -n omec wait \
Jeremy Ronquillo1b9581f2020-03-20 10:37:59 -0700182 --for=condition=Ready \
183 --timeout=300s \
184 pod -l app=spgwu
185 '
Jeremy Ronquillo0d731d32020-04-09 12:20:53 -0700186 """
Jeremy Ronquillo1b9581f2020-03-20 10:37:59 -0700187 }
188 }
189
Jeremy Ronquillo0d731d32020-04-09 12:20:53 -0700190 stage('Deploy Accelleran CBRS') {
Jeremy Ronquillo1b9581f2020-03-20 10:37:59 -0700191 steps {
Jeremy Ronquillo0d731d32020-04-09 12:20:53 -0700192 sh label: 'accelleran-cbrs-common', script: """
193 ssh ${env.vm} '
194 kubectl config use-context ${dp_context}
Jeremy Ronquillo1b9581f2020-03-20 10:37:59 -0700195
196 helm del --purge accelleran-cbrs-common | true
197 helm del --purge accelleran-cbrs-cu | true
198
Jeremy Ronquillo0d731d32020-04-09 12:20:53 -0700199 helm install --kube-context ${dp_context} \
Jeremy Ronquillo1b9581f2020-03-20 10:37:59 -0700200 --name accelleran-cbrs-common \
201 --namespace omec \
Jeremy Ronquillo0d731d32020-04-09 12:20:53 -0700202 --values ${accelleran_cbrs_common} \
Jeremy Ronquillo1b9581f2020-03-20 10:37:59 -0700203 cord/accelleran-cbrs-common
204
Jeremy Ronquillo0d731d32020-04-09 12:20:53 -0700205 helm install --kube-context ${dp_context} \
Jeremy Ronquillo1b9581f2020-03-20 10:37:59 -0700206 --name accelleran-cbrs-cu \
207 --namespace omec \
Jeremy Ronquillo0d731d32020-04-09 12:20:53 -0700208 --values ${accelleran_cbrs_cu} \
Jeremy Ronquillo1b9581f2020-03-20 10:37:59 -0700209 cord/accelleran-cbrs-cu
210
Jeremy Ronquillo0d731d32020-04-09 12:20:53 -0700211 kubectl --context ${dp_context} -n omec wait \
Jeremy Ronquillo1b9581f2020-03-20 10:37:59 -0700212 --for=condition=Ready \
213 --timeout=300s \
214 pod -l app=accelleran-cbrs-cu
215 '
Jeremy Ronquillo0d731d32020-04-09 12:20:53 -0700216 """
Jeremy Ronquillo1b9581f2020-03-20 10:37:59 -0700217 }
218 }
219 }
220}