blob: cf76133111d43addf8b19930eb20e2642f511f22 [file] [log] [blame]
Joey Armstrong96158a92022-11-25 10:36:06 -05001#!/usr/bin/env groovy
2
Matteo Scandolo42f6e572021-01-25 15:11:34 -08003// 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
6def call(Map config) {
Joey Armstrong96158a92022-11-25 10:36:06 -05007
8 String iam = 'vars/volthaDeploy.groovy'
9 println("** ${iam}: ENTER")
10
Matteo Scandolo42f6e572021-01-25 15:11:34 -080011 // note that I can't define this outside the function as there's no global scope in Groovy
Joey Armstrong96158a92022-11-25 10:36:06 -050012 // [joey] A class method or library call can be used in place of globals, fqdn needed.
Matteo Scandolo42f6e572021-01-25 15:11:34 -080013 def defaultConfig = [
14 onosReplica: 1,
15 atomixReplica: 1,
16 kafkaReplica: 1,
17 etcdReplica: 1,
18 bbsimReplica: 1,
19 infraNamespace: "infra",
20 volthaNamespace: "voltha",
Matteo Scandolo2bc660a2021-02-12 10:52:25 -080021 stackName: "voltha",
22 stackId: 1,
Matteo Scandolo42f6e572021-01-25 15:11:34 -080023 workflow: "att",
Hardik Windlass810b6cf2022-02-24 09:21:18 +000024 withMacLearning: false,
Hardik Windlassc97ceae2022-05-13 10:12:55 +053025 withFttb: false,
Matteo Scandolo42f6e572021-01-25 15:11:34 -080026 extraHelmFlags: "",
Matteo Scandolofcfc60d2021-02-24 09:06:48 -080027 localCharts: false, // wether to use locally cloned charts or upstream one (for local we assume they are stored in $WORKSPACE/voltha-helm-charts)
Matteo Scandolo37f168b2021-04-15 16:20:46 -070028 dockerRegistry: "", // use a different docker registry for all images, eg: "mirror.registry.opennetworking.org"
Matteo Scandolod82d1de2021-04-06 14:55:58 -070029 kubeconfig: null, // location of the kubernetes config file, if null we assume it's stored in the $KUBECONFIG environment variable
Hardik Windlass230fca62022-05-04 08:50:35 +053030 withVolthaInfra: true,
31 withVolthaStack: true,
Matteo Scandolo42f6e572021-01-25 15:11:34 -080032 ]
33
34 if (!config) {
35 config = [:]
36 }
37
38 def cfg = defaultConfig + config
39
Matteo Scandolo37f168b2021-04-15 16:20:46 -070040 if (cfg.dockerRegistry != "") {
Matteo Scandolo5244aaa2021-04-28 09:28:58 -070041 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 Campanellab29ca1e2021-05-06 17:45:27 +020049 // we want to always leave the user provided flags at the end, to override changes
Matteo Scandolo5244aaa2021-04-28 09:28:58 -070050 cfg.extraHelmFlags = registryFlags + " " + cfg.extraHelmFlags
Matteo Scandolo37f168b2021-04-15 16:20:46 -070051 }
52
Andrea Campanellab29ca1e2021-05-06 17:45:27 +020053 // 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 Scandolo42f6e572021-01-25 15:11:34 -080061 println "Deploying VOLTHA with the following parameters: ${cfg}."
62
Hardik Windlass230fca62022-05-04 08:50:35 +053063 if (cfg.withVolthaInfra) {
64 volthaInfraDeploy(cfg)
65 }
Matteo Scandolo42f6e572021-01-25 15:11:34 -080066
Hardik Windlass230fca62022-05-04 08:50:35 +053067 if (cfg.withVolthaStack) {
68 volthaStackDeploy(cfg)
69 }
Joey Armstrong96158a92022-11-25 10:36:06 -050070
71 println("** ${iam}: LEAVE")
Matteo Scandolo42f6e572021-01-25 15:11:34 -080072}