blob: 58bd800c74b0871b04d06c6dfcd240b6211ee990 [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 Scandolod82d1de2021-04-06 14:55:58 -070023 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 -080024 ]
25
26 if (!config) {
27 config = [:]
28 }
29
30 def cfg = defaultConfig + config
31
Matteo Scandolofcfc60d2021-02-24 09:06:48 -080032 def volthaInfraChart = "onf/voltha-infra"
33
34 if (cfg.localCharts) {
35 volthaInfraChart = "$WORKSPACE/voltha-helm-charts/voltha-infra"
36
37 sh """
38 pushd $WORKSPACE/voltha-helm-charts/voltha-infra
39 helm dep update
40 popd
41 """
42 }
43
Matteo Scandolo42f6e572021-01-25 15:11:34 -080044 println "Deploying VOLTHA Infra with the following parameters: ${cfg}."
45
Matteo Scandolod82d1de2021-04-06 14:55:58 -070046 def kubeconfig = cfg.kubeconfig
47 if (kubeconfig == null) {
48 kubeconfig = env.KUBECONFIG
49 }
50
Matteo Scandolo42f6e572021-01-25 15:11:34 -080051 sh """
52 kubectl create namespace ${cfg.infraNamespace} || true
Matteo Scandolod82d1de2021-04-06 14:55:58 -070053 kubectl create configmap -n ${cfg.infraNamespace} kube-config "--from-file=kube_config=${kubeconfig}" || true
Matteo Scandolo42f6e572021-01-25 15:11:34 -080054 """
Matteo Scandolod82d1de2021-04-06 14:55:58 -070055
Matteo Scandolo42f6e572021-01-25 15:11:34 -080056 sh """
Matteo Scandoloed1afdd2021-04-02 16:25:45 -070057 helm upgrade --install --create-namespace -n ${cfg.infraNamespace} voltha-infra ${volthaInfraChart} \
Matteo Scandolo660e4af2021-04-02 11:16:09 -070058 --set onos-classic.replicas=${cfg.onosReplica},onos-classic.atomix.replicas=${cfg.atomixReplica} \
Matteo Scandolod43bb302021-04-20 10:19:29 -070059 --set kafka.replicaCount=${cfg.kafkaReplica},kafka.zookeeper.replicaCount=${cfg.kafkaReplica} \
60 --set etcd.statefulset.replicaCount=${cfg.etcdReplica} \
Matteo Scandoloed1afdd2021-04-02 16:25:45 -070061 -f $WORKSPACE/voltha-helm-charts/examples/${cfg.workflow}-values.yaml ${cfg.extraHelmFlags}
Matteo Scandolo42f6e572021-01-25 15:11:34 -080062 """
63}