blob: 42c482a47443bbb9e0e4ae5b850a61f71135107f [file] [log] [blame]
Joey Armstrong96158a92022-11-25 10:36:06 -05001#!/usr/bin/env groovy
Joey Armstrongaf679da2023-01-31 14:22:41 -05002// -----------------------------------------------------------------------
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 Scandolo42f6e572021-01-25 15:11:34 -080017// 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 Armstrongaf679da2023-01-31 14:22:41 -050019// -----------------------------------------------------------------------
Matteo Scandolo42f6e572021-01-25 15:11:34 -080020
21def call(Map config) {
Joey Armstrong96158a92022-11-25 10:36:06 -050022
23 String iam = 'vars/volthaDeploy.groovy'
24 println("** ${iam}: ENTER")
25
Matteo Scandolo42f6e572021-01-25 15:11:34 -080026 // 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 -050027 // [joey] A class method or library call can be used in place of globals, fqdn needed.
Matteo Scandolo42f6e572021-01-25 15:11:34 -080028 def defaultConfig = [
29 onosReplica: 1,
30 atomixReplica: 1,
31 kafkaReplica: 1,
32 etcdReplica: 1,
33 bbsimReplica: 1,
34 infraNamespace: "infra",
35 volthaNamespace: "voltha",
Matteo Scandolo2bc660a2021-02-12 10:52:25 -080036 stackName: "voltha",
37 stackId: 1,
Matteo Scandolo42f6e572021-01-25 15:11:34 -080038 workflow: "att",
Hardik Windlass810b6cf2022-02-24 09:21:18 +000039 withMacLearning: false,
Hardik Windlassc97ceae2022-05-13 10:12:55 +053040 withFttb: false,
Matteo Scandolo42f6e572021-01-25 15:11:34 -080041 extraHelmFlags: "",
Matteo Scandolofcfc60d2021-02-24 09:06:48 -080042 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 -070043 dockerRegistry: "", // use a different docker registry for all images, eg: "mirror.registry.opennetworking.org"
Matteo Scandolod82d1de2021-04-06 14:55:58 -070044 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 +053045 withVolthaInfra: true,
46 withVolthaStack: true,
Matteo Scandolo42f6e572021-01-25 15:11:34 -080047 ]
48
49 if (!config) {
50 config = [:]
51 }
52
53 def cfg = defaultConfig + config
54
Matteo Scandolo37f168b2021-04-15 16:20:46 -070055 if (cfg.dockerRegistry != "") {
Matteo Scandolo5244aaa2021-04-28 09:28:58 -070056 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 Campanellab29ca1e2021-05-06 17:45:27 +020064 // we want to always leave the user provided flags at the end, to override changes
Matteo Scandolo5244aaa2021-04-28 09:28:58 -070065 cfg.extraHelmFlags = registryFlags + " " + cfg.extraHelmFlags
Matteo Scandolo37f168b2021-04-15 16:20:46 -070066 }
67
Andrea Campanellab29ca1e2021-05-06 17:45:27 +020068 // 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 Scandolo42f6e572021-01-25 15:11:34 -080076 println "Deploying VOLTHA with the following parameters: ${cfg}."
77
Hardik Windlass230fca62022-05-04 08:50:35 +053078 if (cfg.withVolthaInfra) {
79 volthaInfraDeploy(cfg)
80 }
Matteo Scandolo42f6e572021-01-25 15:11:34 -080081
Hardik Windlass230fca62022-05-04 08:50:35 +053082 if (cfg.withVolthaStack) {
83 volthaStackDeploy(cfg)
84 }
Joey Armstrong96158a92022-11-25 10:36:06 -050085
86 println("** ${iam}: LEAVE")
Matteo Scandolo42f6e572021-01-25 15:11:34 -080087}
Joey Armstrongaf679da2023-01-31 14:22:41 -050088
89// [EOF]