blob: 733aa2075dc2fdaeb659c9366a174f08fccab629 [file] [log] [blame]
Gary Wu950a3232019-03-26 13:08:29 -07001#!/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
12if [ "$#" -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
16fi
17NUM_K8S_VMS=$1
18
19if [ -z "$WORKSPACE" ]; then
20 export WORKSPACE=`git rev-parse --show-toplevel`
21fi
22PARTS_DIR=$WORKSPACE/deployment/heat/onap-rke/parts
23
24cat <<EOF
25#
26# Generated by scripts/gen-onap-oom-yaml.sh; MANUAL CHANGES WILL BE LOST
27#
28EOF
29
30cat $PARTS_DIR/onap-oom-1.yaml
31
32cat <<EOF
Gary Wu9bb778b2019-06-21 16:16:18 -070033 nfs_volume:
34 type: OS::Cinder::Volume
35 properties:
36 size: 200
37
38 nfs_volume_att:
39 type: OS::Cinder::VolumeAttachment
40 properties:
41 instance_uuid: { get_resource: nfs_vm }
42 volume_id: { get_resource: nfs_volume }
43
Gary Wud95bf2b2019-06-21 15:35:18 -070044 nfs_vm:
Gary Wu950a3232019-03-26 13:08:29 -070045 type: OS::Nova::Server
46 properties:
47 name:
Gary Wud95bf2b2019-06-21 15:35:18 -070048 list_join: ['-', [{ get_param: 'OS::stack_name' }, 'nfs']]
Gary Wu950a3232019-03-26 13:08:29 -070049 image: { get_param: ubuntu_1804_image }
Gary Wud95bf2b2019-06-21 15:35:18 -070050 flavor: { get_param: nfs_vm_flavor }
Gary Wu950a3232019-03-26 13:08:29 -070051 key_name: { get_param: key_name }
52 networks:
Gary Wud95bf2b2019-06-21 15:35:18 -070053 - port: { get_resource: nfs_private_port }
Gary Wu950a3232019-03-26 13:08:29 -070054 user_data_format: RAW
55 user_data:
56 str_replace:
57 template:
Gary Wud95bf2b2019-06-21 15:35:18 -070058 get_file: nfs_vm_entrypoint.sh
Gary Wu950a3232019-03-26 13:08:29 -070059 params:
Gary Wu9bb778b2019-06-21 16:16:18 -070060 __nfs_volume_id__: { get_resource: nfs_volume }
Gary Wu950a3232019-03-26 13:08:29 -070061 __docker_proxy__: { get_param: docker_proxy }
62 __apt_proxy__: { get_param: apt_proxy }
Gary Wud95bf2b2019-06-21 15:35:18 -070063 __nfs_ip_addr__: { get_attr: [nfs_floating_ip, floating_ip_address] }
64 __nfs_private_ip_addr__: { get_attr: [nfs_floating_ip, fixed_ip_address] }
Gary Wu950a3232019-03-26 13:08:29 -070065 __integration_override_yaml__: { get_param: integration_override_yaml }
66 __integration_gerrit_branch__: { get_param: integration_gerrit_branch }
67 __integration_gerrit_refspec__: { get_param: integration_gerrit_refspec }
68 __oom_gerrit_branch__: { get_param: oom_gerrit_branch }
69 __oom_gerrit_refspec__: { get_param: oom_gerrit_refspec }
70 __docker_manifest__: { get_param: docker_manifest }
71 __docker_version__: { get_param: docker_version }
Gary Wu950a3232019-03-26 13:08:29 -070072 __kubectl_version__: { get_param: kubectl_version }
73 __helm_version__: { get_param: helm_version }
74 __helm_deploy_delay__: { get_param: helm_deploy_delay }
Gary Wu950a3232019-03-26 13:08:29 -070075 __mtu__: { get_param: mtu }
76 __portal_hostname__: { get_param: portal_hostname }
77 __public_net_id__: { get_param: public_net_id }
78 __oam_network_cidr__: { get_param: oam_network_cidr }
79 __oam_network_id__: { get_resource: oam_network }
80 __oam_subnet_id__: { get_resource: oam_subnet }
81 __sec_group__: { get_resource: onap_sg }
82 __k8s_01_vm_ip__: { get_attr: [k8s_01_floating_ip, floating_ip_address] }
83 __k8s_vm_ips__: [
84EOF
85
86for 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, floating_ip_address],
90EOF
91done
92
93cat <<EOF
94 ]
95 __k8s_private_ips__: [
96EOF
97
98for VM_NUM in $(seq -f %02g $NUM_K8S_VMS); do
99 K8S_VM_NAME=k8s_$VM_NUM
100 cat <<EOF
101 get_attr: [${K8S_VM_NAME}_floating_ip, fixed_ip_address],
102EOF
103done
104
105cat <<EOF
106 ]
107EOF
108
109for VM_NUM in $(seq -f %02g $NUM_K8S_VMS); do
110 VM_TYPE=k8s HOST_LABEL=compute VM_NUM=$VM_NUM envsubst < $PARTS_DIR/onap-oom-2.yaml
111done
112
113for VM_NUM in $(seq 3); do
114 VM_TYPE=orch HOST_LABEL=orchestration VM_NUM=$VM_NUM envsubst < $PARTS_DIR/onap-oom-2.yaml
115done
116
117
118cat $PARTS_DIR/onap-oom-3.yaml
119
120for VM_NUM in $(seq -f %02g $NUM_K8S_VMS); do
121 K8S_VM_NAME=k8s_$VM_NUM
122 cat <<EOF
123 ${K8S_VM_NAME}_vm_ip:
124 description: The IP address of the ${K8S_VM_NAME} instance
125 value: { get_attr: [${K8S_VM_NAME}_floating_ip, floating_ip_address] }
126
127 ${K8S_VM_NAME}_vm_private_ip:
128 description: The private IP address of the ${K8S_VM_NAME} instance
129 value: { get_attr: [${K8S_VM_NAME}_floating_ip, fixed_ip_address] }
130
131EOF
132done
133
134for VM_NUM in $(seq 3); do
135 K8S_VM_NAME=orch_$VM_NUM
136 cat <<EOF
137 ${K8S_VM_NAME}_vm_ip:
138 description: The IP address of the ${K8S_VM_NAME} instance
139 value: { get_attr: [${K8S_VM_NAME}_floating_ip, floating_ip_address] }
140
141 ${K8S_VM_NAME}_vm_private_ip:
142 description: The private IP address of the ${K8S_VM_NAME} instance
143 value: { get_attr: [${K8S_VM_NAME}_floating_ip, fixed_ip_address] }
144
145EOF
146done