Joey Armstrong | 96158a9 | 2022-11-25 10:36:06 -0500 | [diff] [blame] | 1 | #!/usr/bin/env groovy |
| 2 | |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 3 | // this keyword is dedicated to deploy a single VOLTHA stack with infra |
| 4 | // If you need to deploy different configurations you can use the volthaInfraDeploy and volthaStackDeploy keywords |
| 5 | |
| 6 | def call(Map config) { |
Joey Armstrong | 96158a9 | 2022-11-25 10:36:06 -0500 | [diff] [blame] | 7 | |
| 8 | String iam = 'vars/volthaDeploy.groovy' |
| 9 | println("** ${iam}: ENTER") |
| 10 | |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 11 | // 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] | 12 | // [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] | 13 | def defaultConfig = [ |
| 14 | onosReplica: 1, |
| 15 | atomixReplica: 1, |
| 16 | kafkaReplica: 1, |
| 17 | etcdReplica: 1, |
| 18 | bbsimReplica: 1, |
| 19 | infraNamespace: "infra", |
| 20 | volthaNamespace: "voltha", |
Matteo Scandolo | 2bc660a | 2021-02-12 10:52:25 -0800 | [diff] [blame] | 21 | stackName: "voltha", |
| 22 | stackId: 1, |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 23 | workflow: "att", |
Hardik Windlass | 810b6cf | 2022-02-24 09:21:18 +0000 | [diff] [blame] | 24 | withMacLearning: false, |
Hardik Windlass | c97ceae | 2022-05-13 10:12:55 +0530 | [diff] [blame] | 25 | withFttb: false, |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 26 | extraHelmFlags: "", |
Matteo Scandolo | fcfc60d | 2021-02-24 09:06:48 -0800 | [diff] [blame] | 27 | 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] | 28 | 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] | 29 | 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] | 30 | withVolthaInfra: true, |
| 31 | withVolthaStack: true, |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 32 | ] |
| 33 | |
| 34 | if (!config) { |
| 35 | config = [:] |
| 36 | } |
| 37 | |
| 38 | def cfg = defaultConfig + config |
| 39 | |
Matteo Scandolo | 37f168b | 2021-04-15 16:20:46 -0700 | [diff] [blame] | 40 | if (cfg.dockerRegistry != "") { |
Matteo Scandolo | 5244aaa | 2021-04-28 09:28:58 -0700 | [diff] [blame] | 41 | def registryFlags = " --set global.image_registry=${cfg.dockerRegistry}/ " |
| 42 | registryFlags += " --set etcd.image.registry=${cfg.dockerRegistry} " |
| 43 | registryFlags += " --set kafka.image.registry=${cfg.dockerRegistry} " |
| 44 | registryFlags += " --set kafka.zookeper.image.registry=${cfg.dockerRegistry} " |
| 45 | registryFlags += " --set onos-classic.image.repository=${cfg.dockerRegistry}/voltha/voltha-onos " |
| 46 | registryFlags += " --set onos-classic.atomix.image.repository=${cfg.dockerRegistry}/atomix/atomix " |
| 47 | registryFlags += " --set freeradius.images.radius.registry=${cfg.dockerRegistry}/ " |
| 48 | |
Andrea Campanella | b29ca1e | 2021-05-06 17:45:27 +0200 | [diff] [blame] | 49 | // 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] | 50 | cfg.extraHelmFlags = registryFlags + " " + cfg.extraHelmFlags |
Matteo Scandolo | 37f168b | 2021-04-15 16:20:46 -0700 | [diff] [blame] | 51 | } |
| 52 | |
Andrea Campanella | b29ca1e | 2021-05-06 17:45:27 +0200 | [diff] [blame] | 53 | // Add helm repositories |
| 54 | println "Updating helm repos" |
| 55 | |
| 56 | sh """ |
| 57 | helm repo add onf https://charts.opencord.org |
| 58 | helm repo update |
| 59 | """ |
| 60 | |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 61 | println "Deploying VOLTHA with the following parameters: ${cfg}." |
| 62 | |
Hardik Windlass | 230fca6 | 2022-05-04 08:50:35 +0530 | [diff] [blame] | 63 | if (cfg.withVolthaInfra) { |
| 64 | volthaInfraDeploy(cfg) |
| 65 | } |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 66 | |
Hardik Windlass | 230fca6 | 2022-05-04 08:50:35 +0530 | [diff] [blame] | 67 | if (cfg.withVolthaStack) { |
| 68 | volthaStackDeploy(cfg) |
| 69 | } |
Joey Armstrong | 96158a9 | 2022-11-25 10:36:06 -0500 | [diff] [blame] | 70 | |
| 71 | println("** ${iam}: LEAVE") |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 72 | } |