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", |
| 21 | extraHelmFlags: "", |
Matteo Scandolo | fcfc60d | 2021-02-24 09:06:48 -0800 | [diff] [blame] | 22 | localCharts: false, |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 23 | ] |
| 24 | |
| 25 | if (!config) { |
| 26 | config = [:] |
| 27 | } |
| 28 | |
| 29 | def cfg = defaultConfig + config |
| 30 | |
Matteo Scandolo | fcfc60d | 2021-02-24 09:06:48 -0800 | [diff] [blame] | 31 | 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 Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 43 | 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 Scandolo | fcfc60d | 2021-02-24 09:06:48 -0800 | [diff] [blame] | 51 | helm upgrade --install --create-namespace -n ${cfg.infraNamespace} voltha-infra ${volthaInfraChart} ${cfg.extraHelmFlags} \ |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 52 | -f $WORKSPACE/voltha-helm-charts/examples/${cfg.workflow}-values.yaml |
| 53 | """ |
| 54 | } |