Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 1 | #!/bin/bash |
Gary Wu | a3fb86f | 2018-06-04 16:23:54 -0700 | [diff] [blame] | 2 | # |
| 3 | # Copyright 2018 Huawei Technologies Co., Ltd. |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 11 | |
Gary Wu | 7d03458 | 2018-05-12 09:08:20 -0700 | [diff] [blame] | 12 | if [ "$#" -ne 1 ]; then |
| 13 | echo This script generates the HEAT template for X number of k8s VMs |
| 14 | echo "$0 <num k8s vms>" |
| 15 | exit 1 |
| 16 | fi |
| 17 | NUM_K8S_VMS=$1 |
| 18 | |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 19 | if [ -z "$WORKSPACE" ]; then |
| 20 | export WORKSPACE=`git rev-parse --show-toplevel` |
| 21 | fi |
| 22 | PARTS_DIR=$WORKSPACE/deployment/heat/onap-oom/parts |
| 23 | |
Gary Wu | 11c9874 | 2018-05-02 16:19:04 -0700 | [diff] [blame] | 24 | cat <<EOF |
| 25 | # |
| 26 | # Generated by scripts/gen-onap-oom-yaml.sh; MANUAL CHANGES WILL BE LOST |
| 27 | # |
| 28 | EOF |
| 29 | |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 30 | cat $PARTS_DIR/onap-oom-1.yaml |
| 31 | |
| 32 | cat <<EOF |
| 33 | rancher_vm: |
| 34 | type: OS::Nova::Server |
| 35 | properties: |
eHanan | 97b7a9c | 2018-09-05 14:09:19 +0100 | [diff] [blame] | 36 | name: |
| 37 | list_join: ['-', [{ get_param: 'OS::stack_name' }, 'rancher']] |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 38 | image: { get_param: ubuntu_1604_image } |
| 39 | flavor: { get_param: rancher_vm_flavor } |
gwu | 10db462 | 2018-07-17 22:11:39 -0700 | [diff] [blame] | 40 | key_name: { get_param: key_name } |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 41 | networks: |
| 42 | - port: { get_resource: rancher_private_port } |
| 43 | user_data_format: RAW |
| 44 | user_data: |
| 45 | str_replace: |
| 46 | template: |
| 47 | get_file: rancher_vm_entrypoint.sh |
| 48 | params: |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 49 | __docker_proxy__: { get_param: docker_proxy } |
| 50 | __apt_proxy__: { get_param: apt_proxy } |
| 51 | __rancher_ip_addr__: { get_attr: [rancher_floating_ip, floating_ip_address] } |
Gary Wu | ad51372 | 2018-07-26 13:08:47 -0700 | [diff] [blame] | 52 | __rancher_private_ip_addr__: { get_attr: [rancher_floating_ip, fixed_ip_address] } |
Gary Wu | 11c9874 | 2018-05-02 16:19:04 -0700 | [diff] [blame] | 53 | __integration_override_yaml__: { get_param: integration_override_yaml } |
Gary Wu | 87aa8b5 | 2018-08-09 08:10:24 -0700 | [diff] [blame] | 54 | __integration_gerrit_branch__: { get_param: integration_gerrit_branch } |
| 55 | __integration_gerrit_refspec__: { get_param: integration_gerrit_refspec } |
| 56 | __oom_gerrit_branch__: { get_param: oom_gerrit_branch } |
| 57 | __oom_gerrit_refspec__: { get_param: oom_gerrit_refspec } |
Gary Wu | c474970 | 2018-06-26 14:27:41 -0700 | [diff] [blame] | 58 | __docker_manifest__: { get_param: docker_manifest } |
Gary Wu | 7a04b3d | 2018-08-15 12:31:46 -0700 | [diff] [blame] | 59 | __docker_version__: { get_param: docker_version } |
| 60 | __rancher_version__: { get_param: rancher_version } |
| 61 | __rancher_agent_version__: { get_param: rancher_agent_version } |
| 62 | __kubectl_version__: { get_param: kubectl_version } |
| 63 | __helm_version__: { get_param: helm_version } |
Gary Wu | 48a3294 | 2018-11-08 07:34:49 -0800 | [diff] [blame] | 64 | __helm_deploy_delay__: { get_param: helm_deploy_delay } |
| 65 | __use_ramdisk__: { get_param: use_ramdisk } |
Gary Wu | b8be70a | 2018-11-17 17:14:38 -0800 | [diff] [blame] | 66 | __mtu__: { get_param: mtu } |
Gary Wu | 4a69d51 | 2018-12-10 11:31:24 -0800 | [diff] [blame] | 67 | __portal_hostname__: { get_param: portal_hostname } |
Gary Wu | 978171e | 2018-07-24 11:56:01 -0700 | [diff] [blame] | 68 | __public_net_id__: { get_param: public_net_id } |
| 69 | __oam_network_cidr__: { get_param: oam_network_cidr } |
Gary Wu | 11c9874 | 2018-05-02 16:19:04 -0700 | [diff] [blame] | 70 | __oam_network_id__: { get_resource: oam_network } |
| 71 | __oam_subnet_id__: { get_resource: oam_subnet } |
Gary Wu | 17440fe | 2018-10-22 15:12:07 -0700 | [diff] [blame] | 72 | __sec_group__: { get_resource: onap_sg } |
Gary Wu | 48a3294 | 2018-11-08 07:34:49 -0800 | [diff] [blame] | 73 | __k8s_01_vm_ip__: { get_attr: [k8s_01_floating_ip, floating_ip_address] } |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 74 | __k8s_vm_ips__: [ |
| 75 | EOF |
| 76 | |
Gary Wu | 48a3294 | 2018-11-08 07:34:49 -0800 | [diff] [blame] | 77 | for VM_NUM in $(seq -f %02g $NUM_K8S_VMS); do |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 78 | K8S_VM_NAME=k8s_$VM_NUM |
| 79 | cat <<EOF |
| 80 | get_attr: [${K8S_VM_NAME}_floating_ip, floating_ip_address], |
| 81 | EOF |
| 82 | done |
| 83 | |
| 84 | cat <<EOF |
| 85 | ] |
Gary Wu | ad51372 | 2018-07-26 13:08:47 -0700 | [diff] [blame] | 86 | __k8s_private_ips__: [ |
| 87 | EOF |
| 88 | |
Gary Wu | 48a3294 | 2018-11-08 07:34:49 -0800 | [diff] [blame] | 89 | for VM_NUM in $(seq -f %02g $NUM_K8S_VMS); do |
Gary Wu | ad51372 | 2018-07-26 13:08:47 -0700 | [diff] [blame] | 90 | K8S_VM_NAME=k8s_$VM_NUM |
| 91 | cat <<EOF |
| 92 | get_attr: [${K8S_VM_NAME}_floating_ip, fixed_ip_address], |
| 93 | EOF |
| 94 | done |
| 95 | |
| 96 | cat <<EOF |
| 97 | ] |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 98 | EOF |
| 99 | |
Gary Wu | 48a3294 | 2018-11-08 07:34:49 -0800 | [diff] [blame] | 100 | for VM_NUM in $(seq -f %02g $NUM_K8S_VMS); do |
Gary Wu | 3fd6c2a | 2018-10-28 21:44:00 -0700 | [diff] [blame] | 101 | VM_TYPE=k8s HOST_LABEL=compute VM_NUM=$VM_NUM envsubst < $PARTS_DIR/onap-oom-2.yaml |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 102 | done |
| 103 | |
Gary Wu | 3fd6c2a | 2018-10-28 21:44:00 -0700 | [diff] [blame] | 104 | for VM_NUM in $(seq 3); do |
| 105 | VM_TYPE=etcd HOST_LABEL=etcd VM_NUM=$VM_NUM envsubst < $PARTS_DIR/onap-oom-2.yaml |
| 106 | done |
| 107 | |
Gary Wu | 6e66201 | 2018-11-13 18:41:45 -0800 | [diff] [blame] | 108 | for VM_NUM in $(seq 2); do |
Gary Wu | 3fd6c2a | 2018-10-28 21:44:00 -0700 | [diff] [blame] | 109 | VM_TYPE=orch HOST_LABEL=orchestration VM_NUM=$VM_NUM envsubst < $PARTS_DIR/onap-oom-2.yaml |
| 110 | done |
| 111 | |
| 112 | |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 113 | cat $PARTS_DIR/onap-oom-3.yaml |
Gary Wu | 36e42dd | 2018-05-03 07:29:53 -0700 | [diff] [blame] | 114 | |
Gary Wu | 48a3294 | 2018-11-08 07:34:49 -0800 | [diff] [blame] | 115 | for VM_NUM in $(seq -f %02g $NUM_K8S_VMS); do |
Gary Wu | 36e42dd | 2018-05-03 07:29:53 -0700 | [diff] [blame] | 116 | K8S_VM_NAME=k8s_$VM_NUM |
| 117 | cat <<EOF |
| 118 | ${K8S_VM_NAME}_vm_ip: |
| 119 | description: The IP address of the ${K8S_VM_NAME} instance |
| 120 | value: { get_attr: [${K8S_VM_NAME}_floating_ip, floating_ip_address] } |
| 121 | |
| 122 | EOF |
| 123 | done |