Anton Samoylov | e2e969e | 2024-10-03 15:28:31 +0400 | [diff] [blame] | 1 | heat_template_version: queens |
| 2 | |
| 3 | parameters: |
| 4 | |
Anton Samoylov | e2e969e | 2024-10-03 15:28:31 +0400 | [diff] [blame] | 5 | k8s_network: |
| 6 | type: string |
| 7 | k8s_subnet_id: |
| 8 | type: string |
| 9 | public_net_id: |
| 10 | type: string |
| 11 | data_network: |
| 12 | type: string |
Anton Samoylov | 17e7c03 | 2024-10-14 23:55:18 +0400 | [diff] [blame] | 13 | storage_frontend_network: |
| 14 | type: string |
Anton Samoylov | e2e969e | 2024-10-03 15:28:31 +0400 | [diff] [blame] | 15 | availability_zone: |
| 16 | type: string |
| 17 | default: nova |
Anton Samoylov | 17e7c03 | 2024-10-14 23:55:18 +0400 | [diff] [blame] | 18 | boot_timeout: |
| 19 | type: number |
| 20 | description: Boot timeout for instance |
| 21 | default: 600 |
Anton Samoylov | e2e969e | 2024-10-03 15:28:31 +0400 | [diff] [blame] | 22 | image: |
| 23 | type: string |
| 24 | description: Name of image to use for servers |
| 25 | flavor: |
| 26 | type: string |
| 27 | description: Flavor to use for servers |
| 28 | key_name: |
| 29 | type: string |
| 30 | description: Name of keypair to assign to servers |
| 31 | |
| 32 | resources: |
| 33 | |
| 34 | k8s_network_port: |
| 35 | type: OS::Neutron::Port |
| 36 | properties: |
| 37 | network: { get_param: k8s_network } |
| 38 | port_security_enabled: false |
| 39 | fixed_ips: |
| 40 | - subnet: { get_param: k8s_subnet_id } |
| 41 | |
| 42 | floating_ip_k8s_net: |
| 43 | type: OS::Neutron::FloatingIP |
| 44 | properties: |
| 45 | floating_network_id: { get_param: public_net_id } |
| 46 | port_id: { get_resource: k8s_network_port } |
| 47 | |
Anton Samoylov | 17e7c03 | 2024-10-14 23:55:18 +0400 | [diff] [blame] | 48 | wait_handle: |
| 49 | type: OS::Heat::WaitConditionHandle |
| 50 | |
| 51 | wait_condition: |
| 52 | type: OS::Heat::WaitCondition |
| 53 | properties: |
| 54 | handle: { get_resource: wait_handle } |
| 55 | timeout: { get_param: boot_timeout } |
| 56 | |
Anton Samoylov | e2e969e | 2024-10-03 15:28:31 +0400 | [diff] [blame] | 57 | vm_server: |
| 58 | type: OS::Nova::Server |
| 59 | properties: |
| 60 | availability_zone: { get_param: availability_zone } |
| 61 | image: { get_param: image } |
| 62 | flavor: { get_param: flavor } |
| 63 | key_name: { get_param: key_name } |
| 64 | networks: |
| 65 | - port: { get_resource: k8s_network_port } |
Anton Samoylov | 17e7c03 | 2024-10-14 23:55:18 +0400 | [diff] [blame] | 66 | - network: { get_param : storage_frontend_network } |
Anton Samoylov | e2e969e | 2024-10-03 15:28:31 +0400 | [diff] [blame] | 67 | - network: { get_param : data_network } |
Anton Samoylov | 17e7c03 | 2024-10-14 23:55:18 +0400 | [diff] [blame] | 68 | user_data_format: RAW |
| 69 | user_data: |
| 70 | str_replace: |
| 71 | template: | |
| 72 | #!/bin/bash |
| 73 | |
| 74 | set -x |
| 75 | |
| 76 | STATUS="SUCCESS" |
| 77 | REASON="The node has been successfully deployed" |
| 78 | DATA_BINARY="{\"status\": \"$STATUS\", \"reason\": \"$REASON\"}" |
| 79 | echo "Sending notification to wait condition ..." |
| 80 | |
| 81 | WC_EXIT_CODE=1 |
| 82 | counter=0 |
| 83 | while (( ${WC_EXIT_CODE} != 0 && ${counter} < 3 )); do |
| 84 | wc_notify -k --data-binary "$DATA_BINARY" && WC_EXIT_CODE=0 |
| 85 | counter=$((counter + 1)) |
| 86 | sleep 5 |
| 87 | done |
| 88 | |
| 89 | if (( ${WC_EXIT_CODE} !=0 )) |
| 90 | then |
| 91 | echo "Cannot send notification to wait condition with a SUCCESS status" |
| 92 | exit 1 |
| 93 | fi |
| 94 | params: |
| 95 | wc_notify: { get_attr: [wait_handle, curl_cli] } |
Anton Samoylov | e2e969e | 2024-10-03 15:28:31 +0400 | [diff] [blame] | 96 | |
| 97 | outputs: |
| 98 | server_public_ip: |
| 99 | description: Floating IP address of server in public network |
| 100 | value: { get_attr: [ floating_ip_k8s_net, floating_ip_address ] } |