blob: ad54722f72e2851a46c6759e90e096bf6ad52cae [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
19 availability_zone:
20 type: string
21 default: nova
22 boot_timeout:
23 type: number
24 description: Boot timeout for instance
25 default: 600
26 image:
27 type: string
28 description: Name of image to use for servers
29 flavor:
30 type: string
31 description: Flavor to use for servers
32 key_name:
33 type: string
34 description: Name of keypair to assign to servers
35 metadata:
36 type: json
37 default: {}
38 hardware_metadata:
39 description: The content of lab metadata.
40 type: string
41 user_data_config:
42 description: This is part of clout-config which denies to mount drive with label ephemeral0 to /mnt
43 type: string
44 default: |
45 #cloud-config
46 #
47 # Don't mount ephemeral0 to /mnt as it's by default
48 mounts:
49 - [ ephemeral0, null ]
50
51resources:
52
53 k8s_network_port:
54 type: OS::Neutron::Port
55 properties:
56 network: { get_param: k8s_network }
57 port_security_enabled: false
58 fixed_ips:
59 - subnet: { get_param: k8s_subnet_id }
Anton Samoylovafd066e2025-08-27 10:58:38 +040060 - subnet: { get_param: k8s_subnet_ipv6_id }
Anton Samoylov17e7c032024-10-14 23:55:18 +040061
62 floating_ip_k8s_net:
63 type: OS::Neutron::FloatingIP
64 properties:
65 floating_network_id: { get_param: public_net_id }
66 port_id: { get_resource: k8s_network_port }
67
68 software_config:
69 type: OS::Heat::SoftwareConfig
70 properties:
71 group: ungrouped
72 config:
73 str_replace:
74 template: |
75 #!/bin/bash
76
77 set -x
78
79 /usr/sbin/prepare-metadata.py --metadata-file /usr/share/metadata/lab-metadata.yaml
80
81 HW_METADATA='{}'
82 if [[ -f /usr/share/metadata/ceph.yaml && 'node_metadata' == *"ceph-osd-node"* ]]; then
83 HW_METADATA="{\"ceph\": {\"$(hostname)\": \"$(base64 -w 0 /usr/share/metadata/ceph.yaml)\"}}"
84 ceph_store_drive=$(cat /usr/share/metadata/ceph.yaml | egrep '\- name\: vd?' | awk '{print $3}')
85 if [[ -b /dev/${ceph_store_drive} ]]; then
86 sgdisk --zap-all /dev/${ceph_store_drive}
87 fi
88 fi
Ann Taraday56283e52024-10-25 15:36:20 +020089
90 apt install nfs-common -y
Anton Samoylov17e7c032024-10-14 23:55:18 +040091
92 STATUS="SUCCESS"
93 REASON="The node has been successfully deployed"
94 DATA_BINARY="{\"status\": \"$STATUS\", \"reason\": \"$REASON\", \"data\": $HW_METADATA}"
95 echo "Sending notification to wait condition with data: $HW_METADATA"
96
97 WC_EXIT_CODE=1
98 counter=0
99 while (( ${WC_EXIT_CODE} != 0 && ${counter} < 3 )); do
100 wc_notify -k --data-binary "$DATA_BINARY" && WC_EXIT_CODE=0
101 counter=$((counter + 1))
102 sleep 5
103 done
104
105 if (( ${WC_EXIT_CODE} !=0 ))
106 then
107 echo "Cannot send notification to wait condition with a SUCCESS status"
108 exit 1
109 fi
110 params:
111 wc_notify: { get_attr: [wait_handle, curl_cli] }
112 node_metadata: { get_param: metadata }
113
114 inject_files:
115 type: "OS::Heat::CloudConfig"
116 properties:
117 cloud_config:
118 write_files:
119 - path: /usr/sbin/prepare-metadata.py
120 owner: "root:root"
121 permissions: "0755"
122 content: {get_file: ../../de/heat-templates/scripts/prepare-metadata.py}
123 - path: /usr/share/metadata/lab-metadata.yaml
124 owner: "root:root"
125 permissions: "0644"
126 content: { get_param: hardware_metadata}
Anton Samoylov9b7c6802025-01-20 11:20:35 +0400127 - path: /etc/k0s/containerd.d/cdi.toml
128 owner: "root:root"
129 permissions: "0644"
130 content: {get_file: ../configs/cdi.toml}
Anton Samoylov17e7c032024-10-14 23:55:18 +0400131
132 install_config_agent:
133 type: "OS::Heat::MultipartMime"
134 properties:
135 parts:
136 - config: {get_resource: software_config}
137 - config: {get_resource: inject_files}
138 - config: {get_param: user_data_config}
139
140 wait_handle:
141 type: OS::Heat::WaitConditionHandle
142
143 wait_condition:
144 type: OS::Heat::WaitCondition
145 properties:
146 handle: {get_resource: wait_handle}
147 timeout: { get_param: boot_timeout }
148
Anton Samoylov72279102025-03-05 18:52:39 +0400149 server:
Anton Samoylov17e7c032024-10-14 23:55:18 +0400150 type: OS::Nova::Server
151 properties:
152 availability_zone: { get_param: availability_zone }
153 image: { get_param: image }
154 flavor: { get_param: flavor }
155 key_name: { get_param: key_name }
156 networks:
157 - port: { get_resource: k8s_network_port }
158 - network: { get_param : storage_frontend_network }
159 - network: { get_param : storage_backend_network }
160 - network: { get_param : data_network }
161 user_data_format: SOFTWARE_CONFIG
162 user_data: { get_resource: install_config_agent}
163
164outputs:
165 server_public_ip:
166 description: Floating IP address of server in public network
167 value: { get_attr: [ floating_ip_k8s_net, floating_ip_address ] }
168 wc_data:
169 description: Metadata from instance
170 value: { get_attr: [wait_condition, data]}