blob: 61cbd9e38ef7f79b04cf28266f8b55477dacd7eb [file] [log] [blame]
Anton Samoylov17e7c032024-10-14 23:55:18 +04001heat_template_version: queens
2
3parameters:
4
5 k8s_network:
6 type: string
7 k8s_subnet_id:
8 type: string
Anton Samoylovafd066e2025-08-27 10:58:38 +04009 k8s_subnet_ipv6_id:
10 type: string
Anton Samoylov17e7c032024-10-14 23:55:18 +040011 public_net_id:
12 type: string
13 data_network:
14 type: string
15 storage_frontend_network:
16 type: string
17 storage_backend_network:
18 type: string
Denis Egorenko9dd84da2025-09-23 15:05:32 +040019 storage_volumes_per_node:
20 type: number
21 default: 0
Anton Samoylov17e7c032024-10-14 23:55:18 +040022 availability_zone:
23 type: string
24 default: nova
25 boot_timeout:
26 type: number
27 description: Boot timeout for instance
28 default: 600
29 image:
30 type: string
31 description: Name of image to use for servers
32 flavor:
33 type: string
34 description: Flavor to use for servers
35 key_name:
36 type: string
37 description: Name of keypair to assign to servers
38 metadata:
39 type: json
40 default: {}
41 hardware_metadata:
42 description: The content of lab metadata.
43 type: string
44 user_data_config:
45 description: This is part of clout-config which denies to mount drive with label ephemeral0 to /mnt
46 type: string
47 default: |
48 #cloud-config
49 #
50 # Don't mount ephemeral0 to /mnt as it's by default
51 mounts:
52 - [ ephemeral0, null ]
Ilya Bumarskov54f2ffb2025-10-14 13:29:14 +020053 hybrid_lab:
54 type: boolean
55 default: false
56 pxe_network:
57 type: string
58 default: ''
59 pxe_subnet:
60 type: string
61 default: ''
62
63conditions:
64
65 connect_pxe_network:
66 get_param: hybrid_lab
Anton Samoylov17e7c032024-10-14 23:55:18 +040067
68resources:
69
Ilya Bumarskov54f2ffb2025-10-14 13:29:14 +020070 pxe_network_port:
71 type: OS::Neutron::Port
72 condition: connect_pxe_network
73 properties:
74 network: { get_param: pxe_network }
75 port_security_enabled: false
76 fixed_ips:
77 - subnet: { get_param: pxe_subnet }
78
Anton Samoylov17e7c032024-10-14 23:55:18 +040079 k8s_network_port:
80 type: OS::Neutron::Port
81 properties:
82 network: { get_param: k8s_network }
83 port_security_enabled: false
84 fixed_ips:
85 - subnet: { get_param: k8s_subnet_id }
Anton Samoylovafd066e2025-08-27 10:58:38 +040086 - subnet: { get_param: k8s_subnet_ipv6_id }
Anton Samoylov17e7c032024-10-14 23:55:18 +040087
88 floating_ip_k8s_net:
89 type: OS::Neutron::FloatingIP
90 properties:
91 floating_network_id: { get_param: public_net_id }
92 port_id: { get_resource: k8s_network_port }
93
94 software_config:
95 type: OS::Heat::SoftwareConfig
96 properties:
97 group: ungrouped
98 config:
99 str_replace:
100 template: |
101 #!/bin/bash
102
103 set -x
104
105 /usr/sbin/prepare-metadata.py --metadata-file /usr/share/metadata/lab-metadata.yaml
106
107 HW_METADATA='{}'
108 if [[ -f /usr/share/metadata/ceph.yaml && 'node_metadata' == *"ceph-osd-node"* ]]; then
109 HW_METADATA="{\"ceph\": {\"$(hostname)\": \"$(base64 -w 0 /usr/share/metadata/ceph.yaml)\"}}"
110 ceph_store_drive=$(cat /usr/share/metadata/ceph.yaml | egrep '\- name\: vd?' | awk '{print $3}')
111 if [[ -b /dev/${ceph_store_drive} ]]; then
112 sgdisk --zap-all /dev/${ceph_store_drive}
113 fi
114 fi
Ann Taraday56283e52024-10-25 15:36:20 +0200115
116 apt install nfs-common -y
Anton Samoylov17e7c032024-10-14 23:55:18 +0400117
118 STATUS="SUCCESS"
119 REASON="The node has been successfully deployed"
120 DATA_BINARY="{\"status\": \"$STATUS\", \"reason\": \"$REASON\", \"data\": $HW_METADATA}"
121 echo "Sending notification to wait condition with data: $HW_METADATA"
122
123 WC_EXIT_CODE=1
124 counter=0
125 while (( ${WC_EXIT_CODE} != 0 && ${counter} < 3 )); do
126 wc_notify -k --data-binary "$DATA_BINARY" && WC_EXIT_CODE=0
127 counter=$((counter + 1))
128 sleep 5
129 done
130
131 if (( ${WC_EXIT_CODE} !=0 ))
132 then
133 echo "Cannot send notification to wait condition with a SUCCESS status"
134 exit 1
135 fi
136 params:
137 wc_notify: { get_attr: [wait_handle, curl_cli] }
138 node_metadata: { get_param: metadata }
139
140 inject_files:
141 type: "OS::Heat::CloudConfig"
142 properties:
143 cloud_config:
144 write_files:
145 - path: /usr/sbin/prepare-metadata.py
146 owner: "root:root"
147 permissions: "0755"
148 content: {get_file: ../../de/heat-templates/scripts/prepare-metadata.py}
149 - path: /usr/share/metadata/lab-metadata.yaml
150 owner: "root:root"
151 permissions: "0644"
152 content: { get_param: hardware_metadata}
Anton Samoylov9b7c6802025-01-20 11:20:35 +0400153 - path: /etc/k0s/containerd.d/cdi.toml
154 owner: "root:root"
155 permissions: "0644"
156 content: {get_file: ../configs/cdi.toml}
Anton Samoylov17e7c032024-10-14 23:55:18 +0400157
158 install_config_agent:
159 type: "OS::Heat::MultipartMime"
160 properties:
161 parts:
162 - config: {get_resource: software_config}
163 - config: {get_resource: inject_files}
164 - config: {get_param: user_data_config}
165
166 wait_handle:
167 type: OS::Heat::WaitConditionHandle
168
169 wait_condition:
170 type: OS::Heat::WaitCondition
171 properties:
172 handle: {get_resource: wait_handle}
173 timeout: { get_param: boot_timeout }
174
Anton Samoylov72279102025-03-05 18:52:39 +0400175 server:
Anton Samoylov17e7c032024-10-14 23:55:18 +0400176 type: OS::Nova::Server
177 properties:
178 availability_zone: { get_param: availability_zone }
179 image: { get_param: image }
180 flavor: { get_param: flavor }
181 key_name: { get_param: key_name }
182 networks:
Ilya Bumarskov54f2ffb2025-10-14 13:29:14 +0200183 if:
184 - connect_pxe_network
185 - - port: { get_resource: k8s_network_port }
186 - network: { get_param: storage_frontend_network }
187 - network: { get_param: storage_backend_network }
188 - network: { get_param: data_network }
189 - port: { get_resource: pxe_network_port }
190 - - port: { get_resource: k8s_network_port }
191 - network: { get_param: storage_frontend_network }
192 - network: { get_param: storage_backend_network }
193 - network: { get_param: data_network }
194
Anton Samoylov17e7c032024-10-14 23:55:18 +0400195 user_data_format: SOFTWARE_CONFIG
196 user_data: { get_resource: install_config_agent}
197
Denis Egorenko9dd84da2025-09-23 15:05:32 +0400198 extra_volumes:
199 type: OS::Heat::ResourceGroup
200 properties:
201 count: { get_param: storage_volumes_per_node }
202 resource_def:
203 type: ./CinderVolumeVM.yaml
204 properties:
205 instance_id: { get_resource: server }
206
Anton Samoylov17e7c032024-10-14 23:55:18 +0400207outputs:
208 server_public_ip:
209 description: Floating IP address of server in public network
210 value: { get_attr: [ floating_ip_k8s_net, floating_ip_address ] }
211 wc_data:
212 description: Metadata from instance
213 value: { get_attr: [wait_condition, data]}