Gary Wu | 950a323 | 2019-03-26 13:08:29 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 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 | # |
| 11 | |
| 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 | |
| 19 | if [ -z "$WORKSPACE" ]; then |
| 20 | export WORKSPACE=`git rev-parse --show-toplevel` |
| 21 | fi |
| 22 | PARTS_DIR=$WORKSPACE/deployment/heat/onap-rke/parts |
| 23 | |
| 24 | cat <<EOF |
| 25 | # |
| 26 | # Generated by scripts/gen-onap-oom-yaml.sh; MANUAL CHANGES WILL BE LOST |
| 27 | # |
| 28 | EOF |
| 29 | |
| 30 | cat $PARTS_DIR/onap-oom-1.yaml |
| 31 | |
| 32 | cat <<EOF |
Gary Wu | d95bf2b | 2019-06-21 15:35:18 -0700 | [diff] [blame] | 33 | nfs_vm: |
Gary Wu | 950a323 | 2019-03-26 13:08:29 -0700 | [diff] [blame] | 34 | type: OS::Nova::Server |
| 35 | properties: |
| 36 | name: |
Gary Wu | d95bf2b | 2019-06-21 15:35:18 -0700 | [diff] [blame] | 37 | list_join: ['-', [{ get_param: 'OS::stack_name' }, 'nfs']] |
Gary Wu | 950a323 | 2019-03-26 13:08:29 -0700 | [diff] [blame] | 38 | image: { get_param: ubuntu_1804_image } |
Gary Wu | d95bf2b | 2019-06-21 15:35:18 -0700 | [diff] [blame] | 39 | flavor: { get_param: nfs_vm_flavor } |
Gary Wu | 950a323 | 2019-03-26 13:08:29 -0700 | [diff] [blame] | 40 | key_name: { get_param: key_name } |
| 41 | networks: |
Gary Wu | d95bf2b | 2019-06-21 15:35:18 -0700 | [diff] [blame] | 42 | - port: { get_resource: nfs_private_port } |
Gary Wu | 950a323 | 2019-03-26 13:08:29 -0700 | [diff] [blame] | 43 | user_data_format: RAW |
| 44 | user_data: |
| 45 | str_replace: |
| 46 | template: |
Gary Wu | d95bf2b | 2019-06-21 15:35:18 -0700 | [diff] [blame] | 47 | get_file: nfs_vm_entrypoint.sh |
Gary Wu | 950a323 | 2019-03-26 13:08:29 -0700 | [diff] [blame] | 48 | params: |
| 49 | __docker_proxy__: { get_param: docker_proxy } |
| 50 | __apt_proxy__: { get_param: apt_proxy } |
Gary Wu | d95bf2b | 2019-06-21 15:35:18 -0700 | [diff] [blame] | 51 | __nfs_ip_addr__: { get_attr: [nfs_floating_ip, floating_ip_address] } |
| 52 | __nfs_private_ip_addr__: { get_attr: [nfs_floating_ip, fixed_ip_address] } |
Gary Wu | 950a323 | 2019-03-26 13:08:29 -0700 | [diff] [blame] | 53 | __integration_override_yaml__: { get_param: integration_override_yaml } |
| 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 } |
| 58 | __docker_manifest__: { get_param: docker_manifest } |
| 59 | __docker_version__: { get_param: docker_version } |
Gary Wu | 950a323 | 2019-03-26 13:08:29 -0700 | [diff] [blame] | 60 | __kubectl_version__: { get_param: kubectl_version } |
| 61 | __helm_version__: { get_param: helm_version } |
| 62 | __helm_deploy_delay__: { get_param: helm_deploy_delay } |
Gary Wu | 950a323 | 2019-03-26 13:08:29 -0700 | [diff] [blame] | 63 | __mtu__: { get_param: mtu } |
| 64 | __portal_hostname__: { get_param: portal_hostname } |
| 65 | __public_net_id__: { get_param: public_net_id } |
| 66 | __oam_network_cidr__: { get_param: oam_network_cidr } |
| 67 | __oam_network_id__: { get_resource: oam_network } |
| 68 | __oam_subnet_id__: { get_resource: oam_subnet } |
| 69 | __sec_group__: { get_resource: onap_sg } |
| 70 | __k8s_01_vm_ip__: { get_attr: [k8s_01_floating_ip, floating_ip_address] } |
| 71 | __k8s_vm_ips__: [ |
| 72 | EOF |
| 73 | |
| 74 | for VM_NUM in $(seq -f %02g $NUM_K8S_VMS); do |
| 75 | K8S_VM_NAME=k8s_$VM_NUM |
| 76 | cat <<EOF |
| 77 | get_attr: [${K8S_VM_NAME}_floating_ip, floating_ip_address], |
| 78 | EOF |
| 79 | done |
| 80 | |
| 81 | cat <<EOF |
| 82 | ] |
| 83 | __k8s_private_ips__: [ |
| 84 | EOF |
| 85 | |
| 86 | for VM_NUM in $(seq -f %02g $NUM_K8S_VMS); do |
| 87 | K8S_VM_NAME=k8s_$VM_NUM |
| 88 | cat <<EOF |
| 89 | get_attr: [${K8S_VM_NAME}_floating_ip, fixed_ip_address], |
| 90 | EOF |
| 91 | done |
| 92 | |
| 93 | cat <<EOF |
| 94 | ] |
| 95 | EOF |
| 96 | |
| 97 | for VM_NUM in $(seq -f %02g $NUM_K8S_VMS); do |
| 98 | VM_TYPE=k8s HOST_LABEL=compute VM_NUM=$VM_NUM envsubst < $PARTS_DIR/onap-oom-2.yaml |
| 99 | done |
| 100 | |
| 101 | for VM_NUM in $(seq 3); do |
| 102 | VM_TYPE=orch HOST_LABEL=orchestration VM_NUM=$VM_NUM envsubst < $PARTS_DIR/onap-oom-2.yaml |
| 103 | done |
| 104 | |
| 105 | |
| 106 | cat $PARTS_DIR/onap-oom-3.yaml |
| 107 | |
| 108 | for VM_NUM in $(seq -f %02g $NUM_K8S_VMS); do |
| 109 | K8S_VM_NAME=k8s_$VM_NUM |
| 110 | cat <<EOF |
| 111 | ${K8S_VM_NAME}_vm_ip: |
| 112 | description: The IP address of the ${K8S_VM_NAME} instance |
| 113 | value: { get_attr: [${K8S_VM_NAME}_floating_ip, floating_ip_address] } |
| 114 | |
| 115 | ${K8S_VM_NAME}_vm_private_ip: |
| 116 | description: The private IP address of the ${K8S_VM_NAME} instance |
| 117 | value: { get_attr: [${K8S_VM_NAME}_floating_ip, fixed_ip_address] } |
| 118 | |
| 119 | EOF |
| 120 | done |
| 121 | |
| 122 | for VM_NUM in $(seq 3); do |
| 123 | K8S_VM_NAME=orch_$VM_NUM |
| 124 | cat <<EOF |
| 125 | ${K8S_VM_NAME}_vm_ip: |
| 126 | description: The IP address of the ${K8S_VM_NAME} instance |
| 127 | value: { get_attr: [${K8S_VM_NAME}_floating_ip, floating_ip_address] } |
| 128 | |
| 129 | ${K8S_VM_NAME}_vm_private_ip: |
| 130 | description: The private IP address of the ${K8S_VM_NAME} instance |
| 131 | value: { get_attr: [${K8S_VM_NAME}_floating_ip, fixed_ip_address] } |
| 132 | |
| 133 | EOF |
| 134 | done |