Joey Armstrong | 96158a9 | 2022-11-25 10:36:06 -0500 | [diff] [blame] | 1 | #!/usr/bin/env groovy |
| 2 | |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 3 | // usage |
| 4 | // |
| 5 | // stage('test stage') { |
| 6 | // steps { |
| 7 | // volthaDeploy([ |
| 8 | // onosReplica: 3 |
| 9 | // ]) |
| 10 | // } |
| 11 | // } |
| 12 | |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 13 | def call(Map config) { |
Joey Armstrong | 96158a9 | 2022-11-25 10:36:06 -0500 | [diff] [blame] | 14 | |
| 15 | String iam = 'vars/volthaInfraDeploy.groovy' |
| 16 | println("** ${iam}: ENTER") |
| 17 | |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 18 | // 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 Windlass | 810b6cf | 2022-02-24 09:21:18 +0000 | [diff] [blame] | 26 | withMacLearning: false, |
Hardik Windlass | c97ceae | 2022-05-13 10:12:55 +0530 | [diff] [blame] | 27 | withFttb: false, |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 28 | extraHelmFlags: "", |
Matteo Scandolo | fcfc60d | 2021-02-24 09:06:48 -0800 | [diff] [blame] | 29 | localCharts: false, |
Matteo Scandolo | d82d1de | 2021-04-06 14:55:58 -0700 | [diff] [blame] | 30 | 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] | 31 | ] |
| 32 | |
| 33 | if (!config) { |
| 34 | config = [:] |
| 35 | } |
| 36 | |
| 37 | def cfg = defaultConfig + config |
| 38 | |
Matteo Scandolo | fcfc60d | 2021-02-24 09:06:48 -0800 | [diff] [blame] | 39 | 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 Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 51 | println "Deploying VOLTHA Infra with the following parameters: ${cfg}." |
| 52 | |
Matteo Scandolo | d82d1de | 2021-04-06 14:55:58 -0700 | [diff] [blame] | 53 | def kubeconfig = cfg.kubeconfig |
| 54 | if (kubeconfig == null) { |
| 55 | kubeconfig = env.KUBECONFIG |
| 56 | } |
| 57 | |
Joey Armstrong | 96158a9 | 2022-11-25 10:36:06 -0500 | [diff] [blame] | 58 | /* |
| 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 Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 65 | sh """ |
| 66 | kubectl create namespace ${cfg.infraNamespace} || true |
Matteo Scandolo | d82d1de | 2021-04-06 14:55:58 -0700 | [diff] [blame] | 67 | 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] | 68 | """ |
Matteo Scandolo | d82d1de | 2021-04-06 14:55:58 -0700 | [diff] [blame] | 69 | |
Hardik Windlass | 810b6cf | 2022-02-24 09:21:18 +0000 | [diff] [blame] | 70 | def serviceConfigFile = cfg.workflow |
| 71 | if (cfg.withMacLearning && cfg.workflow == 'tt') { |
| 72 | serviceConfigFile = "tt-maclearner" |
Hardik Windlass | c97ceae | 2022-05-13 10:12:55 +0530 | [diff] [blame] | 73 | } else if (cfg.withFttb && cfg.workflow == 'dt') { |
| 74 | serviceConfigFile = "dt-fttb" |
Hardik Windlass | 810b6cf | 2022-02-24 09:21:18 +0000 | [diff] [blame] | 75 | } |
| 76 | |
Matteo Scandolo | a1b5d79 | 2021-06-01 12:19:31 -0700 | [diff] [blame] | 77 | // 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 Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 79 | sh """ |
Matteo Scandolo | ed1afdd | 2021-04-02 16:25:45 -0700 | [diff] [blame] | 80 | helm upgrade --install --create-namespace -n ${cfg.infraNamespace} voltha-infra ${volthaInfraChart} \ |
Matteo Scandolo | 660e4af | 2021-04-02 11:16:09 -0700 | [diff] [blame] | 81 | --set onos-classic.replicas=${cfg.onosReplica},onos-classic.atomix.replicas=${cfg.atomixReplica} \ |
Matteo Scandolo | d43bb30 | 2021-04-20 10:19:29 -0700 | [diff] [blame] | 82 | --set kafka.replicaCount=${cfg.kafkaReplica},kafka.zookeeper.replicaCount=${cfg.kafkaReplica} \ |
| 83 | --set etcd.statefulset.replicaCount=${cfg.etcdReplica} \ |
Matteo Scandolo | a1b5d79 | 2021-06-01 12:19:31 -0700 | [diff] [blame] | 84 | --set etcd.replicaCount=${cfg.etcdReplica} \ |
Hardik Windlass | 810b6cf | 2022-02-24 09:21:18 +0000 | [diff] [blame] | 85 | -f $WORKSPACE/voltha-helm-charts/examples/${serviceConfigFile}-values.yaml ${cfg.extraHelmFlags} |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 86 | """ |
Joey Armstrong | 96158a9 | 2022-11-25 10:36:06 -0500 | [diff] [blame] | 87 | |
| 88 | println("** ${iam}: LEAVE") |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 89 | } |