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 | |
Hung-Wei Chiu | d06947b | 2021-08-10 16:10:07 -0700 | [diff] [blame] | 5 | SDFabric Deployment |
| 6 | =================== |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 7 | |
Zack Williams | 1ae109e | 2021-07-27 11:17:04 -0700 | [diff] [blame] | 8 | Update aether-pod-configs |
| 9 | ------------------------- |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 10 | |
Zack Williams | 1ae109e | 2021-07-27 11:17:04 -0700 | [diff] [blame] | 11 | ``aether-pod-configs`` is a git project hosted on **gerrit.opencord.org** and |
| 12 | we placed the following materials in it. |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 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 |
Hung-Wei Chiu | d06947b | 2021-08-10 16:10:07 -0700 | [diff] [blame] | 34 | │ ├── kubeconfig -> ../../../../common/tost/apps/onos/kubeconfig/ |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 35 | │ ├── main.tf -> ../../../../common/tost/apps/onos/main.tf |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 36 | │ ├── onos.yaml |
| 37 | │ └── variables.tf -> ../../../../common/tost/apps/onos/variables.tf |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 38 | ├── stratum |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 39 | │ ├── app_map.tfvars |
| 40 | │ ├── backend.tf |
| 41 | │ ├── main.tf -> ../../../../common/tost/apps/stratum/main.tf |
| 42 | │ ├── menlo-staging-leaf-1-chassis-config.pb.txt |
| 43 | │ ├── menlo-staging-leaf-2-chassis-config.pb.txt |
| 44 | │ ├── menlo-staging-spine-1-chassis-config.pb.txt |
| 45 | │ ├── menlo-staging-spine-2-chassis-config.pb.txt |
| 46 | │ ├── stratum.yaml |
| 47 | │ ├── tost-dev-chassis-config.pb.txt |
| 48 | │ └── variables.tf -> ../../../../common/tost/apps/stratum/variables.tf |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 49 | ├── telegraf |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 50 | │ ├── app_map.tfvars |
| 51 | │ ├── backend.tf |
| 52 | │ ├── main.tf -> ../../../../common/tost/apps/telegraf/main.tf |
| 53 | │ ├── telegraf.yaml |
| 54 | │ └── variables.tf -> ../../../../common/tost/apps/telegraf/variables.tf |
| 55 | └── variables.tf -> ../../../common/tost/variables.tf |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 56 | |
| 57 | There are four Terraform scripts inside **tost** directory and are responsible for managing each service. |
| 58 | |
| 59 | Root folder |
Zack Williams | bcc4c2b | 2021-04-07 16:58:03 -0700 | [diff] [blame] | 60 | """"""""""" |
| 61 | |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 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 | |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 75 | |
| 76 | ONOS folder |
Zack Williams | bcc4c2b | 2021-04-07 16:58:03 -0700 | [diff] [blame] | 77 | """"""""""" |
| 78 | |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 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" |
Hung-Wei Chiu | d06947b | 2021-08-10 16:10:07 -0700 | [diff] [blame] | 96 | template_version = "0.1.40" |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 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: |
Hung-Wei Chiu | d06947b | 2021-08-10 16:10:07 -0700 | [diff] [blame] | 146 | netcfg: > |
| 147 | { |
| 148 | "devices": { |
| 149 | "device:leaf1": { |
| 150 | "segmentrouting": { |
| 151 | "ipv4NodeSid": 201, |
| 152 | "ipv4Loopback": "10.128.100.38", |
| 153 | "routerMac": "00:00:0A:80:64:26", |
| 154 | "isEdgeRouter": true, |
| 155 | "adjacencySids": [] |
| 156 | }, |
| 157 | } |
| 158 | } |
| 159 | } |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 160 | |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 161 | |
Hung-Wei Chiu | d06947b | 2021-08-10 16:10:07 -0700 | [diff] [blame] | 162 | **config.netcfg** is environment dependent and please change it to fit your environment. |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 163 | |
| 164 | .. |
| 165 | TODO: Add an example based on the recommended topology |
| 166 | |
| 167 | Stratum folder |
Zack Williams | bcc4c2b | 2021-04-07 16:58:03 -0700 | [diff] [blame] | 168 | """""""""""""" |
| 169 | |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 170 | Stratum uses a similar directory structure as ONOS for Terraform and its configuration files. |
| 171 | |
| 172 | The customize value file is named **stratum.yaml** |
| 173 | |
| 174 | .. code-block:: |
| 175 | |
| 176 | app_map = { |
| 177 | stratum= { |
| 178 | app_name = "stratum" |
| 179 | project_name = "tost" |
| 180 | target_namespace = "stratum" |
| 181 | catalog_name = "stratum" |
| 182 | template_name = "stratum" |
Hung-Wei Chiu | d06947b | 2021-08-10 16:10:07 -0700 | [diff] [blame] | 183 | template_version = "0.1.13" |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 184 | values_yaml = ["stratum.yaml"] |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | Like ONOS, **stratum.yaml** used to customize Stratum Helm Chart and please pay attention to the config section. |
| 189 | |
| 190 | .. code-block:: yaml |
| 191 | |
| 192 | image: |
| 193 | registry: registry.aetherproject.org |
| 194 | repository: tost/stratum-bfrt |
| 195 | tag: 9.2.0-4.14.49 |
| 196 | pullPolicy: Always |
| 197 | pullSecrets: |
| 198 | - aether-registry-credential |
| 199 | |
| 200 | extraParams: |
| 201 | - "-max_log_size=0" |
| 202 | - '-write_req_log_file=""' |
| 203 | - '-read_req_log_file=""' |
| 204 | - "-v=0" |
| 205 | - "-stderrthreshold=0" |
| 206 | - "-bf_switchd_background=false" |
| 207 | |
| 208 | nodeSelector: |
| 209 | node-role.aetherproject.org: switch |
| 210 | |
| 211 | tolerations: |
| 212 | - effect: NoSchedule |
| 213 | value: switch |
| 214 | key: node-role.aetherproject.org |
| 215 | |
| 216 | config: |
| 217 | server: gerrit.opencord.org |
| 218 | repo: aether-pod-configs |
| 219 | folder: staging/ace-onf-menlo/tost/stratum |
| 220 | |
| 221 | Stratum has the same deployment workflow as ONOS. |
| 222 | Once it is deployed to Kubernetes, it will read switch-dependent config files from the aether-pod-configs repo. |
| 223 | The key folder indicates that relative path of configs. |
| 224 | |
| 225 | .. attention:: |
| 226 | |
| 227 | The switch-dependent config file should be named as **${hostname}-chassis-config.pb.txt**. |
| 228 | For example, if the host name of your Tofino switch is **my-leaf**, please name config file **my-leaf-config.pb.txt**. |
| 229 | |
| 230 | .. |
| 231 | TODO: Add an example based on the recommended topology |
| 232 | |
| 233 | Telegraf folder |
Zack Williams | bcc4c2b | 2021-04-07 16:58:03 -0700 | [diff] [blame] | 234 | """"""""""""""" |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 235 | |
| 236 | The app_map.tfvars specify the Helm Chart version and the filename of the custom Helm value file. |
| 237 | |
| 238 | .. code-block:: |
| 239 | |
| 240 | apps=["telegraf"] |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 241 | app_map = { |
Hung-Wei Chiu | d06947b | 2021-08-10 16:10:07 -0700 | [diff] [blame] | 242 | telegraf = { |
| 243 | app_name = "telegraf" |
| 244 | project_name = "tost" |
| 245 | target_namespace = "tost" |
| 246 | catalog_name = "aether" |
| 247 | template_name = "tost-telegraf" |
| 248 | template_version = "0.1.1" |
| 249 | values_yaml = ["telegraf.yaml"] |
| 250 | } |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 251 | } |
| 252 | |
Hung-Wei Chiu | d06947b | 2021-08-10 16:10:07 -0700 | [diff] [blame] | 253 | The **telegraf.yaml** used to override the ONOS-Telegraf Helm Chart and its environment-dependent. |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 254 | Please pay attention to the **inputs.addresses** section. |
| 255 | Telegraf will read data from stratum so we need to specify all Tofino switch’s IP addresses here. |
| 256 | Taking Menlo staging pod as example, there are four switches so we fill out 4 IP addresses. |
| 257 | |
| 258 | .. code-block:: yaml |
| 259 | |
| 260 | podAnnotations: |
| 261 | field.cattle.io/workloadMetrics: '[{"path":"/metrics","port":9273,"schema":"HTTP"}]' |
| 262 | |
| 263 | config: |
| 264 | outputs: |
| 265 | - prometheus_client: |
| 266 | metric_version: 2 |
| 267 | listen: ":9273" |
| 268 | inputs: |
| 269 | - cisco_telemetry_gnmi: |
| 270 | addresses: |
| 271 | - 10.92.1.81:9339 |
| 272 | - 10.92.1.82:9339 |
| 273 | - 10.92.1.83:9339 |
| 274 | - 10.92.1.84:9339 |
| 275 | redial: 10s |
| 276 | - cisco_telemetry_gnmi.subscription: |
| 277 | name: stratum_counters |
| 278 | origin: openconfig-interfaces |
| 279 | path: /interfaces/interface[name=*]/state/counters |
| 280 | sample_interval: 5000ns |
| 281 | subscription_mode: sample |
| 282 | |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 283 | |
| 284 | Create Your Own Configs |
Zack Williams | bcc4c2b | 2021-04-07 16:58:03 -0700 | [diff] [blame] | 285 | """"""""""""""""""""""" |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 286 | |
| 287 | The easiest way to create your own configs is running the template script. |
| 288 | |
| 289 | Assumed we would like to set up the **ace-example** pod in the production environment. |
| 290 | |
Hung-Wei Chiu | d06947b | 2021-08-10 16:10:07 -0700 | [diff] [blame] | 291 | 1. open the **tools/ace_config.yaml** (You should already have this file when you finish VPN bootstrap stage) |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 292 | 2. fill out all required variables |
Hung-Wei Chiu | d06947b | 2021-08-10 16:10:07 -0700 | [diff] [blame] | 293 | 3. perform the makefile command to generate configuration and directory for TOST |
| 294 | 4. update **onos.yaml** for ONOS |
| 295 | 5. update **${hostname}-chassis-config.pb.txt** for Stratum |
| 296 | 6. commit your change and open the Gerrit patch |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 297 | |
| 298 | .. code-block:: console |
| 299 | |
Hung-Wei Chiu | d06947b | 2021-08-10 16:10:07 -0700 | [diff] [blame] | 300 | vim tools/ace_config.yaml |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 301 | make -C tools/ tost |
Hung-Wei Chiu | d06947b | 2021-08-10 16:10:07 -0700 | [diff] [blame] | 302 | vim production/ace-example/tost/onos/onos.yaml |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 303 | vim production/ace-example/tost/stratum/*${hostname}-chassis-config.pb.txt** |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 304 | git add commit |
| 305 | git review |
| 306 | |
| 307 | |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 308 | Quick recap |
Zack Williams | bcc4c2b | 2021-04-07 16:58:03 -0700 | [diff] [blame] | 309 | """"""""""" |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 310 | |
| 311 | To recap, most of the files in **tost** folder can be copied from existing examples. |
| 312 | However, there are a few files we need to pay extra attentions to. |
| 313 | |
Hung-Wei Chiu | d06947b | 2021-08-10 16:10:07 -0700 | [diff] [blame] | 314 | - **onos.yaml** in **onos** folder |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 315 | - Chassis config in **stratum** folder |
Zack Williams | 794532a | 2021-03-18 17:38:36 -0700 | [diff] [blame] | 316 | There should be one chassis config for each switch. The file name needs to be |
| 317 | **${hostname}-chassis-config.pb.txt** |
| 318 | - **telegraf.yaml** in **telegraf** folder need to be updated with all switch |
| 319 | IP addresses |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 320 | |
| 321 | Double check these files and make sure they have been updated accordingly. |
| 322 | |
| 323 | |
| 324 | Create a review request |
Zack Williams | bcc4c2b | 2021-04-07 16:58:03 -0700 | [diff] [blame] | 325 | """"""""""""""""""""""" |
| 326 | |
Zack Williams | 794532a | 2021-03-18 17:38:36 -0700 | [diff] [blame] | 327 | We also need to create a gerrit review request, similar to what we have done in |
| 328 | the **Aether Runtime Deployment**. |
| 329 | |
| 330 | Please refer to :doc:`Aether Runtime Deployment <runtime_deployment>` to |
| 331 | create a review request. |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 332 | |
| 333 | |
| 334 | Create TOST deployment job in Jenkins |
Zack Williams | bcc4c2b | 2021-04-07 16:58:03 -0700 | [diff] [blame] | 335 | ------------------------------------- |
| 336 | |
Zack Williams | 794532a | 2021-03-18 17:38:36 -0700 | [diff] [blame] | 337 | There are three major components in the Jenkins system, the Jenkins pipeline |
| 338 | and Jenkins Job Builder and Jenkins Job. |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 339 | |
Zack Williams | 794532a | 2021-03-18 17:38:36 -0700 | [diff] [blame] | 340 | We follow the Infrastructure as Code principle to place three major components |
| 341 | in a Git repo, ``aether-ci-management`` |
| 342 | |
| 343 | Download the ``aether-ci-management`` repository. |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 344 | |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 345 | .. code-block:: shell |
| 346 | |
| 347 | $ cd $WORKDIR |
| 348 | $ git clone "ssh://[username]@gerrit.opencord.org:29418/aether-ci-management" |
| 349 | |
| 350 | |
Zack Williams | 794532a | 2021-03-18 17:38:36 -0700 | [diff] [blame] | 351 | Here is the example of folder structure, we put everything related to three |
| 352 | major components under the jjb folder. |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 353 | |
| 354 | .. code-block:: console |
| 355 | |
| 356 | $ tree -d jjb |
| 357 | jjb |
| 358 | ├── ci-management |
| 359 | ├── global |
| 360 | │ ├── jenkins-admin -> ../../global-jjb/jenkins-admin |
| 361 | │ ├── jenkins-init-scripts -> ../../global-jjb/jenkins-init-scripts |
| 362 | │ ├── jjb -> ../../global-jjb/jjb |
| 363 | │ └── shell -> ../../global-jjb/shell |
| 364 | ├── pipeline |
| 365 | ├── repos |
| 366 | ├── shell |
| 367 | └── templates |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 368 | |
| 369 | |
| 370 | Jenkins pipeline |
Zack Williams | bcc4c2b | 2021-04-07 16:58:03 -0700 | [diff] [blame] | 371 | """""""""""""""" |
| 372 | |
Zack Williams | 794532a | 2021-03-18 17:38:36 -0700 | [diff] [blame] | 373 | Jenkins pipeline runs the Terraform scripts to install desired applications |
| 374 | into the specified Kubernetes cluster. |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 375 | |
Zack Williams | 794532a | 2021-03-18 17:38:36 -0700 | [diff] [blame] | 376 | Both ONOS and Stratum will read configuration files (network config, chassis |
| 377 | config) from aether-pod-config. |
| 378 | |
| 379 | The default git branch is master. For testing purpose, we also provide two |
| 380 | parameters to specify the number of reviews and patchset. |
| 381 | |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 382 | We will explain more in the next section. |
| 383 | |
| 384 | .. note:: |
| 385 | |
| 386 | Currently, we don’t perform the incremental upgrade for TOST application. |
| 387 | Instead, we perform the clean installation. |
Zack Williams | 794532a | 2021-03-18 17:38:36 -0700 | [diff] [blame] | 388 | In the pipeline script, Terraform will destroy all existing resources and |
| 389 | then create them again. |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 390 | |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 391 | |
Zack Williams | 794532a | 2021-03-18 17:38:36 -0700 | [diff] [blame] | 392 | We put all pipeline scripts under the pipeline directory, the language of the |
| 393 | pipeline script is groovy. |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 394 | |
| 395 | .. code-block:: console |
| 396 | |
| 397 | $ tree pipeline |
| 398 | pipeline |
| 399 | ├── aether-in-a-box.groovy |
| 400 | ├── artifact-release.groovy |
| 401 | ├── cd-pipeline-charts-postrelease.groovy |
| 402 | ├── cd-pipeline-dockerhub-postrelease.groovy |
| 403 | ├── cd-pipeline-postrelease.groovy |
| 404 | ├── cd-pipeline-terraform.groovy |
| 405 | ├── docker-publish.groovy |
| 406 | ├── ng40-func.groovy |
| 407 | ├── ng40-scale.groovy |
| 408 | ├── reuse-scan-gerrit.groovy |
| 409 | ├── reuse-scan-github.groovy |
| 410 | ├── tost-onos.groovy |
| 411 | ├── tost-stratum.groovy |
| 412 | ├── tost-telegraf.groovy |
| 413 | └── tost.groovy |
| 414 | |
| 415 | Currently, we had four pipeline scripts for TOST deployment. |
| 416 | |
| 417 | 1. tost-onos.groovy |
| 418 | 2. tost-stratum.groovy |
| 419 | 3. tost-telegraf.groovy |
| 420 | 4. tost.groovy |
| 421 | |
Zack Williams | 794532a | 2021-03-18 17:38:36 -0700 | [diff] [blame] | 422 | tost-[onos/stratum/telegraf].groovy are used to deploy the individual |
| 423 | application respectively, and tost.groovy is a high level script, used to |
| 424 | deploy the TOST application, it will execute the above three scripts in its |
| 425 | pipeline script. |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 426 | |
| 427 | |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 428 | Jenkins jobs |
Zack Williams | bcc4c2b | 2021-04-07 16:58:03 -0700 | [diff] [blame] | 429 | """""""""""" |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 430 | |
| 431 | Jenkins job is the task unit in the Jenkins system. A Jenkins job contains the following information: |
| 432 | |
| 433 | - Jenkins pipeline |
| 434 | - Parameters for Jenkins pipeline |
| 435 | - Build trigger |
| 436 | - Source code management |
| 437 | |
| 438 | We created one Jenkins job for each TOST component, per Aether edge. |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 439 | |
Zack Williams | 794532a | 2021-03-18 17:38:36 -0700 | [diff] [blame] | 440 | We have four Jenkins jobs (HostPath provisioner, ONOS, Stratum and Telegraf) |
| 441 | for each edge as of today. |
| 442 | |
| 443 | There are 10+ parameters in Jenkins jobs and they can be divided into two |
| 444 | parts, cluster-level and application-level. |
| 445 | |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 446 | Here is an example of supported parameters. |
| 447 | |
| 448 | .. image:: images/jenkins-onos-params.png |
| 449 | :width: 480px |
| 450 | |
| 451 | Application level |
Zack Williams | bcc4c2b | 2021-04-07 16:58:03 -0700 | [diff] [blame] | 452 | ''''''''''''''''' |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 453 | |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 454 | - **GERRIT_CHANGE_NUMBER/GERRIT_PATCHSET_NUMBER**: tell the pipeline script to read |
| 455 | the config for aether-pod-configs repo from a specified gerrit review, instead of the |
| 456 | HEAD branch. It’s good for developer to test its change before merge. |
| 457 | - **onos_user**: used to login ONOS controller |
Zack Williams | 794532a | 2021-03-18 17:38:36 -0700 | [diff] [blame] | 458 | - **git_repo/git_server/git_user/git_password_env**: information of git |
| 459 | repository, **git_password_env** is a key for Jenkins Credential system. |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 460 | |
| 461 | Cluster level |
Zack Williams | bcc4c2b | 2021-04-07 16:58:03 -0700 | [diff] [blame] | 462 | ''''''''''''' |
| 463 | |
Zack Williams | 794532a | 2021-03-18 17:38:36 -0700 | [diff] [blame] | 464 | - **gcp_credential**: Google Cloud Platform credential for remote storage, used |
| 465 | by Terraform. |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 466 | - **terraform_dir**: The root directory of the TOST directory. |
| 467 | - **rancher_cluster**: target Rancher cluster name. |
| 468 | - **rancher_api_env**: Rancher credential to access Rancher, used by Terraform. |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 469 | |
| 470 | .. note:: |
| 471 | |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 472 | 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] | 473 | |
| 474 | Jenkins Job Builder (JJB) |
Zack Williams | bcc4c2b | 2021-04-07 16:58:03 -0700 | [diff] [blame] | 475 | """"""""""""""""""""""""" |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 476 | |
Zack Williams | 794532a | 2021-03-18 17:38:36 -0700 | [diff] [blame] | 477 | We prefer to apply the IaC (Infrastructure as Code) for everything. We use the |
| 478 | JJB (Jenkins Job Builder) to create new Jenkins Job, including the Jenkins |
| 479 | 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] | 480 | |
Zack Williams | 794532a | 2021-03-18 17:38:36 -0700 | [diff] [blame] | 481 | In order to provide the flexibility and avoid re-inventing the wheel, we used |
| 482 | the job template to declare your job. Thanks to the JJB, we can use the |
| 483 | 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] | 484 | |
| 485 | All the template files are placed under templates directory. |
| 486 | |
| 487 | .. code-block:: console |
| 488 | |
| 489 | ╰─$ tree templates |
| 490 | templates |
| 491 | ├── aether-in-a-box.yaml |
| 492 | ├── archive-artifacts.yaml |
| 493 | ├── artifact-release.yml |
| 494 | ├── cd-pipeline-terraform.yaml |
| 495 | ├── docker-publish-github.yaml |
| 496 | ├── docker-publish.yaml |
| 497 | ├── helm-lint.yaml |
| 498 | ├── make-test.yaml |
| 499 | ├── ng40-nightly.yaml |
| 500 | ├── ng40-test.yaml |
| 501 | ├── private-docker-publish.yaml |
| 502 | ├── private-make-test.yaml |
| 503 | ├── publish-helm-repo.yaml |
| 504 | ├── reuse-gerrit.yaml |
| 505 | ├── reuse-github.yaml |
| 506 | ├── sync-dir.yaml |
| 507 | ├── tost.yaml |
| 508 | ├── verify-licensed.yaml |
| 509 | └── versioning.yaml |
| 510 | |
Zack Williams | 794532a | 2021-03-18 17:38:36 -0700 | [diff] [blame] | 511 | We defined all TOST required job templates in tost.yaml and here is its partial |
| 512 | content. |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 513 | |
| 514 | .. code-block:: yaml |
| 515 | |
| 516 | - job-template: |
| 517 | name: "{name}-onos" |
| 518 | id: "deploy-onos" |
| 519 | project-type: pipeline |
| 520 | dsl: !include-raw-escape: jjb/pipeline/tost-onos.groovy |
| 521 | triggers: |
| 522 | - onf-infra-tost-gerrit-trigger: |
| 523 | gerrit-server-name: '{gerrit-server-name}' |
| 524 | trigger_command: "apply" |
| 525 | pattern: "{terraform_dir}/tost/onos/.*" |
| 526 | logrotate: |
| 527 | daysToKeep: 7 |
| 528 | numToKeep: 10 |
| 529 | artifactDaysToKeep: 7 |
| 530 | artifactNumToKeep: 10 |
| 531 | parameters: |
| 532 | - string: |
| 533 | name: gcp_credential |
| 534 | default: "{google_bucket_access}" |
| 535 | - string: |
| 536 | name: rancher_cluster |
| 537 | default: "{rancher_cluster}" |
| 538 | - string: |
| 539 | name: rancher_api_env |
| 540 | default: "{rancher_api}" |
| 541 | - string: |
| 542 | name: git_repo |
| 543 | default: "aether-pod-configs" |
| 544 | - string: |
| 545 | name: git_server |
| 546 | default: "gerrit.opencord.org" |
| 547 | - string: |
| 548 | name: git_ssh_user |
| 549 | default: "jenkins" |
| 550 | |
| 551 | |
| 552 | |
| 553 | |
| 554 | Once we have the job template, we need to tell the JJB, we want to use the job template to create our own jobs. |
| 555 | Here comes the concept of project, you need to define job templates you want to use and the values of all parameters. |
| 556 | |
| 557 | |
| 558 | We put all project yaml files under the repo directory and here is the example |
| 559 | |
| 560 | .. code-block:: console |
| 561 | |
| 562 | ╰─$ tree repos 130 ↵ |
| 563 | repos |
| 564 | ├── aether-helm-charts.yaml |
| 565 | ├── aether-in-a-box.yaml |
| 566 | ├── cd-pipeline-terraform.yaml |
| 567 | ├── ng40-test.yaml |
| 568 | ├── spgw.yaml |
| 569 | └── tost.yaml |
| 570 | |
| 571 | |
| 572 | Following is the example of tost projects, we defined three projects here, and each project has different |
| 573 | parameters and Jenkins jobs it wants to use. |
| 574 | |
| 575 | .. code-block:: yaml |
| 576 | |
Hung-Wei Chiu | d06947b | 2021-08-10 16:10:07 -0700 | [diff] [blame] | 577 | |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 578 | - project: |
Hung-Wei Chiu | d06947b | 2021-08-10 16:10:07 -0700 | [diff] [blame] | 579 | name: deploy-tucson-pairedleaves-dev |
| 580 | rancher_cluster: "dev-pairedleaves-tucson" |
| 581 | terraform_dir: "staging/dev-pairedleaves-tucson" |
| 582 | rancher_api: "{rancher_staging_access}" |
| 583 | properties: |
| 584 | - onf-infra-onfstaff-private |
| 585 | jobs: |
| 586 | - "deploy" |
| 587 | - "deploy-onos" |
| 588 | - "deploy-stratum" |
| 589 | - "deploy-telegraf" |
| 590 | - "debug-tost" |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 591 | |
| 592 | |
| 593 | Create Your Own Jenkins Job |
Zack Williams | bcc4c2b | 2021-04-07 16:58:03 -0700 | [diff] [blame] | 594 | """"""""""""""""""""""""""" |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 595 | |
| 596 | Basically, if you don't need to customize the Jenkins pipeline script and the job configuration, the only thing |
| 597 | you need to do is modify the repos/tost.yaml to add your project. |
| 598 | |
| 599 | For example, we would like to deploy the TOST to our production pod, let's assume it named "tost-example". |
| 600 | Add the following content into repos/tost.yaml |
| 601 | |
| 602 | .. code-block:: yaml |
| 603 | |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 604 | |
Hung-Wei Chiu | d06947b | 2021-08-10 16:10:07 -0700 | [diff] [blame] | 605 | - project: |
| 606 | name: deploy-tost-example-production |
| 607 | rancher_cluster: "ace-test-example" |
| 608 | terraform_dir: "production/tost-example" |
| 609 | rancher_api: "{rancher_production_access}" |
| 610 | properties: |
| 611 | - onf-infra-onfstaff-private |
| 612 | jobs: |
| 613 | - "deploy" |
| 614 | - "deploy-onos" |
| 615 | - "deploy-stratum" |
| 616 | - "deploy-telegraf" |
| 617 | - "debug-tost" |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 618 | |
| 619 | .. note:: |
| 620 | |
| 621 | The **terraform_dir** indicates the directory location in aether-pod-configs repo, please ensure your Terraform scripts |
| 622 | already there before running the Jenkins job. |
| 623 | |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 624 | |
| 625 | Trigger TOST deployment in Jenkins |
Zack Williams | bcc4c2b | 2021-04-07 16:58:03 -0700 | [diff] [blame] | 626 | ---------------------------------- |
| 627 | |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 628 | Whenever a change is merged into **aether-pod-config**, |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 629 | the Jenkins job should be triggered automatically to (re)deploy TOST. |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 630 | |
Hung-Wei Chiu | f7cadb3 | 2020-11-19 04:49:35 +0000 | [diff] [blame] | 631 | 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] | 632 | |
Charles Chan | 2cb05c7 | 2020-12-09 16:31:20 -0800 | [diff] [blame] | 633 | |
| 634 | Verification |
Zack Williams | bcc4c2b | 2021-04-07 16:58:03 -0700 | [diff] [blame] | 635 | ------------ |
| 636 | |
Charles Chan | 2cb05c7 | 2020-12-09 16:31:20 -0800 | [diff] [blame] | 637 | Fabric connectivity should be fully ready at this point. |
| 638 | We should verify that **all servers**, including compute nodes and the management server, |
| 639 | have an IP address and are **able to reach each other via fabric interface** before continuing the next step. |
| 640 | |
| 641 | This can be simply done by running a **ping** command from one server to another server's fabric IP. |
| 642 | |
| 643 | |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 644 | Troubleshooting |
Zack Williams | bcc4c2b | 2021-04-07 16:58:03 -0700 | [diff] [blame] | 645 | --------------- |
Charles Chan | 4a10722 | 2020-10-30 17:23:48 -0700 | [diff] [blame] | 646 | |
| 647 | The deployment process involves the following steps: |
| 648 | |
| 649 | 1. Jenkins Job |
| 650 | 2. Jenkins Pipeline |
| 651 | 3. Clone Git Repository |
| 652 | 4. Execute Terraform scripts |
| 653 | 5. Rancher start to install applications |
| 654 | 6. Applications be deployed into Kubernetes cluster |
| 655 | 7. ONOS/Stratum will read the configuration (network config, chassis config) |
| 656 | 8. Pod become running |
| 657 | |
| 658 | Taking ONOS as an example, here's what you can do to troubleshoot. |
| 659 | |
| 660 | You can see the log message of the first 4 steps in Jenkins console. |
| 661 | If something goes wrong, the status of the Jenkins job will be in red. |
| 662 | If Jenkins doesn't report any error message, the next step is going to Rancher's portal |
| 663 | to ensure the Answers is same as the *onos.yaml* in *aether-pod-configs*. |
Zack Williams | bcc4c2b | 2021-04-07 16:58:03 -0700 | [diff] [blame] | 664 | |
| 665 | Accessing the Stratum CLI |
| 666 | """"""""""""""""""""""""" |
| 667 | |
| 668 | You can login to the Stratum container running on a switch using this script: |
| 669 | |
| 670 | .. code-block:: sh |
| 671 | |
| 672 | #!/bin/bash |
| 673 | echo 'Attaching to Stratum container. Ctrl-P Ctrl-Q to exit' |
| 674 | echo 'Press Enter to continue...' |
| 675 | DOCKER_ID=`docker ps | grep stratum-bf | awk '{print $1}'` |
| 676 | docker attach $DOCKER_ID |
| 677 | |
Zack Williams | 1ae109e | 2021-07-27 11:17:04 -0700 | [diff] [blame] | 678 | You should then see the ``bf_sde`` prompt: |
Zack Williams | bcc4c2b | 2021-04-07 16:58:03 -0700 | [diff] [blame] | 679 | |
| 680 | .. code-block:: sh |
| 681 | |
| 682 | bf_sde> pm |
| 683 | bf_sde.pm> show -a |
| 684 | |
| 685 | Accessing the ONOS CLI |
| 686 | """""""""""""""""""""" |
| 687 | |
| 688 | After setting up kubectl to access the TOST pods, run: |
| 689 | |
| 690 | .. code-block:: sh |
| 691 | |
| 692 | $ kubectl get pods -n tost |
| 693 | |
| 694 | Pick a TOST pod, and make a port forward to it, then login to it with the |
| 695 | ``onos`` CLI tool: |
| 696 | |
| 697 | .. code-block:: sh |
| 698 | |
| 699 | $ kubectl -n tost port-forward onos-tost-onos-classic-0 8181 8101 |
| 700 | $ onos karaf@localhost |
| 701 | |
| 702 | In some rare cases, you may need to access the ONOS master instance CLI, in |
| 703 | which case you can run ``roles``: |
| 704 | |
| 705 | .. code-block:: sh |
| 706 | |
| 707 | karaf@root > roles |
| 708 | device:devswitch1: master=onos-tost-onos-classic-1, standbys=[ onos-tost-onos-classic-0 ] |
| 709 | |
| 710 | Above lines show that ``onos-tost-onos-classic-1`` is the master. So switch to |
| 711 | that by killing the port forward, starting a new one pointing at the master, |
| 712 | then logging into that one: |
| 713 | |
| 714 | .. code-block:: sh |
| 715 | |
| 716 | $ ps ax | grep -i kubectl |
| 717 | # returns kubectl commands running, pick the port-forward one and kill it |
| 718 | $ kill 0123 |
| 719 | $ kubectl -n tost port-forward onos-tost-onos-classic-1 8181 8101 |
| 720 | $ onos karaf@localhost |
| 721 | |