Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 1 | // usage |
| 2 | // |
| 3 | // stage('test stage') { |
| 4 | // steps { |
| 5 | // volthaDeploy([ |
| 6 | // onosReplica: 3 |
| 7 | // ]) |
| 8 | // } |
| 9 | // } |
| 10 | |
| 11 | |
| 12 | def 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 Windlass | 810b6cf | 2022-02-24 09:21:18 +0000 | [diff] [blame] | 21 | withMacLearning: false, |
Hardik Windlass | c97ceae | 2022-05-13 10:12:55 +0530 | [diff] [blame] | 22 | withFttb: false, |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 23 | extraHelmFlags: "", |
Matteo Scandolo | fcfc60d | 2021-02-24 09:06:48 -0800 | [diff] [blame] | 24 | localCharts: false, |
Matteo Scandolo | d82d1de | 2021-04-06 14:55:58 -0700 | [diff] [blame] | 25 | kubeconfig: null, // location of the kubernetes config file, if null we assume it's stored in the $KUBECONFIG environment variable |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 26 | ] |
| 27 | |
| 28 | if (!config) { |
| 29 | config = [:] |
| 30 | } |
| 31 | |
| 32 | def cfg = defaultConfig + config |
| 33 | |
Matteo Scandolo | fcfc60d | 2021-02-24 09:06:48 -0800 | [diff] [blame] | 34 | def volthaInfraChart = "onf/voltha-infra" |
| 35 | |
| 36 | if (cfg.localCharts) { |
| 37 | volthaInfraChart = "$WORKSPACE/voltha-helm-charts/voltha-infra" |
| 38 | |
| 39 | sh """ |
| 40 | pushd $WORKSPACE/voltha-helm-charts/voltha-infra |
| 41 | helm dep update |
| 42 | popd |
| 43 | """ |
| 44 | } |
| 45 | |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 46 | println "Deploying VOLTHA Infra with the following parameters: ${cfg}." |
| 47 | |
Matteo Scandolo | d82d1de | 2021-04-06 14:55:58 -0700 | [diff] [blame] | 48 | def kubeconfig = cfg.kubeconfig |
| 49 | if (kubeconfig == null) { |
| 50 | kubeconfig = env.KUBECONFIG |
| 51 | } |
| 52 | |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 53 | sh """ |
| 54 | kubectl create namespace ${cfg.infraNamespace} || true |
Matteo Scandolo | d82d1de | 2021-04-06 14:55:58 -0700 | [diff] [blame] | 55 | kubectl create configmap -n ${cfg.infraNamespace} kube-config "--from-file=kube_config=${kubeconfig}" || true |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 56 | """ |
Matteo Scandolo | d82d1de | 2021-04-06 14:55:58 -0700 | [diff] [blame] | 57 | |
Hardik Windlass | 810b6cf | 2022-02-24 09:21:18 +0000 | [diff] [blame] | 58 | def serviceConfigFile = cfg.workflow |
| 59 | if (cfg.withMacLearning && cfg.workflow == 'tt') { |
| 60 | serviceConfigFile = "tt-maclearner" |
Hardik Windlass | c97ceae | 2022-05-13 10:12:55 +0530 | [diff] [blame] | 61 | } else if (cfg.withFttb && cfg.workflow == 'dt') { |
| 62 | serviceConfigFile = "dt-fttb" |
Hardik Windlass | 810b6cf | 2022-02-24 09:21:18 +0000 | [diff] [blame] | 63 | } |
| 64 | |
Matteo Scandolo | a1b5d79 | 2021-06-01 12:19:31 -0700 | [diff] [blame] | 65 | // bitnamic/etch has change the replica format between the currently used 5.4.2 and the latest 6.2.5 |
| 66 | // for now put both values in the extra helm chart flags |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 67 | sh """ |
Matteo Scandolo | ed1afdd | 2021-04-02 16:25:45 -0700 | [diff] [blame] | 68 | helm upgrade --install --create-namespace -n ${cfg.infraNamespace} voltha-infra ${volthaInfraChart} \ |
Matteo Scandolo | 660e4af | 2021-04-02 11:16:09 -0700 | [diff] [blame] | 69 | --set onos-classic.replicas=${cfg.onosReplica},onos-classic.atomix.replicas=${cfg.atomixReplica} \ |
Matteo Scandolo | d43bb30 | 2021-04-20 10:19:29 -0700 | [diff] [blame] | 70 | --set kafka.replicaCount=${cfg.kafkaReplica},kafka.zookeeper.replicaCount=${cfg.kafkaReplica} \ |
| 71 | --set etcd.statefulset.replicaCount=${cfg.etcdReplica} \ |
Matteo Scandolo | a1b5d79 | 2021-06-01 12:19:31 -0700 | [diff] [blame] | 72 | --set etcd.replicaCount=${cfg.etcdReplica} \ |
Hardik Windlass | 810b6cf | 2022-02-24 09:21:18 +0000 | [diff] [blame] | 73 | -f $WORKSPACE/voltha-helm-charts/examples/${serviceConfigFile}-values.yaml ${cfg.extraHelmFlags} |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 74 | """ |
| 75 | } |