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 | |
| 21 | def call(Map config) { |
Joey Armstrong | 96158a9 | 2022-11-25 10:36:06 -0500 | [diff] [blame] | 22 | |
| 23 | String iam = 'vars/volthaDeploy.groovy' |
| 24 | println("** ${iam}: ENTER") |
| 25 | |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 26 | // 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] | 27 | // [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] | 28 | def defaultConfig = [ |
| 29 | onosReplica: 1, |
| 30 | atomixReplica: 1, |
| 31 | kafkaReplica: 1, |
| 32 | etcdReplica: 1, |
| 33 | bbsimReplica: 1, |
| 34 | infraNamespace: "infra", |
| 35 | volthaNamespace: "voltha", |
Matteo Scandolo | 2bc660a | 2021-02-12 10:52:25 -0800 | [diff] [blame] | 36 | stackName: "voltha", |
| 37 | stackId: 1, |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 38 | workflow: "att", |
Hardik Windlass | 810b6cf | 2022-02-24 09:21:18 +0000 | [diff] [blame] | 39 | withMacLearning: false, |
Hardik Windlass | c97ceae | 2022-05-13 10:12:55 +0530 | [diff] [blame] | 40 | withFttb: false, |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 41 | extraHelmFlags: "", |
Matteo Scandolo | fcfc60d | 2021-02-24 09:06:48 -0800 | [diff] [blame] | 42 | localCharts: false, // wether to use locally cloned charts or upstream one (for local we assume they are stored in $WORKSPACE/voltha-helm-charts) |
Matteo Scandolo | 37f168b | 2021-04-15 16:20:46 -0700 | [diff] [blame] | 43 | dockerRegistry: "", // use a different docker registry for all images, eg: "mirror.registry.opennetworking.org" |
Matteo Scandolo | d82d1de | 2021-04-06 14:55:58 -0700 | [diff] [blame] | 44 | kubeconfig: null, // location of the kubernetes config file, if null we assume it's stored in the $KUBECONFIG environment variable |
Hardik Windlass | 230fca6 | 2022-05-04 08:50:35 +0530 | [diff] [blame] | 45 | withVolthaInfra: true, |
| 46 | withVolthaStack: true, |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 47 | ] |
| 48 | |
| 49 | if (!config) { |
| 50 | config = [:] |
| 51 | } |
| 52 | |
| 53 | def cfg = defaultConfig + config |
| 54 | |
Matteo Scandolo | 37f168b | 2021-04-15 16:20:46 -0700 | [diff] [blame] | 55 | if (cfg.dockerRegistry != "") { |
Matteo Scandolo | 5244aaa | 2021-04-28 09:28:58 -0700 | [diff] [blame] | 56 | def registryFlags = " --set global.image_registry=${cfg.dockerRegistry}/ " |
| 57 | registryFlags += " --set etcd.image.registry=${cfg.dockerRegistry} " |
| 58 | registryFlags += " --set kafka.image.registry=${cfg.dockerRegistry} " |
| 59 | registryFlags += " --set kafka.zookeper.image.registry=${cfg.dockerRegistry} " |
| 60 | registryFlags += " --set onos-classic.image.repository=${cfg.dockerRegistry}/voltha/voltha-onos " |
| 61 | registryFlags += " --set onos-classic.atomix.image.repository=${cfg.dockerRegistry}/atomix/atomix " |
| 62 | registryFlags += " --set freeradius.images.radius.registry=${cfg.dockerRegistry}/ " |
| 63 | |
Andrea Campanella | b29ca1e | 2021-05-06 17:45:27 +0200 | [diff] [blame] | 64 | // we want to always leave the user provided flags at the end, to override changes |
Matteo Scandolo | 5244aaa | 2021-04-28 09:28:58 -0700 | [diff] [blame] | 65 | cfg.extraHelmFlags = registryFlags + " " + cfg.extraHelmFlags |
Matteo Scandolo | 37f168b | 2021-04-15 16:20:46 -0700 | [diff] [blame] | 66 | } |
| 67 | |
Andrea Campanella | b29ca1e | 2021-05-06 17:45:27 +0200 | [diff] [blame] | 68 | // Add helm repositories |
| 69 | println "Updating helm repos" |
| 70 | |
| 71 | sh """ |
| 72 | helm repo add onf https://charts.opencord.org |
| 73 | helm repo update |
| 74 | """ |
| 75 | |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 76 | println "Deploying VOLTHA with the following parameters: ${cfg}." |
| 77 | |
Hardik Windlass | 230fca6 | 2022-05-04 08:50:35 +0530 | [diff] [blame] | 78 | if (cfg.withVolthaInfra) { |
| 79 | volthaInfraDeploy(cfg) |
| 80 | } |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 81 | |
Hardik Windlass | 230fca6 | 2022-05-04 08:50:35 +0530 | [diff] [blame] | 82 | if (cfg.withVolthaStack) { |
| 83 | volthaStackDeploy(cfg) |
| 84 | } |
Joey Armstrong | 96158a9 | 2022-11-25 10:36:06 -0500 | [diff] [blame] | 85 | |
| 86 | println("** ${iam}: LEAVE") |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 87 | } |
Joey Armstrong | af679da | 2023-01-31 14:22:41 -0500 | [diff] [blame] | 88 | |
| 89 | // [EOF] |