Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 1 | .. |
| 2 | SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org> |
| 3 | SPDX-License-Identifier: Apache-2.0 |
| 4 | |
| 5 | =============== |
| 6 | TOST Deployment |
| 7 | =============== |
| 8 | |
| 9 | Update aether-pod-config |
| 10 | ======================== |
| 11 | |
| 12 | Aether-pod-configs is a git project hosted on **gerrit.opencord.org** and we placed the following materials in it. |
| 13 | |
| 14 | - Terraform scripts to install TOST applications on Rancher, including ONOS, Stratum and Telegraf. |
| 15 | - Customized configuration for each application (helm values). |
| 16 | - Application specific configuration files, including ONOS network configuration and Stratum chassis config. |
| 17 | |
| 18 | Here is an example folder structure: |
| 19 | |
| 20 | .. code-block:: console |
| 21 | |
| 22 | ╰─$ tree staging/ace-menlo/tost |
| 23 | staging/ace-menlo/tost |
| 24 | ├── app_map.tfvars |
| 25 | ├── backend.tf |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 26 | ├── deepinsight |
| 27 | │ ├── README.md |
| 28 | │ ├── deepinsight-topo.json |
| 29 | │ └── deepinsight-topo.json.license |
| 30 | ├── main.tf -> ../../../common/tost/main.tf |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 31 | ├── onos |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 32 | │ ├── app_map.tfvars |
| 33 | │ ├── backend.tf |
| 34 | │ ├── main.tf -> ../../../../common/tost/apps/onos/main.tf |
| 35 | │ ├── onos-netcfg.json |
| 36 | │ ├── onos-netcfg.json.license |
| 37 | │ ├── onos.yaml |
| 38 | │ └── variables.tf -> ../../../../common/tost/apps/onos/variables.tf |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 39 | ├── stratum |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 40 | │ ├── app_map.tfvars |
| 41 | │ ├── backend.tf |
| 42 | │ ├── main.tf -> ../../../../common/tost/apps/stratum/main.tf |
| 43 | │ ├── menlo-staging-leaf-1-chassis-config.pb.txt |
| 44 | │ ├── menlo-staging-leaf-2-chassis-config.pb.txt |
| 45 | │ ├── menlo-staging-spine-1-chassis-config.pb.txt |
| 46 | │ ├── menlo-staging-spine-2-chassis-config.pb.txt |
| 47 | │ ├── stratum.yaml |
| 48 | │ ├── tost-dev-chassis-config.pb.txt |
| 49 | │ └── variables.tf -> ../../../../common/tost/apps/stratum/variables.tf |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 50 | ├── telegraf |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 51 | │ ├── app_map.tfvars |
| 52 | │ ├── backend.tf |
| 53 | │ ├── main.tf -> ../../../../common/tost/apps/telegraf/main.tf |
| 54 | │ ├── telegraf.yaml |
| 55 | │ └── variables.tf -> ../../../../common/tost/apps/telegraf/variables.tf |
| 56 | └── variables.tf -> ../../../common/tost/variables.tf |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 57 | |
| 58 | There are four Terraform scripts inside **tost** directory and are responsible for managing each service. |
| 59 | |
| 60 | Root folder |
| 61 | ^^^^^^^^^^^ |
| 62 | Terraform reads **app_map.tfvars** to know which application will be installed on Rancher |
| 63 | and which version and customized values need to apply to. |
| 64 | |
Hyunsun Moon | fc751aa | 2020-11-11 18:49:47 -0800 | [diff] [blame] | 65 | Here is the example of **app_map.tfvars** which defines prerequisite apps for TOST |
| 66 | as well as project and namespace in which TOST apps will be provisioned. |
| 67 | Note that currently we don't have any prerequisite so we left this blank intentionally. |
| 68 | It can be used to specify prerequisites in the future. |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 69 | |
| 70 | .. code-block:: |
| 71 | |
| 72 | project_name = "tost" |
| 73 | namespace_name = "tost" |
| 74 | |
Hyunsun Moon | fc751aa | 2020-11-11 18:49:47 -0800 | [diff] [blame] | 75 | app_map = {} |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 76 | |
| 77 | ONOS folder |
| 78 | ^^^^^^^^^^^ |
| 79 | All files under **onos** directory are related to ONOS application. |
Hyunsun Moon | fc751aa | 2020-11-11 18:49:47 -0800 | [diff] [blame] | 80 | The **app_map.tfvars** in this folder describes the information about ONOS helm chart. |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 81 | |
| 82 | In this example, we specify the **onos-tost** helm chart version to **0.1.18** and load **onos.yaml** |
| 83 | as custom value files. |
| 84 | |
| 85 | .. code-block:: |
| 86 | |
| 87 | apps = ["onos"] |
| 88 | |
| 89 | app_map = { |
| 90 | onos = { |
| 91 | app_name = "onos-tost" |
| 92 | project_name = "tost" |
| 93 | target_namespace = "onos-tost" |
| 94 | catalog_name = "onos" |
| 95 | template_name = "onos-tost" |
| 96 | template_version = "0.1.18" |
| 97 | values_yaml = ["onos.yaml"] |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | **onos.yaml** used to custom your ONOS-tost Helm chart values and please pay attention to the last section, config. |
| 102 | |
| 103 | .. code-block:: yaml |
| 104 | |
| 105 | onos-classic: |
| 106 | image: |
| 107 | tag: master |
| 108 | pullPolicy: Always |
| 109 | replicas: 1 |
| 110 | atomix: |
| 111 | replicas: 1 |
| 112 | logging: |
| 113 | config: | |
| 114 | # Common pattern layout for appenders |
| 115 | log4j2.stdout.pattern = %d{RFC3339} %-5level [%c{1}] %msg%n%throwable |
| 116 | |
| 117 | # Root logger |
| 118 | log4j2.rootLogger.level = INFO |
| 119 | |
| 120 | # OSGi appender |
| 121 | log4j2.rootLogger.appenderRef.PaxOsgi.ref = PaxOsgi |
| 122 | log4j2.appender.osgi.type = PaxOsgi |
| 123 | log4j2.appender.osgi.name = PaxOsgi |
| 124 | log4j2.appender.osgi.filter = * |
| 125 | |
| 126 | # stdout appender |
| 127 | log4j2.rootLogger.appenderRef.Console.ref = Console |
| 128 | log4j2.appender.console.type = Console |
| 129 | log4j2.appender.console.name = Console |
| 130 | log4j2.appender.console.layout.type = PatternLayout |
| 131 | log4j2.appender.console.layout.pattern = ${log4j2.stdout.pattern} |
| 132 | |
| 133 | # SSHD logger |
| 134 | log4j2.logger.sshd.name = org.apache.sshd |
| 135 | log4j2.logger.sshd.level = INFO |
| 136 | |
| 137 | # Spifly logger |
| 138 | log4j2.logger.spifly.name = org.apache.aries.spifly |
| 139 | log4j2.logger.spifly.level = WARN |
| 140 | |
| 141 | # SegmentRouting logger |
| 142 | log4j2.logger.segmentrouting.name = org.onosproject.segmentrouting |
| 143 | log4j2.logger.segmentrouting.level = DEBUG |
| 144 | |
| 145 | config: |
| 146 | server: gerrit.opencord.org |
| 147 | repo: aether-pod-configs |
| 148 | folder: staging/ace-menlo/tost/onos |
| 149 | file: onos-netcfg.json |
| 150 | netcfgUrl: http://onos-tost-onos-classic-hs.tost.svc:8181/onos/v1/network/configuration |
| 151 | clusterUrl: http://onos-tost-onos-classic-hs.tost.svc:8181/onos/v1/cluster |
| 152 | |
| 153 | Once the **onos-tost** containers are deployed into Kubernetes, |
| 154 | it will read **onos-netcfg.json** file from the **aether-pod-config** and please change the folder name to different location if necessary. |
| 155 | |
| 156 | **onos-netcfg.json** is environment dependent and please change it to fit your environment. |
| 157 | |
| 158 | .. |
| 159 | TODO: Add an example based on the recommended topology |
| 160 | |
| 161 | Stratum folder |
| 162 | ^^^^^^^^^^^^^^ |
| 163 | Stratum uses a similar directory structure as ONOS for Terraform and its configuration files. |
| 164 | |
| 165 | The customize value file is named **stratum.yaml** |
| 166 | |
| 167 | .. code-block:: |
| 168 | |
| 169 | app_map = { |
| 170 | stratum= { |
| 171 | app_name = "stratum" |
| 172 | project_name = "tost" |
| 173 | target_namespace = "stratum" |
| 174 | catalog_name = "stratum" |
| 175 | template_name = "stratum" |
| 176 | template_version = "0.1.9" |
| 177 | values_yaml = ["stratum.yaml"] |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | Like ONOS, **stratum.yaml** used to customize Stratum Helm Chart and please pay attention to the config section. |
| 182 | |
| 183 | .. code-block:: yaml |
| 184 | |
| 185 | image: |
| 186 | registry: registry.aetherproject.org |
| 187 | repository: tost/stratum-bfrt |
| 188 | tag: 9.2.0-4.14.49 |
| 189 | pullPolicy: Always |
| 190 | pullSecrets: |
| 191 | - aether-registry-credential |
| 192 | |
| 193 | extraParams: |
| 194 | - "-max_log_size=0" |
| 195 | - '-write_req_log_file=""' |
| 196 | - '-read_req_log_file=""' |
| 197 | - "-v=0" |
| 198 | - "-stderrthreshold=0" |
| 199 | - "-bf_switchd_background=false" |
| 200 | |
| 201 | nodeSelector: |
| 202 | node-role.aetherproject.org: switch |
| 203 | |
| 204 | tolerations: |
| 205 | - effect: NoSchedule |
| 206 | value: switch |
| 207 | key: node-role.aetherproject.org |
| 208 | |
| 209 | config: |
| 210 | server: gerrit.opencord.org |
| 211 | repo: aether-pod-configs |
| 212 | folder: staging/ace-onf-menlo/tost/stratum |
| 213 | |
| 214 | Stratum has the same deployment workflow as ONOS. |
| 215 | Once it is deployed to Kubernetes, it will read switch-dependent config files from the aether-pod-configs repo. |
| 216 | The key folder indicates that relative path of configs. |
| 217 | |
| 218 | .. attention:: |
| 219 | |
| 220 | The switch-dependent config file should be named as **${hostname}-chassis-config.pb.txt**. |
| 221 | For example, if the host name of your Tofino switch is **my-leaf**, please name config file **my-leaf-config.pb.txt**. |
| 222 | |
| 223 | .. |
| 224 | TODO: Add an example based on the recommended topology |
| 225 | |
| 226 | Telegraf folder |
| 227 | ^^^^^^^^^^^^^^^ |
| 228 | |
| 229 | The app_map.tfvars specify the Helm Chart version and the filename of the custom Helm value file. |
| 230 | |
| 231 | .. code-block:: |
| 232 | |
| 233 | apps=["telegraf"] |
| 234 | |
| 235 | app_map = { |
| 236 | telegraf= { |
| 237 | app_name = "telegraf" |
| 238 | project_name = "tost" |
| 239 | target_namespace = "telegraf" |
| 240 | catalog_name = "influxdata" |
| 241 | template_name = "telegraf" |
| 242 | template_version = "1.7.23" |
| 243 | values_yaml = ["telegraf.yaml"] |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | The **telegraf.yaml** used to override the Telegraf Helm Chart and its environment-dependent. |
| 248 | Please pay attention to the **inputs.addresses** section. |
| 249 | Telegraf will read data from stratum so we need to specify all Tofino switch’s IP addresses here. |
| 250 | Taking Menlo staging pod as example, there are four switches so we fill out 4 IP addresses. |
| 251 | |
| 252 | .. code-block:: yaml |
| 253 | |
| 254 | podAnnotations: |
| 255 | field.cattle.io/workloadMetrics: '[{"path":"/metrics","port":9273,"schema":"HTTP"}]' |
| 256 | |
| 257 | config: |
| 258 | outputs: |
| 259 | - prometheus_client: |
| 260 | metric_version: 2 |
| 261 | listen: ":9273" |
| 262 | inputs: |
| 263 | - cisco_telemetry_gnmi: |
| 264 | addresses: |
| 265 | - 10.92.1.81:9339 |
| 266 | - 10.92.1.82:9339 |
| 267 | - 10.92.1.83:9339 |
| 268 | - 10.92.1.84:9339 |
| 269 | redial: 10s |
| 270 | - cisco_telemetry_gnmi.subscription: |
| 271 | name: stratum_counters |
| 272 | origin: openconfig-interfaces |
| 273 | path: /interfaces/interface[name=*]/state/counters |
| 274 | sample_interval: 5000ns |
| 275 | subscription_mode: sample |
| 276 | |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 277 | |
| 278 | Create Your Own Configs |
| 279 | ^^^^^^^^^^^^^^^^^^^^^^^ |
| 280 | |
| 281 | The easiest way to create your own configs is running the template script. |
| 282 | |
| 283 | Assumed we would like to set up the **ace-example** pod in the production environment. |
| 284 | |
| 285 | 1. open the **tools/ace_env** |
| 286 | 2. fill out all required variables |
| 287 | 3. import the environment variables from **tools/ace_env** |
| 288 | 4. perform the makefile command to generate configuration and directory for TOST |
| 289 | 5. update **onos-netcfg.json** for ONOS |
| 290 | 6. update **${hostname}-chassis-config.pb.txt** for Stratum |
| 291 | 7. update all switch IPs in **telegraf.yaml** |
| 292 | 8. commit your change and open the Gerrit patch |
| 293 | |
| 294 | .. code-block:: console |
| 295 | |
| 296 | vim tools/ace_env |
| 297 | source tools/ace_env |
| 298 | make -C tools/ tost |
| 299 | vim production/ace-example/tost/onos/onos-netcfg.json |
| 300 | vim production/ace-example/tost/stratum/*${hostname}-chassis-config.pb.txt** |
| 301 | vim production/ace-example/tost/telegraf/telegraf.yam |
| 302 | git add commit |
| 303 | git review |
| 304 | |
| 305 | |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 306 | Quick recap |
| 307 | ^^^^^^^^^^^ |
| 308 | |
| 309 | To recap, most of the files in **tost** folder can be copied from existing examples. |
| 310 | However, there are a few files we need to pay extra attentions to. |
| 311 | |
| 312 | - **onos-netcfg.json** in **onos** folder |
| 313 | - Chassis config in **stratum** folder |
Zack Williams | 794532a | 2021-03-18 17:38:36 -0700 | [diff] [blame] | 314 | There should be one chassis config for each switch. The file name needs to be |
| 315 | **${hostname}-chassis-config.pb.txt** |
| 316 | - **telegraf.yaml** in **telegraf** folder need to be updated with all switch |
| 317 | IP addresses |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 318 | |
| 319 | Double check these files and make sure they have been updated accordingly. |
| 320 | |
| 321 | |
| 322 | Create a review request |
| 323 | ^^^^^^^^^^^^^^^^^^^^^^^ |
Zack Williams | 794532a | 2021-03-18 17:38:36 -0700 | [diff] [blame] | 324 | We also need to create a gerrit review request, similar to what we have done in |
| 325 | the **Aether Runtime Deployment**. |
| 326 | |
| 327 | Please refer to :doc:`Aether Runtime Deployment <runtime_deployment>` to |
| 328 | create a review request. |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 329 | |
| 330 | |
| 331 | Create TOST deployment job in Jenkins |
| 332 | ===================================== |
Zack Williams | 794532a | 2021-03-18 17:38:36 -0700 | [diff] [blame] | 333 | There are three major components in the Jenkins system, the Jenkins pipeline |
| 334 | and Jenkins Job Builder and Jenkins Job. |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 335 | |
Zack Williams | 794532a | 2021-03-18 17:38:36 -0700 | [diff] [blame] | 336 | We follow the Infrastructure as Code principle to place three major components |
| 337 | in a Git repo, ``aether-ci-management`` |
| 338 | |
| 339 | Download the ``aether-ci-management`` repository. |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 340 | |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 341 | .. code-block:: shell |
| 342 | |
| 343 | $ cd $WORKDIR |
| 344 | $ git clone "ssh://[username]@gerrit.opencord.org:29418/aether-ci-management" |
| 345 | |
| 346 | |
Zack Williams | 794532a | 2021-03-18 17:38:36 -0700 | [diff] [blame] | 347 | Here is the example of folder structure, we put everything related to three |
| 348 | major components under the jjb folder. |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 349 | |
| 350 | .. code-block:: console |
| 351 | |
| 352 | $ tree -d jjb |
| 353 | jjb |
| 354 | ├── ci-management |
| 355 | ├── global |
| 356 | │ ├── jenkins-admin -> ../../global-jjb/jenkins-admin |
| 357 | │ ├── jenkins-init-scripts -> ../../global-jjb/jenkins-init-scripts |
| 358 | │ ├── jjb -> ../../global-jjb/jjb |
| 359 | │ └── shell -> ../../global-jjb/shell |
| 360 | ├── pipeline |
| 361 | ├── repos |
| 362 | ├── shell |
| 363 | └── templates |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 364 | |
| 365 | |
| 366 | Jenkins pipeline |
| 367 | ^^^^^^^^^^^^^^^^ |
Zack Williams | 794532a | 2021-03-18 17:38:36 -0700 | [diff] [blame] | 368 | Jenkins pipeline runs the Terraform scripts to install desired applications |
| 369 | into the specified Kubernetes cluster. |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 370 | |
Zack Williams | 794532a | 2021-03-18 17:38:36 -0700 | [diff] [blame] | 371 | Both ONOS and Stratum will read configuration files (network config, chassis |
| 372 | config) from aether-pod-config. |
| 373 | |
| 374 | The default git branch is master. For testing purpose, we also provide two |
| 375 | parameters to specify the number of reviews and patchset. |
| 376 | |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 377 | We will explain more in the next section. |
| 378 | |
| 379 | .. note:: |
| 380 | |
| 381 | Currently, we don’t perform the incremental upgrade for TOST application. |
| 382 | Instead, we perform the clean installation. |
Zack Williams | 794532a | 2021-03-18 17:38:36 -0700 | [diff] [blame] | 383 | In the pipeline script, Terraform will destroy all existing resources and |
| 384 | then create them again. |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 385 | |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 386 | |
Zack Williams | 794532a | 2021-03-18 17:38:36 -0700 | [diff] [blame] | 387 | We put all pipeline scripts under the pipeline directory, the language of the |
| 388 | pipeline script is groovy. |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 389 | |
| 390 | .. code-block:: console |
| 391 | |
| 392 | $ tree pipeline |
| 393 | pipeline |
| 394 | ├── aether-in-a-box.groovy |
| 395 | ├── artifact-release.groovy |
| 396 | ├── cd-pipeline-charts-postrelease.groovy |
| 397 | ├── cd-pipeline-dockerhub-postrelease.groovy |
| 398 | ├── cd-pipeline-postrelease.groovy |
| 399 | ├── cd-pipeline-terraform.groovy |
| 400 | ├── docker-publish.groovy |
| 401 | ├── ng40-func.groovy |
| 402 | ├── ng40-scale.groovy |
| 403 | ├── reuse-scan-gerrit.groovy |
| 404 | ├── reuse-scan-github.groovy |
| 405 | ├── tost-onos.groovy |
| 406 | ├── tost-stratum.groovy |
| 407 | ├── tost-telegraf.groovy |
| 408 | └── tost.groovy |
| 409 | |
| 410 | Currently, we had four pipeline scripts for TOST deployment. |
| 411 | |
| 412 | 1. tost-onos.groovy |
| 413 | 2. tost-stratum.groovy |
| 414 | 3. tost-telegraf.groovy |
| 415 | 4. tost.groovy |
| 416 | |
Zack Williams | 794532a | 2021-03-18 17:38:36 -0700 | [diff] [blame] | 417 | tost-[onos/stratum/telegraf].groovy are used to deploy the individual |
| 418 | application respectively, and tost.groovy is a high level script, used to |
| 419 | deploy the TOST application, it will execute the above three scripts in its |
| 420 | pipeline script. |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 421 | |
| 422 | |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 423 | Jenkins jobs |
| 424 | ^^^^^^^^^^^^ |
| 425 | |
| 426 | Jenkins job is the task unit in the Jenkins system. A Jenkins job contains the following information: |
| 427 | |
| 428 | - Jenkins pipeline |
| 429 | - Parameters for Jenkins pipeline |
| 430 | - Build trigger |
| 431 | - Source code management |
| 432 | |
| 433 | We created one Jenkins job for each TOST component, per Aether edge. |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 434 | |
Zack Williams | 794532a | 2021-03-18 17:38:36 -0700 | [diff] [blame] | 435 | We have four Jenkins jobs (HostPath provisioner, ONOS, Stratum and Telegraf) |
| 436 | for each edge as of today. |
| 437 | |
| 438 | There are 10+ parameters in Jenkins jobs and they can be divided into two |
| 439 | parts, cluster-level and application-level. |
| 440 | |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 441 | Here is an example of supported parameters. |
| 442 | |
| 443 | .. image:: images/jenkins-onos-params.png |
| 444 | :width: 480px |
| 445 | |
| 446 | Application level |
| 447 | """"""""""""""""" |
| 448 | |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 449 | - **GERRIT_CHANGE_NUMBER/GERRIT_PATCHSET_NUMBER**: tell the pipeline script to read |
| 450 | the config for aether-pod-configs repo from a specified gerrit review, instead of the |
| 451 | HEAD branch. It’s good for developer to test its change before merge. |
| 452 | - **onos_user**: used to login ONOS controller |
Zack Williams | 794532a | 2021-03-18 17:38:36 -0700 | [diff] [blame] | 453 | - **git_repo/git_server/git_user/git_password_env**: information of git |
| 454 | repository, **git_password_env** is a key for Jenkins Credential system. |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 455 | |
| 456 | Cluster level |
| 457 | """"""""""""" |
Zack Williams | 794532a | 2021-03-18 17:38:36 -0700 | [diff] [blame] | 458 | - **gcp_credential**: Google Cloud Platform credential for remote storage, used |
| 459 | by Terraform. |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 460 | - **terraform_dir**: The root directory of the TOST directory. |
| 461 | - **rancher_cluster**: target Rancher cluster name. |
| 462 | - **rancher_api_env**: Rancher credential to access Rancher, used by Terraform. |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 463 | |
| 464 | .. note:: |
| 465 | |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 466 | Typically, developer only focus on **GERRIT_CHANGE_NUMBER** and **GERRIT_PATCHSET_NUMBER**. The rest of them are managed by OPs. |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 467 | |
| 468 | Jenkins Job Builder (JJB) |
| 469 | ^^^^^^^^^^^^^^^^^^^^^^^^^ |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 470 | |
Zack Williams | 794532a | 2021-03-18 17:38:36 -0700 | [diff] [blame] | 471 | We prefer to apply the IaC (Infrastructure as Code) for everything. We use the |
| 472 | JJB (Jenkins Job Builder) to create new Jenkins Job, including the Jenkins |
| 473 | pipeline. We need to clone a set of Jenkins jobs when a new edge is deployed. |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 474 | |
Zack Williams | 794532a | 2021-03-18 17:38:36 -0700 | [diff] [blame] | 475 | In order to provide the flexibility and avoid re-inventing the wheel, we used |
| 476 | the job template to declare your job. Thanks to the JJB, we can use the |
| 477 | parameters in the job template to render different kinds of jobs easily. |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 478 | |
| 479 | All the template files are placed under templates directory. |
| 480 | |
| 481 | .. code-block:: console |
| 482 | |
| 483 | ╰─$ tree templates |
| 484 | templates |
| 485 | ├── aether-in-a-box.yaml |
| 486 | ├── archive-artifacts.yaml |
| 487 | ├── artifact-release.yml |
| 488 | ├── cd-pipeline-terraform.yaml |
| 489 | ├── docker-publish-github.yaml |
| 490 | ├── docker-publish.yaml |
| 491 | ├── helm-lint.yaml |
| 492 | ├── make-test.yaml |
| 493 | ├── ng40-nightly.yaml |
| 494 | ├── ng40-test.yaml |
| 495 | ├── private-docker-publish.yaml |
| 496 | ├── private-make-test.yaml |
| 497 | ├── publish-helm-repo.yaml |
| 498 | ├── reuse-gerrit.yaml |
| 499 | ├── reuse-github.yaml |
| 500 | ├── sync-dir.yaml |
| 501 | ├── tost.yaml |
| 502 | ├── verify-licensed.yaml |
| 503 | └── versioning.yaml |
| 504 | |
Zack Williams | 794532a | 2021-03-18 17:38:36 -0700 | [diff] [blame] | 505 | We defined all TOST required job templates in tost.yaml and here is its partial |
| 506 | content. |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 507 | |
| 508 | .. code-block:: yaml |
| 509 | |
| 510 | - job-template: |
| 511 | name: "{name}-onos" |
| 512 | id: "deploy-onos" |
| 513 | project-type: pipeline |
| 514 | dsl: !include-raw-escape: jjb/pipeline/tost-onos.groovy |
| 515 | triggers: |
| 516 | - onf-infra-tost-gerrit-trigger: |
| 517 | gerrit-server-name: '{gerrit-server-name}' |
| 518 | trigger_command: "apply" |
| 519 | pattern: "{terraform_dir}/tost/onos/.*" |
| 520 | logrotate: |
| 521 | daysToKeep: 7 |
| 522 | numToKeep: 10 |
| 523 | artifactDaysToKeep: 7 |
| 524 | artifactNumToKeep: 10 |
| 525 | parameters: |
| 526 | - string: |
| 527 | name: gcp_credential |
| 528 | default: "{google_bucket_access}" |
| 529 | - string: |
| 530 | name: rancher_cluster |
| 531 | default: "{rancher_cluster}" |
| 532 | - string: |
| 533 | name: rancher_api_env |
| 534 | default: "{rancher_api}" |
| 535 | - string: |
| 536 | name: git_repo |
| 537 | default: "aether-pod-configs" |
| 538 | - string: |
| 539 | name: git_server |
| 540 | default: "gerrit.opencord.org" |
| 541 | - string: |
| 542 | name: git_ssh_user |
| 543 | default: "jenkins" |
| 544 | |
| 545 | |
| 546 | |
| 547 | |
| 548 | Once we have the job template, we need to tell the JJB, we want to use the job template to create our own jobs. |
| 549 | Here comes the concept of project, you need to define job templates you want to use and the values of all parameters. |
| 550 | |
| 551 | |
| 552 | We put all project yaml files under the repo directory and here is the example |
| 553 | |
| 554 | .. code-block:: console |
| 555 | |
| 556 | ╰─$ tree repos 130 ↵ |
| 557 | repos |
| 558 | ├── aether-helm-charts.yaml |
| 559 | ├── aether-in-a-box.yaml |
| 560 | ├── cd-pipeline-terraform.yaml |
| 561 | ├── ng40-test.yaml |
| 562 | ├── spgw.yaml |
| 563 | └── tost.yaml |
| 564 | |
| 565 | |
| 566 | Following is the example of tost projects, we defined three projects here, and each project has different |
| 567 | parameters and Jenkins jobs it wants to use. |
| 568 | |
| 569 | .. code-block:: yaml |
| 570 | |
| 571 | - project: |
| 572 | name: deploy-menlo-tost-dev |
| 573 | rancher_cluster: "menlo-tost-dev" |
| 574 | terraform_dir: "testing/menlo-tost" |
| 575 | rancher_api: "{rancher_testing_access}" |
| 576 | jobs: |
| 577 | - "deploy" |
| 578 | - "deploy-onos" |
| 579 | - "deploy-stratum" |
| 580 | - "deploy-telegraf" |
| 581 | - project: |
| 582 | name: deploy-menlo-tost-staging |
| 583 | rancher_cluster: "ace-menlo" |
| 584 | terraform_dir: "staging/ace-menlo" |
| 585 | rancher_api: "{rancher_staging_access}" |
| 586 | jobs: |
| 587 | - "deploy" |
| 588 | - "deploy-onos" |
| 589 | - "deploy-stratum" |
| 590 | - "deploy-telegraf" |
| 591 | - project: |
| 592 | name: deploy-menlo-production |
| 593 | rancher_cluster: "ace-menlo" |
| 594 | terraform_dir: "production/ace-menlo" |
| 595 | rancher_api: "{rancher_production_access}" |
| 596 | jobs: |
| 597 | - "deploy" |
| 598 | - "deploy-onos" |
| 599 | - "deploy-stratum" |
| 600 | - "deploy-telegraf" |
| 601 | |
| 602 | |
| 603 | Create Your Own Jenkins Job |
| 604 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 605 | |
| 606 | Basically, if you don't need to customize the Jenkins pipeline script and the job configuration, the only thing |
| 607 | you need to do is modify the repos/tost.yaml to add your project. |
| 608 | |
| 609 | For example, we would like to deploy the TOST to our production pod, let's assume it named "tost-example". |
| 610 | Add the following content into repos/tost.yaml |
| 611 | |
| 612 | .. code-block:: yaml |
| 613 | |
| 614 | - project: |
| 615 | name: deploy-tost-example-production |
| 616 | rancher_cluster: "ace-test-example" |
| 617 | terraform_dir: "production/tost-example" |
| 618 | rancher_api: "{rancher_production_access}" |
| 619 | jobs: |
| 620 | - "deploy" |
| 621 | - "deploy-onos" |
| 622 | - "deploy-stratum" |
| 623 | - "deploy-telegraf" |
| 624 | |
| 625 | |
| 626 | .. note:: |
| 627 | |
| 628 | The **terraform_dir** indicates the directory location in aether-pod-configs repo, please ensure your Terraform scripts |
| 629 | already there before running the Jenkins job. |
| 630 | |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 631 | |
| 632 | Trigger TOST deployment in Jenkins |
| 633 | ================================== |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 634 | Whenever a change is merged into **aether-pod-config**, |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 635 | the Jenkins job should be triggered automatically to (re)deploy TOST. |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 636 | |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 637 | You can also type the comment **apply** in the Gerrit patch, it will trigger Jenkins jobs to deploy TOST for you. |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 638 | |
Charles Chan | 2cb05c7 | 2020-12-09 16:31:20 -0800 | [diff] [blame] | 639 | |
| 640 | Verification |
| 641 | ============ |
| 642 | Fabric connectivity should be fully ready at this point. |
| 643 | We should verify that **all servers**, including compute nodes and the management server, |
| 644 | have an IP address and are **able to reach each other via fabric interface** before continuing the next step. |
| 645 | |
| 646 | This can be simply done by running a **ping** command from one server to another server's fabric IP. |
| 647 | |
| 648 | |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 649 | Troubleshooting |
| 650 | =============== |
| 651 | |
| 652 | The deployment process involves the following steps: |
| 653 | |
| 654 | 1. Jenkins Job |
| 655 | 2. Jenkins Pipeline |
| 656 | 3. Clone Git Repository |
| 657 | 4. Execute Terraform scripts |
| 658 | 5. Rancher start to install applications |
| 659 | 6. Applications be deployed into Kubernetes cluster |
| 660 | 7. ONOS/Stratum will read the configuration (network config, chassis config) |
| 661 | 8. Pod become running |
| 662 | |
| 663 | Taking ONOS as an example, here's what you can do to troubleshoot. |
| 664 | |
| 665 | You can see the log message of the first 4 steps in Jenkins console. |
| 666 | If something goes wrong, the status of the Jenkins job will be in red. |
| 667 | If Jenkins doesn't report any error message, the next step is going to Rancher's portal |
| 668 | to ensure the Answers is same as the *onos.yaml* in *aether-pod-configs*. |