blob: a545da16fa44a96fb95fd481b09e9adc3e21b061 [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
Joey Armstrongc33a0bf2023-09-08 14:41:23 -040021// -----------------------------------------------------------------------
22// -----------------------------------------------------------------------
23String 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// -----------------------------------------------------------------------
33void 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// -----------------------------------------------------------------------
43void 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 Scandolo42f6e572021-01-25 15:11:34 -080053def call(Map config) {
Joey Armstrong96158a92022-11-25 10:36:06 -050054
Joey Armstrongc33a0bf2023-09-08 14:41:23 -040055 // String iam = 'vars/volthaDeploy.groovy'
56 enter('main')
Joey Armstrong96158a92022-11-25 10:36:06 -050057
Matteo Scandolo42f6e572021-01-25 15:11:34 -080058 // 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 -050059 // [joey] A class method or library call can be used in place of globals, fqdn needed.
Matteo Scandolo42f6e572021-01-25 15:11:34 -080060 def defaultConfig = [
Joey Armstrongc33a0bf2023-09-08 14:41:23 -040061 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 Scandolo42f6e572021-01-25 15:11:34 -080079 ]
80
81 if (!config) {
82 config = [:]
83 }
84
85 def cfg = defaultConfig + config
86
Matteo Scandolo37f168b2021-04-15 16:20:46 -070087 if (cfg.dockerRegistry != "") {
Joey Armstrongc33a0bf2023-09-08 14:41:23 -040088 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 Scandolo5244aaa2021-04-28 09:28:58 -070095
Joey Armstrongc33a0bf2023-09-08 14:41:23 -040096 // we want to always leave the user provided flags at the end, to override changes
97 cfg.extraHelmFlags = registryFlags + " " + cfg.extraHelmFlags
Matteo Scandolo37f168b2021-04-15 16:20:46 -070098 }
99
Andrea Campanellab29ca1e2021-05-06 17:45:27 +0200100 // Add helm repositories
101 println "Updating helm repos"
102
Joey Armstrongc33a0bf2023-09-08 14:41:23 -0400103 sh(label : 'Configure helm repo',
104 script : """
105helm repo add onf https://charts.opencord.org
106helm repo update
107""")
Andrea Campanellab29ca1e2021-05-06 17:45:27 +0200108
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800109 println "Deploying VOLTHA with the following parameters: ${cfg}."
110
Hardik Windlass230fca62022-05-04 08:50:35 +0530111 if (cfg.withVolthaInfra) {
Joey Armstrongc33a0bf2023-09-08 14:41:23 -0400112 volthaInfraDeploy(cfg)
Hardik Windlass230fca62022-05-04 08:50:35 +0530113 }
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800114
Hardik Windlass230fca62022-05-04 08:50:35 +0530115 if (cfg.withVolthaStack) {
Joey Armstrongc33a0bf2023-09-08 14:41:23 -0400116 volthaStackDeploy(cfg)
Hardik Windlass230fca62022-05-04 08:50:35 +0530117 }
Joey Armstrong96158a92022-11-25 10:36:06 -0500118
Joey Armstrongc33a0bf2023-09-08 14:41:23 -0400119 leave('main')
Matteo Scandolo42f6e572021-01-25 15:11:34 -0800120}
Joey Armstrongaf679da2023-01-31 14:22:41 -0500121
122// [EOF]