blob: fd03e510ce4a0766192e7982df4eb817a409c12f [file] [log] [blame]
Matteo Scandolo42f6e572021-01-25 15:11:34 -08001// usage
2//
3// stage('test stage') {
4// steps {
5// volthaDeploy([
6// onosReplica: 3
7// ])
8// }
9// }
10
11
12def call(Map config) {
13 // NOTE use params or directule extraHelmFlags??
14 def defaultConfig = [
15 onosReplica: 1,
16 atomixReplica: 1,
17 kafkaReplica: 1,
18 etcdReplica: 1,
19 infraNamespace: "infra",
20 workflow: "att",
Hardik Windlass810b6cf2022-02-24 09:21:18 +000021 withMacLearning: false,
Matteo Scandolo42f6e572021-01-25 15:11:34 -080022 extraHelmFlags: "",
Matteo Scandolofcfc60d2021-02-24 09:06:48 -080023 localCharts: false,
Matteo Scandolod82d1de2021-04-06 14:55:58 -070024 kubeconfig: null, // location of the kubernetes config file, if null we assume it's stored in the $KUBECONFIG environment variable
Matteo Scandolo42f6e572021-01-25 15:11:34 -080025 ]
26
27 if (!config) {
28 config = [:]
29 }
30
31 def cfg = defaultConfig + config
32
Matteo Scandolofcfc60d2021-02-24 09:06:48 -080033 def volthaInfraChart = "onf/voltha-infra"
34
35 if (cfg.localCharts) {
36 volthaInfraChart = "$WORKSPACE/voltha-helm-charts/voltha-infra"
37
38 sh """
39 pushd $WORKSPACE/voltha-helm-charts/voltha-infra
40 helm dep update
41 popd
42 """
43 }
44
Matteo Scandolo42f6e572021-01-25 15:11:34 -080045 println "Deploying VOLTHA Infra with the following parameters: ${cfg}."
46
Matteo Scandolod82d1de2021-04-06 14:55:58 -070047 def kubeconfig = cfg.kubeconfig
48 if (kubeconfig == null) {
49 kubeconfig = env.KUBECONFIG
50 }
51
Matteo Scandolo42f6e572021-01-25 15:11:34 -080052 sh """
53 kubectl create namespace ${cfg.infraNamespace} || true
Matteo Scandolod82d1de2021-04-06 14:55:58 -070054 kubectl create configmap -n ${cfg.infraNamespace} kube-config "--from-file=kube_config=${kubeconfig}" || true
Matteo Scandolo42f6e572021-01-25 15:11:34 -080055 """
Matteo Scandolod82d1de2021-04-06 14:55:58 -070056
Hardik Windlass810b6cf2022-02-24 09:21:18 +000057 def serviceConfigFile = cfg.workflow
58 if (cfg.withMacLearning && cfg.workflow == 'tt') {
59 serviceConfigFile = "tt-maclearner"
60 }
61
Matteo Scandoloa1b5d792021-06-01 12:19:31 -070062 // bitnamic/etch has change the replica format between the currently used 5.4.2 and the latest 6.2.5
63 // for now put both values in the extra helm chart flags
Matteo Scandolo42f6e572021-01-25 15:11:34 -080064 sh """
Matteo Scandoloed1afdd2021-04-02 16:25:45 -070065 helm upgrade --install --create-namespace -n ${cfg.infraNamespace} voltha-infra ${volthaInfraChart} \
Matteo Scandolo660e4af2021-04-02 11:16:09 -070066 --set onos-classic.replicas=${cfg.onosReplica},onos-classic.atomix.replicas=${cfg.atomixReplica} \
Matteo Scandolod43bb302021-04-20 10:19:29 -070067 --set kafka.replicaCount=${cfg.kafkaReplica},kafka.zookeeper.replicaCount=${cfg.kafkaReplica} \
68 --set etcd.statefulset.replicaCount=${cfg.etcdReplica} \
Matteo Scandoloa1b5d792021-06-01 12:19:31 -070069 --set etcd.replicaCount=${cfg.etcdReplica} \
Hardik Windlass810b6cf2022-02-24 09:21:18 +000070 -f $WORKSPACE/voltha-helm-charts/examples/${serviceConfigFile}-values.yaml ${cfg.extraHelmFlags}
Matteo Scandolo42f6e572021-01-25 15:11:34 -080071 """
72}