Joey Armstrong | 96158a9 | 2022-11-25 10:36:06 -0500 | [diff] [blame] | 1 | #!/usr/bin/env groovy |
Joey Armstrong | af679da | 2023-01-31 14:22:41 -0500 | [diff] [blame] | 2 | // ----------------------------------------------------------------------- |
| 3 | // Copyright 2021-2023 Open Networking Foundation (ONF) and the ONF Contributors |
| 4 | // |
| 5 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | // you may not use this file except in compliance with the License. |
| 7 | // You may obtain a copy of the License at |
| 8 | // |
| 9 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | // |
| 11 | // Unless required by applicable law or agreed to in writing, software |
| 12 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | // See the License for the specific language governing permissions and |
| 15 | // limitations under the License. |
| 16 | // ----------------------------------------------------------------------- |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 17 | // this keyword is dedicated to deploy a single VOLTHA stack with infra |
| 18 | // If you need to deploy different configurations you can use the volthaInfraDeploy and volthaStackDeploy keywords |
Joey Armstrong | af679da | 2023-01-31 14:22:41 -0500 | [diff] [blame] | 19 | // ----------------------------------------------------------------------- |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 20 | |
Joey Armstrong | c33a0bf | 2023-09-08 14:41:23 -0400 | [diff] [blame^] | 21 | // ----------------------------------------------------------------------- |
| 22 | // ----------------------------------------------------------------------- |
| 23 | String getIam(String func) { |
| 24 | // Cannot rely on a stack trace due to jenkins manipulation |
| 25 | String src = 'vars/volthaDeploy.groovy' |
| 26 | String iam = [src, func].join('::') |
| 27 | return iam |
| 28 | } |
| 29 | |
| 30 | // ----------------------------------------------------------------------- |
| 31 | // Intent: Log progress message |
| 32 | // ----------------------------------------------------------------------- |
| 33 | void enter(String name) { |
| 34 | // Announce ourselves for log usability |
| 35 | String iam = getIam(name) |
| 36 | println("${iam}: ENTER") |
| 37 | return |
| 38 | } |
| 39 | |
| 40 | // ----------------------------------------------------------------------- |
| 41 | // Intent: Log progress message |
| 42 | // ----------------------------------------------------------------------- |
| 43 | void leave(String name) { |
| 44 | // Announce ourselves for log usability |
| 45 | String iam = getIam(name) |
| 46 | println("${iam}: LEAVE") |
| 47 | return |
| 48 | } |
| 49 | |
| 50 | // ----------------------------------------------------------------------- |
| 51 | // Intent: Perform volthaDeploy stuff |
| 52 | // ----------------------------------------------------------------------- |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 53 | def call(Map config) { |
Joey Armstrong | 96158a9 | 2022-11-25 10:36:06 -0500 | [diff] [blame] | 54 | |
Joey Armstrong | c33a0bf | 2023-09-08 14:41:23 -0400 | [diff] [blame^] | 55 | // String iam = 'vars/volthaDeploy.groovy' |
| 56 | enter('main') |
Joey Armstrong | 96158a9 | 2022-11-25 10:36:06 -0500 | [diff] [blame] | 57 | |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 58 | // note that I can't define this outside the function as there's no global scope in Groovy |
Joey Armstrong | 96158a9 | 2022-11-25 10:36:06 -0500 | [diff] [blame] | 59 | // [joey] A class method or library call can be used in place of globals, fqdn needed. |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 60 | def defaultConfig = [ |
Joey Armstrong | c33a0bf | 2023-09-08 14:41:23 -0400 | [diff] [blame^] | 61 | onosReplica: 1, |
| 62 | atomixReplica: 1, |
| 63 | kafkaReplica: 1, |
| 64 | etcdReplica: 1, |
| 65 | bbsimReplica: 1, |
| 66 | infraNamespace: "infra", |
| 67 | volthaNamespace: "voltha", |
| 68 | stackName: "voltha", |
| 69 | stackId: 1, |
| 70 | workflow: "att", |
| 71 | withMacLearning: false, |
| 72 | withFttb: false, |
| 73 | extraHelmFlags: "", |
| 74 | localCharts: false, // wether to use locally cloned charts or upstream one (for local we assume they are stored in $WORKSPACE/voltha-helm-charts) |
| 75 | dockerRegistry: "", // use a different docker registry for all images, eg: "mirror.registry.opennetworking.org" |
| 76 | kubeconfig: null, // location of the kubernetes config file, if null we assume it's stored in the $KUBECONFIG environment variable |
| 77 | withVolthaInfra: true, |
| 78 | withVolthaStack: true, |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 79 | ] |
| 80 | |
| 81 | if (!config) { |
| 82 | config = [:] |
| 83 | } |
| 84 | |
| 85 | def cfg = defaultConfig + config |
| 86 | |
Matteo Scandolo | 37f168b | 2021-04-15 16:20:46 -0700 | [diff] [blame] | 87 | if (cfg.dockerRegistry != "") { |
Joey Armstrong | c33a0bf | 2023-09-08 14:41:23 -0400 | [diff] [blame^] | 88 | def registryFlags = " --set global.image_registry=${cfg.dockerRegistry}/ " |
| 89 | registryFlags += " --set etcd.image.registry=${cfg.dockerRegistry} " |
| 90 | registryFlags += " --set kafka.image.registry=${cfg.dockerRegistry} " |
| 91 | registryFlags += " --set kafka.zookeper.image.registry=${cfg.dockerRegistry} " |
| 92 | registryFlags += " --set onos-classic.image.repository=${cfg.dockerRegistry}/voltha/voltha-onos " |
| 93 | registryFlags += " --set onos-classic.atomix.image.repository=${cfg.dockerRegistry}/atomix/atomix " |
| 94 | registryFlags += " --set freeradius.images.radius.registry=${cfg.dockerRegistry}/ " |
Matteo Scandolo | 5244aaa | 2021-04-28 09:28:58 -0700 | [diff] [blame] | 95 | |
Joey Armstrong | c33a0bf | 2023-09-08 14:41:23 -0400 | [diff] [blame^] | 96 | // we want to always leave the user provided flags at the end, to override changes |
| 97 | cfg.extraHelmFlags = registryFlags + " " + cfg.extraHelmFlags |
Matteo Scandolo | 37f168b | 2021-04-15 16:20:46 -0700 | [diff] [blame] | 98 | } |
| 99 | |
Andrea Campanella | b29ca1e | 2021-05-06 17:45:27 +0200 | [diff] [blame] | 100 | // Add helm repositories |
| 101 | println "Updating helm repos" |
| 102 | |
Joey Armstrong | c33a0bf | 2023-09-08 14:41:23 -0400 | [diff] [blame^] | 103 | sh(label : 'Configure helm repo', |
| 104 | script : """ |
| 105 | helm repo add onf https://charts.opencord.org |
| 106 | helm repo update |
| 107 | """) |
Andrea Campanella | b29ca1e | 2021-05-06 17:45:27 +0200 | [diff] [blame] | 108 | |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 109 | println "Deploying VOLTHA with the following parameters: ${cfg}." |
| 110 | |
Hardik Windlass | 230fca6 | 2022-05-04 08:50:35 +0530 | [diff] [blame] | 111 | if (cfg.withVolthaInfra) { |
Joey Armstrong | c33a0bf | 2023-09-08 14:41:23 -0400 | [diff] [blame^] | 112 | volthaInfraDeploy(cfg) |
Hardik Windlass | 230fca6 | 2022-05-04 08:50:35 +0530 | [diff] [blame] | 113 | } |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 114 | |
Hardik Windlass | 230fca6 | 2022-05-04 08:50:35 +0530 | [diff] [blame] | 115 | if (cfg.withVolthaStack) { |
Joey Armstrong | c33a0bf | 2023-09-08 14:41:23 -0400 | [diff] [blame^] | 116 | volthaStackDeploy(cfg) |
Hardik Windlass | 230fca6 | 2022-05-04 08:50:35 +0530 | [diff] [blame] | 117 | } |
Joey Armstrong | 96158a9 | 2022-11-25 10:36:06 -0500 | [diff] [blame] | 118 | |
Joey Armstrong | c33a0bf | 2023-09-08 14:41:23 -0400 | [diff] [blame^] | 119 | leave('main') |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 120 | } |
Joey Armstrong | af679da | 2023-01-31 14:22:41 -0500 | [diff] [blame] | 121 | |
| 122 | // [EOF] |