blob: 189b56211188945dc6ab4d039d3f25f43c135042 [file] [log] [blame]
Joey Armstrong96158a92022-11-25 10:36:06 -05001#!/usr/bin/env groovy
2
Matteo Scandolo42f6e572021-01-25 15:11:34 -08003// usage
4//
5// stage('test stage') {
6// steps {
7// volthaDeploy([
8// onosReplica: 3
9// ])
10// }
11// }
12
Matteo Scandolo42f6e572021-01-25 15:11:34 -080013def call(Map config) {
Joey Armstrong96158a92022-11-25 10:36:06 -050014
15 String iam = 'vars/volthaInfraDeploy.groovy'
16 println("** ${iam}: ENTER")
17
Matteo Scandolo42f6e572021-01-25 15:11:34 -080018 // NOTE use params or directule extraHelmFlags??
19 def defaultConfig = [
20 onosReplica: 1,
21 atomixReplica: 1,
22 kafkaReplica: 1,
23 etcdReplica: 1,
24 infraNamespace: "infra",
25 workflow: "att",
Hardik Windlass810b6cf2022-02-24 09:21:18 +000026 withMacLearning: false,
Hardik Windlassc97ceae2022-05-13 10:12:55 +053027 withFttb: false,
Matteo Scandolo42f6e572021-01-25 15:11:34 -080028 extraHelmFlags: "",
Matteo Scandolofcfc60d2021-02-24 09:06:48 -080029 localCharts: false,
Matteo Scandolod82d1de2021-04-06 14:55:58 -070030 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 -080031 ]
32
33 if (!config) {
34 config = [:]
35 }
36
37 def cfg = defaultConfig + config
38
Matteo Scandolofcfc60d2021-02-24 09:06:48 -080039 def volthaInfraChart = "onf/voltha-infra"
40
41 if (cfg.localCharts) {
42 volthaInfraChart = "$WORKSPACE/voltha-helm-charts/voltha-infra"
43
44 sh """
45 pushd $WORKSPACE/voltha-helm-charts/voltha-infra
46 helm dep update
47 popd
48 """
49 }
50
Matteo Scandolo42f6e572021-01-25 15:11:34 -080051 println "Deploying VOLTHA Infra with the following parameters: ${cfg}."
52
Matteo Scandolod82d1de2021-04-06 14:55:58 -070053 def kubeconfig = cfg.kubeconfig
54 if (kubeconfig == null) {
55 kubeconfig = env.KUBECONFIG
56 }
57
Joey Armstrong96158a92022-11-25 10:36:06 -050058 /*
59 [joey] - should pre-existing hint the env is tainted (?)
60 05:24:57 + kubectl create namespace infra
61 05:24:57 Error from server (AlreadyExists): namespaces "infra" already exists
62 05:24:57 error: failed to create configmap: configmaps "kube-config" already exists
63 */
64
Matteo Scandolo42f6e572021-01-25 15:11:34 -080065 sh """
66 kubectl create namespace ${cfg.infraNamespace} || true
Matteo Scandolod82d1de2021-04-06 14:55:58 -070067 kubectl create configmap -n ${cfg.infraNamespace} kube-config "--from-file=kube_config=${kubeconfig}" || true
Matteo Scandolo42f6e572021-01-25 15:11:34 -080068 """
Matteo Scandolod82d1de2021-04-06 14:55:58 -070069
Hardik Windlass810b6cf2022-02-24 09:21:18 +000070 def serviceConfigFile = cfg.workflow
71 if (cfg.withMacLearning && cfg.workflow == 'tt') {
72 serviceConfigFile = "tt-maclearner"
Hardik Windlassc97ceae2022-05-13 10:12:55 +053073 } else if (cfg.withFttb && cfg.workflow == 'dt') {
74 serviceConfigFile = "dt-fttb"
Hardik Windlass810b6cf2022-02-24 09:21:18 +000075 }
76
Matteo Scandoloa1b5d792021-06-01 12:19:31 -070077 // bitnamic/etch has change the replica format between the currently used 5.4.2 and the latest 6.2.5
78 // for now put both values in the extra helm chart flags
Matteo Scandolo42f6e572021-01-25 15:11:34 -080079 sh """
Matteo Scandoloed1afdd2021-04-02 16:25:45 -070080 helm upgrade --install --create-namespace -n ${cfg.infraNamespace} voltha-infra ${volthaInfraChart} \
Matteo Scandolo660e4af2021-04-02 11:16:09 -070081 --set onos-classic.replicas=${cfg.onosReplica},onos-classic.atomix.replicas=${cfg.atomixReplica} \
Matteo Scandolod43bb302021-04-20 10:19:29 -070082 --set kafka.replicaCount=${cfg.kafkaReplica},kafka.zookeeper.replicaCount=${cfg.kafkaReplica} \
83 --set etcd.statefulset.replicaCount=${cfg.etcdReplica} \
Matteo Scandoloa1b5d792021-06-01 12:19:31 -070084 --set etcd.replicaCount=${cfg.etcdReplica} \
Hardik Windlass810b6cf2022-02-24 09:21:18 +000085 -f $WORKSPACE/voltha-helm-charts/examples/${serviceConfigFile}-values.yaml ${cfg.extraHelmFlags}
Matteo Scandolo42f6e572021-01-25 15:11:34 -080086 """
Joey Armstrong96158a92022-11-25 10:36:06 -050087
88 println("** ${iam}: LEAVE")
Matteo Scandolo42f6e572021-01-25 15:11:34 -080089}