blob: 37f5846c2e7804da64e9e9364178443b7b0a0c6d [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",
21 extraHelmFlags: "",
Matteo Scandolofcfc60d2021-02-24 09:06:48 -080022 localCharts: false,
Matteo Scandolo42f6e572021-01-25 15:11:34 -080023 ]
24
25 if (!config) {
26 config = [:]
27 }
28
29 def cfg = defaultConfig + config
30
Matteo Scandolofcfc60d2021-02-24 09:06:48 -080031 def volthaInfraChart = "onf/voltha-infra"
32
33 if (cfg.localCharts) {
34 volthaInfraChart = "$WORKSPACE/voltha-helm-charts/voltha-infra"
35
36 sh """
37 pushd $WORKSPACE/voltha-helm-charts/voltha-infra
38 helm dep update
39 popd
40 """
41 }
42
Matteo Scandolo42f6e572021-01-25 15:11:34 -080043 println "Deploying VOLTHA Infra with the following parameters: ${cfg}."
44
45 sh """
46 kubectl create namespace ${cfg.infraNamespace} || true
47 kubectl create configmap -n ${cfg.infraNamespace} kube-config "--from-file=kube_config=$KUBECONFIG" || true
48 """
49 // TODO support multiple replicas
50 sh """
Matteo Scandolofcfc60d2021-02-24 09:06:48 -080051 helm upgrade --install --create-namespace -n ${cfg.infraNamespace} voltha-infra ${volthaInfraChart} ${cfg.extraHelmFlags} \
Matteo Scandolo42f6e572021-01-25 15:11:34 -080052 -f $WORKSPACE/voltha-helm-charts/examples/${cfg.workflow}-values.yaml
53 """
54}