mirror of
https://github.com/batonogov/learn-devops.git
synced 2025-12-01 09:43:01 +00:00
Add MinIO cluster (#15)
Co-authored-by: Fedor Batonogov <f.batonogov@yandex.ru>
This commit is contained in:
committed by
GitHub
parent
a45b92d625
commit
55deb994c6
25
opentofu/nginx/.terraform.lock.hcl
generated
Normal file
25
opentofu/nginx/.terraform.lock.hcl
generated
Normal file
@@ -0,0 +1,25 @@
|
||||
# This file is maintained automatically by "tofu init".
|
||||
# Manual edits may be lost in future updates.
|
||||
|
||||
provider "registry.opentofu.org/bpg/proxmox" {
|
||||
version = "0.61.1"
|
||||
constraints = ">= 0.57.0"
|
||||
hashes = [
|
||||
"h1:SQSHTHj2ThcF08cON2gHYcnkS/XLmoF8E4cRIgpagtE=",
|
||||
"zh:27d8b589a2dc1e0a5b0f8ab299b9f3704a2f0b69799d1d4d8845c68056986d1f",
|
||||
"zh:46dfa6b33ddd7007a2144f38090457604eb56a59a303b37bb0ad1be5c84ddaca",
|
||||
"zh:47a1b14a759393c5ecc76f2feb950677c418c910b8c677fde0dd3e4675c41579",
|
||||
"zh:582e49d109d1c2b1f3b1268a7cbc43548f3c6d96a87c92a5428767097a5e383e",
|
||||
"zh:5e98ad6afae5969a4c3ffb14c0484936550c66c8313d7686551c29b633ff32f2",
|
||||
"zh:7b9e24b76f947ab8f1e571cf61beefc983b7d2aa1b85df35c4f015728fe37a38",
|
||||
"zh:8255ca210f279a0f7b8ca2762df26d2ea1a01704298c5e3d5cf601bd39a743f0",
|
||||
"zh:85d7655fdc95dedced9cf8105a0beeb0d7bc8f668c55f62019a7215a76d60300",
|
||||
"zh:8aeea5a1d001b06baaf923b754e1a14d06c75eb8c8b87a7f65a3c8205fc8b079",
|
||||
"zh:a9cfab6c06f613658c5fdd83742cd22c0eb7563778924b1407965ef8c36c1ce0",
|
||||
"zh:ceaab67801d49a92eb5858b1ddae6df2569462e5ffbe31f9dbd79dcb684ea142",
|
||||
"zh:dc25b506d5c55d1d78a335d3ebd03213c99b4b2a5859812349a955c2f746ff7e",
|
||||
"zh:e04b477fd77a0d37a0bdb76a7cf69184dad9e7fbba9b4f3a378a8901b82b75e5",
|
||||
"zh:f1e6838d9141557f73340df9b21fce5a82b41cc16ae36f063a920ccc36bc0758",
|
||||
"zh:f26e0763dbe6a6b2195c94b44696f2110f7f55433dc142839be16b9697fa5597",
|
||||
]
|
||||
}
|
||||
105
opentofu/nginx/nginx.tf
Normal file
105
opentofu/nginx/nginx.tf
Normal file
@@ -0,0 +1,105 @@
|
||||
variable "minio_vms" {
|
||||
type = list(object({
|
||||
name = string
|
||||
address = string
|
||||
node_name = string
|
||||
}))
|
||||
default = [
|
||||
{
|
||||
name = "nginx-01"
|
||||
address = "10.0.75.91/24"
|
||||
node_name = "pve-01"
|
||||
},
|
||||
{
|
||||
name = "nginx-02"
|
||||
address = "10.0.75.92/24"
|
||||
node_name = "pve-02"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
# Создание виртуальных машин
|
||||
resource "proxmox_virtual_environment_vm" "minio" {
|
||||
for_each = { for vm in var.minio_vms : vm.name => vm }
|
||||
|
||||
name = each.value.name
|
||||
migrate = true
|
||||
# protection = true
|
||||
description = "Managed by OpenTofu"
|
||||
tags = ["nignx", "opentofu"]
|
||||
on_boot = true
|
||||
node_name = each.value.node_name
|
||||
|
||||
clone {
|
||||
vm_id = "2404"
|
||||
node_name = "pve-01"
|
||||
retries = 3
|
||||
}
|
||||
|
||||
agent {
|
||||
enabled = true
|
||||
}
|
||||
|
||||
operating_system {
|
||||
type = "l26"
|
||||
}
|
||||
|
||||
cpu {
|
||||
cores = 1
|
||||
type = "host"
|
||||
numa = true
|
||||
}
|
||||
|
||||
memory {
|
||||
dedicated = 1024
|
||||
}
|
||||
|
||||
vga {
|
||||
memory = 4
|
||||
type = "serial0"
|
||||
}
|
||||
|
||||
disk {
|
||||
size = "20"
|
||||
interface = "virtio0"
|
||||
datastore_id = "proxmox-data-02"
|
||||
file_format = "raw"
|
||||
}
|
||||
|
||||
network_device {
|
||||
bridge = "vmbr0"
|
||||
model = "virtio"
|
||||
}
|
||||
|
||||
initialization {
|
||||
datastore_id = "proxmox-data-02"
|
||||
ip_config {
|
||||
ipv4 {
|
||||
address = each.value.address
|
||||
gateway = "10.0.75.1"
|
||||
}
|
||||
}
|
||||
dns {
|
||||
servers = [
|
||||
"10.0.75.65",
|
||||
"10.0.75.66"
|
||||
]
|
||||
}
|
||||
user_account {
|
||||
username = "infra"
|
||||
keys = [
|
||||
var.ssh_public_key
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Создание ресурсов высокой доступности
|
||||
# resource "proxmox_virtual_environment_haresource" "patroni" {
|
||||
# for_each = { for vm in var.minio_vms : vm.name => vm }
|
||||
|
||||
# resource_id = "vm:${proxmox_virtual_environment_vm.patroni[each.key].vm_id}"
|
||||
# state = "started"
|
||||
# group = "prod"
|
||||
# comment = "Managed by OpenTofu"
|
||||
# }
|
||||
17
opentofu/nginx/provider.tf
Normal file
17
opentofu/nginx/provider.tf
Normal file
@@ -0,0 +1,17 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
proxmox = {
|
||||
source = "bpg/proxmox"
|
||||
version = ">= 0.57.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "proxmox" {
|
||||
endpoint = var.virtual_environment_endpoint
|
||||
api_token = var.virtual_environment_api_token
|
||||
insecure = true
|
||||
ssh {
|
||||
agent = false
|
||||
}
|
||||
}
|
||||
3
opentofu/nginx/terraform.tfvars.example
Normal file
3
opentofu/nginx/terraform.tfvars.example
Normal file
@@ -0,0 +1,3 @@
|
||||
virtual_environment_api_token = "fedor@pve!opentofu=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
virtual_environment_endpoint = "https://x.x.x.x:8006/"
|
||||
ssh_public_key = "ssh-rsa ..."
|
||||
14
opentofu/nginx/variables.tf
Normal file
14
opentofu/nginx/variables.tf
Normal file
@@ -0,0 +1,14 @@
|
||||
variable "virtual_environment_endpoint" {
|
||||
type = string
|
||||
description = "The endpoint for the Proxmox Virtual Environment API (example: https://host:port)"
|
||||
}
|
||||
|
||||
variable "virtual_environment_api_token" {
|
||||
type = string
|
||||
description = "The api roken the Proxmox Virtual Environment API (example: root@pam!for-terraform-provider=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)"
|
||||
}
|
||||
|
||||
variable "ssh_public_key" {
|
||||
type = string
|
||||
description = "SSH Puclic key for VMs (example: ssh-rsa ...)"
|
||||
}
|
||||
Reference in New Issue
Block a user