commit fix
This commit is contained in:
31
cluster/cloud-config/rocky.yml
Normal file
31
cluster/cloud-config/rocky.yml
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#cloud-config
|
||||||
|
timezone: Europe/Moscow
|
||||||
|
|
||||||
|
users:
|
||||||
|
- name: rocky
|
||||||
|
groups: [wheel]
|
||||||
|
shell: /bin/bash
|
||||||
|
lock_passwd: false
|
||||||
|
passwd: "$6$M8xzsYT0lwWjlcdH$HJRhw0rBb2WowCbqg03/WvMUlte0j5SLs9tAVCxCukEqWAt7XG0ceWYc5GRUBmRxFRTbcEDrdCVTXu5jIxN2f0"
|
||||||
|
sudo: ["ALL=(ALL) NOPASSWD:ALL"]
|
||||||
|
ssh_authorized_keys:
|
||||||
|
- ${ssh_key}
|
||||||
|
|
||||||
|
package_update: true
|
||||||
|
|
||||||
|
packages:
|
||||||
|
- qemu-guest-agent
|
||||||
|
|
||||||
|
runcmd:
|
||||||
|
- systemctl enable --now qemu-guest-agent
|
||||||
|
- hostnamectl set-hostname ${hostname}
|
||||||
|
- systemctl disable --now packagekit || true
|
||||||
|
- systemctl disable --now ModemManager || true
|
||||||
|
- systemctl disable --now multipathd || true
|
||||||
|
|
||||||
|
write_files:
|
||||||
|
- path: /etc/motd
|
||||||
|
content: |
|
||||||
|
Managed by OpenTofu
|
||||||
|
|
||||||
|
final_message: "cloud-init finished"
|
||||||
124
example_locals.tf
Normal file
124
example_locals.tf
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
locals {
|
||||||
|
nodes = {
|
||||||
|
k8s-worker-1 = {
|
||||||
|
index = 1
|
||||||
|
cpu = 2
|
||||||
|
memory = 2048
|
||||||
|
|
||||||
|
disks = [
|
||||||
|
{
|
||||||
|
datastore = "ssd2"
|
||||||
|
interface = "scsi0"
|
||||||
|
size = 20
|
||||||
|
import_from = "local:import/ubuntu-24.qcow2"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
network_devices = [
|
||||||
|
{
|
||||||
|
bridge = "vmbr0"
|
||||||
|
vlan_id = 20
|
||||||
|
ip = "192.168.20.10"
|
||||||
|
cidr = 24
|
||||||
|
gateway = "192.168.20.1"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
k8s-worker-2 = {
|
||||||
|
index = 2
|
||||||
|
cpu = 2
|
||||||
|
memory = 2048
|
||||||
|
|
||||||
|
disks = [
|
||||||
|
{
|
||||||
|
datastore = "ssd2"
|
||||||
|
interface = "scsi0"
|
||||||
|
size = 20
|
||||||
|
import_from = "local:import/ubuntu-24.qcow2"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
network_devices = [
|
||||||
|
{
|
||||||
|
bridge = "vmbr0"
|
||||||
|
vlan_id = 20
|
||||||
|
ip = "192.168.20.11"
|
||||||
|
cidr = 24
|
||||||
|
gateway = "192.168.20.1"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
k8s-worker-3 = {
|
||||||
|
index = 3
|
||||||
|
cpu = 2
|
||||||
|
memory = 2048
|
||||||
|
|
||||||
|
disks = [
|
||||||
|
{
|
||||||
|
datastore = "ssd2"
|
||||||
|
interface = "scsi0"
|
||||||
|
size = 20
|
||||||
|
import_from = "local:import/ubuntu-24.qcow2"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
network_devices = [
|
||||||
|
{
|
||||||
|
bridge = "vmbr0"
|
||||||
|
vlan_id = 20
|
||||||
|
ip = "192.168.20.12"
|
||||||
|
cidr = 24
|
||||||
|
gateway = "192.168.20.1"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
k8s-worker-4 = {
|
||||||
|
index = 4
|
||||||
|
cpu = 2
|
||||||
|
memory = 2048
|
||||||
|
|
||||||
|
disks = [
|
||||||
|
{
|
||||||
|
datastore = "ssd2"
|
||||||
|
interface = "scsi0"
|
||||||
|
size = 20
|
||||||
|
import_from = "local:import/ubuntu-24.qcow2"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
network_devices = [
|
||||||
|
{
|
||||||
|
bridge = "vmbr0"
|
||||||
|
vlan_id = 20
|
||||||
|
ip = "192.168.20.13"
|
||||||
|
cidr = 24
|
||||||
|
gateway = "192.168.20.1"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
k8s-worker-5 = {
|
||||||
|
index = 5
|
||||||
|
cpu = 2
|
||||||
|
memory = 2048
|
||||||
|
|
||||||
|
disks = [
|
||||||
|
{
|
||||||
|
datastore = "ssd2"
|
||||||
|
interface = "scsi0"
|
||||||
|
size = 20
|
||||||
|
import_from = "local:import/ubuntu-24.qcow2"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
network_devices = [
|
||||||
|
{
|
||||||
|
bridge = "vmbr0"
|
||||||
|
vlan_id = 20
|
||||||
|
ip = "192.168.20.14"
|
||||||
|
cidr = 24
|
||||||
|
gateway = "192.168.20.1"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
54
generate.py
Normal file
54
generate.py
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
BASE_IP = "192.168.20"
|
||||||
|
START = 10
|
||||||
|
COUNT = 5
|
||||||
|
|
||||||
|
CPU = 2
|
||||||
|
MEMORY = 2048
|
||||||
|
GATEWAY = "192.168.20.1"
|
||||||
|
|
||||||
|
def generate():
|
||||||
|
print("locals {")
|
||||||
|
print(" nodes = {")
|
||||||
|
|
||||||
|
for i in range(COUNT):
|
||||||
|
idx = i + 1
|
||||||
|
last_octet = START + i
|
||||||
|
|
||||||
|
if last_octet > 254:
|
||||||
|
raise ValueError("IP overflow")
|
||||||
|
|
||||||
|
ip = f"{BASE_IP}.{last_octet}"
|
||||||
|
comma = "," if i < COUNT - 1 else ""
|
||||||
|
|
||||||
|
print(f""" k8s-worker-{idx} = {{
|
||||||
|
index = {idx}
|
||||||
|
cpu = {CPU}
|
||||||
|
memory = {MEMORY}
|
||||||
|
|
||||||
|
disks = [
|
||||||
|
{{
|
||||||
|
datastore = "ssd2"
|
||||||
|
interface = "scsi0"
|
||||||
|
size = 20
|
||||||
|
import_from = "local:import/ubuntu-24.qcow2"
|
||||||
|
}}
|
||||||
|
]
|
||||||
|
|
||||||
|
network_devices = [
|
||||||
|
{{
|
||||||
|
bridge = "vmbr0"
|
||||||
|
vlan_id = 20
|
||||||
|
ip = "{ip}"
|
||||||
|
cidr = 24
|
||||||
|
gateway = "{GATEWAY}"
|
||||||
|
}}
|
||||||
|
]
|
||||||
|
}}{comma}""")
|
||||||
|
|
||||||
|
print(" }")
|
||||||
|
print("}")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
generate()
|
||||||
34
infra/cloud-config/master.yml
Normal file
34
infra/cloud-config/master.yml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#cloud-config
|
||||||
|
# Создать passwd hash: openssl passwd -6
|
||||||
|
|
||||||
|
timezone: Europe/Moscow
|
||||||
|
|
||||||
|
users:
|
||||||
|
- name: iurii
|
||||||
|
groups: [sudo]
|
||||||
|
shell: /bin/bash
|
||||||
|
lock_passwd: false
|
||||||
|
passwd: "$6$Zc8nwvtw0Kns5.sD$FpQ4aBSeGogefqjM4we4U5QQd4YBtC98tuG3rR4j9ZmbtC1kyFf2sY/IodYW3wG.U81aEntlZrtOTOqw3ZcOc0"
|
||||||
|
sudo: ["ALL=(ALL) NOPASSWD:ALL"]
|
||||||
|
ssh_authorized_keys:
|
||||||
|
- ${ssh_key}
|
||||||
|
|
||||||
|
package_update: true
|
||||||
|
|
||||||
|
packages:
|
||||||
|
- qemu-guest-agent
|
||||||
|
|
||||||
|
runcmd:
|
||||||
|
- systemctl enable --now qemu-guest-agent
|
||||||
|
- hostnamectl set-hostname ${hostname}
|
||||||
|
- systemctl disable --now packagekit
|
||||||
|
- systemctl disable --now ModemManager
|
||||||
|
- systemctl disable --now multipathd
|
||||||
|
|
||||||
|
write_files:
|
||||||
|
- path: /etc/motd
|
||||||
|
content: |
|
||||||
|
Managed by OpenTofu
|
||||||
|
|
||||||
|
|
||||||
|
final_message: "cloud-init finished"
|
||||||
34
infra/cloud-config/worker.yml
Normal file
34
infra/cloud-config/worker.yml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#cloud-config
|
||||||
|
# Создать passwd hash: openssl passwd -6
|
||||||
|
|
||||||
|
timezone: Europe/Moscow
|
||||||
|
|
||||||
|
users:
|
||||||
|
- name: iurii
|
||||||
|
groups: [sudo]
|
||||||
|
shell: /bin/bash
|
||||||
|
lock_passwd: false
|
||||||
|
passwd: "$6$Zc8nwvtw0Kns5.sD$FpQ4aBSeGogefqjM4we4U5QQd4YBtC98tuG3rR4j9ZmbtC1kyFf2sY/IodYW3wG.U81aEntlZrtOTOqw3ZcOc0"
|
||||||
|
sudo: ["ALL=(ALL) NOPASSWD:ALL"]
|
||||||
|
ssh_authorized_keys:
|
||||||
|
- ${ssh_key}
|
||||||
|
|
||||||
|
package_update: true
|
||||||
|
|
||||||
|
packages:
|
||||||
|
- qemu-guest-agent
|
||||||
|
|
||||||
|
runcmd:
|
||||||
|
- systemctl enable --now qemu-guest-agent
|
||||||
|
- hostnamectl set-hostname ${hostname}
|
||||||
|
- systemctl disable --now packagekit
|
||||||
|
- systemctl disable --now ModemManager
|
||||||
|
- systemctl disable --now multipathd
|
||||||
|
|
||||||
|
write_files:
|
||||||
|
- path: /etc/motd
|
||||||
|
content: |
|
||||||
|
Managed by OpenTofu
|
||||||
|
|
||||||
|
|
||||||
|
final_message: "cloud-init finished"
|
||||||
34
lab/cloud-config/lab.yml
Normal file
34
lab/cloud-config/lab.yml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#cloud-config
|
||||||
|
# Создать passwd hash: openssl passwd -6
|
||||||
|
|
||||||
|
timezone: Europe/Moscow
|
||||||
|
|
||||||
|
users:
|
||||||
|
- name: iurii
|
||||||
|
groups: [sudo]
|
||||||
|
shell: /bin/bash
|
||||||
|
lock_passwd: false
|
||||||
|
passwd: "$6$Zc8nwvtw0Kns5.sD$FpQ4aBSeGogefqjM4we4U5QQd4YBtC98tuG3rR4j9ZmbtC1kyFf2sY/IodYW3wG.U81aEntlZrtOTOqw3ZcOc0"
|
||||||
|
sudo: ["ALL=(ALL) NOPASSWD:ALL"]
|
||||||
|
ssh_authorized_keys:
|
||||||
|
- ${ssh_key}
|
||||||
|
|
||||||
|
package_update: true
|
||||||
|
|
||||||
|
packages:
|
||||||
|
- qemu-guest-agent
|
||||||
|
|
||||||
|
runcmd:
|
||||||
|
- systemctl enable --now qemu-guest-agent
|
||||||
|
- hostnamectl set-hostname ${hostname}
|
||||||
|
- systemctl disable --now packagekit
|
||||||
|
- systemctl disable --now ModemManager
|
||||||
|
- systemctl disable --now multipathd
|
||||||
|
|
||||||
|
write_files:
|
||||||
|
- path: /etc/motd
|
||||||
|
content: |
|
||||||
|
Managed by OpenTofu
|
||||||
|
|
||||||
|
|
||||||
|
final_message: "cloud-init finished"
|
||||||
48
setup_disk.sh
Normal file
48
setup_disk.sh
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
DISK="/dev/sdb"
|
||||||
|
PART="${DISK}1"
|
||||||
|
MOUNT_POINT="/u01"
|
||||||
|
|
||||||
|
echo "[1] Проверка диска"
|
||||||
|
lsblk "$DISK"
|
||||||
|
|
||||||
|
echo "[2] Создание GPT и раздела"
|
||||||
|
sudo parted "$DISK" --script mklabel gpt
|
||||||
|
sudo parted "$DISK" --script mkpart primary ext4 0% 100%
|
||||||
|
|
||||||
|
echo "[3] Ожидание появления раздела"
|
||||||
|
sleep 2
|
||||||
|
|
||||||
|
echo "[4] Форматирование"
|
||||||
|
sudo mkfs.ext4 -F "$PART"
|
||||||
|
|
||||||
|
echo "[5] Создание точки монтирования"
|
||||||
|
sudo mkdir -p "$MOUNT_POINT"
|
||||||
|
|
||||||
|
echo "[6] Получение UUID"
|
||||||
|
UUID=$(blkid -s UUID -o value "$PART")
|
||||||
|
|
||||||
|
if [[ -z "$UUID" ]]; then
|
||||||
|
echo "ERROR: UUID not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "[7] Добавление в fstab"
|
||||||
|
if ! grep -q "$UUID" /etc/fstab; then
|
||||||
|
echo "UUID=$UUID $MOUNT_POINT ext4 defaults,nofail 0 2" | sudo tee -a /etc/fstab
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "[8] Применение"
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo mount -a
|
||||||
|
|
||||||
|
echo "[9] Проверка"
|
||||||
|
df -h | grep "$MOUNT_POINT"
|
||||||
|
|
||||||
|
echo "[10] Подготовка под OpenSearch"
|
||||||
|
sudo mkdir -p /u01/opensearch
|
||||||
|
sudo chown -R 1000:1000 /u01/opensearch
|
||||||
|
|
||||||
|
echo "DONE"
|
||||||
Reference in New Issue
Block a user