mirror of
https://github.com/batonogov/learn-devops.git
synced 2025-11-29 00:33:02 +00:00
Add kubeadm example (#4)
* Add kubeadm example * Fix dns --------- Co-authored-by: Fedor Batonogov <f.batonogov@yandex.ru>
This commit is contained in:
committed by
GitHub
parent
346360f820
commit
07fb0c68bf
25
opentofu/kubeadm/.terraform.lock.hcl
generated
Normal file
25
opentofu/kubeadm/.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.54.0"
|
||||
constraints = ">= 0.51.0"
|
||||
hashes = [
|
||||
"h1:xgDrDol/cYu93YOPTL0UVpURchPzdxPXaHjcoieoXXI=",
|
||||
"zh:4521f8893b4645c93e75ffc3545ea59d3f31aed7cea4c26dcd0fbd7c0cce6ca8",
|
||||
"zh:520e56abd10d888935047ef07a7577c2a1cce5bc54e25b03a0dbdc4356997ca9",
|
||||
"zh:53469dd058ef8b2ea29577f69a2681f8ffb9f79494b8c1d1594dd42ad314d7bd",
|
||||
"zh:6948adb6e088fe652b7273906a5c11032528f84eb5a5ca797534ab3b6076a8c6",
|
||||
"zh:72655e9765b7791e3e37508c70a847172561bff348c7d5f916794e5823a84efe",
|
||||
"zh:7faa281319d90026ad9b2dce00ac059896f451cb9305ed11bb90fcfda7c5d143",
|
||||
"zh:8fe20fa893e9545aa30672392f76948ed56a93a2decb1d3bd8693c5e1d2dd85a",
|
||||
"zh:b175411aa820c1a47473ef691c743670eeb900999576c6cdcb113d14a7c499aa",
|
||||
"zh:b59205ad7981f263ff287d3eb0a93296f8cd6b166a01ddd3b16606fc39d456ec",
|
||||
"zh:f26e0763dbe6a6b2195c94b44696f2110f7f55433dc142839be16b9697fa5597",
|
||||
"zh:f3524bc67d995e98ad9d7e17f3be91f7a975608180fad6b227fc42087b5facc1",
|
||||
"zh:f4bf087717e1b0f5f3ee7d3b6b47fb66e5f821097f15ec0cf6714a39c7d80959",
|
||||
"zh:fc14a29b1aef50872d60f338af89f7cbbac307c630f973c07a7951bdde8be2a5",
|
||||
"zh:fc72da3d651bf0f0e20a0860e9217a94797b4c1d5cae1742f1b8e15d28f8ceeb",
|
||||
"zh:fff2299a427e1590775611bf186220686795af966772e61e44234f0df44b6c22",
|
||||
]
|
||||
}
|
||||
70
opentofu/kubeadm/control-plane-01.tf
Normal file
70
opentofu/kubeadm/control-plane-01.tf
Normal file
@@ -0,0 +1,70 @@
|
||||
# Машинка
|
||||
resource "proxmox_virtual_environment_vm" "kubeadm-cp-01" {
|
||||
name = "kubeadm-cp-01"
|
||||
migrate = true
|
||||
description = "Managed by OpenTofu"
|
||||
tags = ["kubeadm", "test"]
|
||||
on_boot = true
|
||||
|
||||
# Указываем целевой узел, на котором будет запущена ВМ
|
||||
node_name = "pve-01"
|
||||
|
||||
# Шоблон из которого будет создавать ВМ
|
||||
clone {
|
||||
vm_id = "2204"
|
||||
node_name = "pve-01"
|
||||
retries = 2
|
||||
}
|
||||
|
||||
# Активируем QEMU для этов ВМ
|
||||
agent {
|
||||
enabled = true
|
||||
}
|
||||
|
||||
operating_system {
|
||||
type = "l26"
|
||||
}
|
||||
|
||||
cpu {
|
||||
cores = 4
|
||||
type = "host"
|
||||
numa = true
|
||||
}
|
||||
|
||||
memory {
|
||||
dedicated = 4096
|
||||
}
|
||||
|
||||
disk {
|
||||
size = "50"
|
||||
interface = "virtio0"
|
||||
datastore_id = "k8s-data-01"
|
||||
file_format = "raw"
|
||||
}
|
||||
|
||||
network_device {
|
||||
bridge = "vmbr0"
|
||||
model = "virtio"
|
||||
}
|
||||
|
||||
initialization {
|
||||
datastore_id = "k8s-data-01"
|
||||
ip_config {
|
||||
ipv4 {
|
||||
address = "10.0.70.70/24"
|
||||
gateway = "10.0.70.101"
|
||||
}
|
||||
}
|
||||
dns {
|
||||
servers = [
|
||||
"77.88.8.8"
|
||||
]
|
||||
}
|
||||
user_account {
|
||||
username = "infra"
|
||||
keys = [
|
||||
"ssh-rsa..."
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
70
opentofu/kubeadm/control-plane-02.tf
Normal file
70
opentofu/kubeadm/control-plane-02.tf
Normal file
@@ -0,0 +1,70 @@
|
||||
# Машинка
|
||||
resource "proxmox_virtual_environment_vm" "kubeadm-cp-02" {
|
||||
name = "kubeadm-cp-02"
|
||||
migrate = true
|
||||
description = "Managed by OpenTofu"
|
||||
tags = ["kubeadm", "test"]
|
||||
on_boot = true
|
||||
|
||||
# Указываем целевой узел, на котором будет запущена ВМ
|
||||
node_name = "pve-02"
|
||||
|
||||
# Шоблон из которого будет создавать ВМ
|
||||
clone {
|
||||
vm_id = "2204"
|
||||
node_name = "pve-01"
|
||||
retries = 2
|
||||
}
|
||||
|
||||
# Активируем QEMU для этов ВМ
|
||||
agent {
|
||||
enabled = true
|
||||
}
|
||||
|
||||
operating_system {
|
||||
type = "l26"
|
||||
}
|
||||
|
||||
cpu {
|
||||
cores = 4
|
||||
type = "host"
|
||||
numa = true
|
||||
}
|
||||
|
||||
memory {
|
||||
dedicated = 4096
|
||||
}
|
||||
|
||||
disk {
|
||||
size = "50"
|
||||
interface = "virtio0"
|
||||
datastore_id = "k8s-data-01"
|
||||
file_format = "raw"
|
||||
}
|
||||
|
||||
network_device {
|
||||
bridge = "vmbr0"
|
||||
model = "virtio"
|
||||
}
|
||||
|
||||
initialization {
|
||||
datastore_id = "k8s-data-01"
|
||||
ip_config {
|
||||
ipv4 {
|
||||
address = "10.0.70.78/24"
|
||||
gateway = "10.0.70.101"
|
||||
}
|
||||
}
|
||||
dns {
|
||||
servers = [
|
||||
"77.88.8.8"
|
||||
]
|
||||
}
|
||||
user_account {
|
||||
username = "infra"
|
||||
keys = [
|
||||
"ssh-rsa..."
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
70
opentofu/kubeadm/control-plane-03.tf
Normal file
70
opentofu/kubeadm/control-plane-03.tf
Normal file
@@ -0,0 +1,70 @@
|
||||
# Машинка
|
||||
resource "proxmox_virtual_environment_vm" "kubeadm-cp-03" {
|
||||
name = "kubeadm-cp-03"
|
||||
migrate = true
|
||||
description = "Managed by OpenTofu"
|
||||
tags = ["kubeadm", "test"]
|
||||
on_boot = true
|
||||
|
||||
# Указываем целевой узел, на котором будет запущена ВМ
|
||||
node_name = "pve-03"
|
||||
|
||||
# Шоблон из которого будет создавать ВМ
|
||||
clone {
|
||||
vm_id = "2204"
|
||||
node_name = "pve-01"
|
||||
retries = 2
|
||||
}
|
||||
|
||||
# Активируем QEMU для этов ВМ
|
||||
agent {
|
||||
enabled = true
|
||||
}
|
||||
|
||||
operating_system {
|
||||
type = "l26"
|
||||
}
|
||||
|
||||
cpu {
|
||||
cores = 4
|
||||
type = "host"
|
||||
numa = true
|
||||
}
|
||||
|
||||
memory {
|
||||
dedicated = 4096
|
||||
}
|
||||
|
||||
disk {
|
||||
size = "50"
|
||||
interface = "virtio0"
|
||||
datastore_id = "k8s-data-01"
|
||||
file_format = "raw"
|
||||
}
|
||||
|
||||
network_device {
|
||||
bridge = "vmbr0"
|
||||
model = "virtio"
|
||||
}
|
||||
|
||||
initialization {
|
||||
datastore_id = "k8s-data-01"
|
||||
ip_config {
|
||||
ipv4 {
|
||||
address = "10.0.70.79/24"
|
||||
gateway = "10.0.70.101"
|
||||
}
|
||||
}
|
||||
dns {
|
||||
servers = [
|
||||
"77.88.8.8"
|
||||
]
|
||||
}
|
||||
user_account {
|
||||
username = "infra"
|
||||
keys = [
|
||||
"ssh-rsa..."
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
70
opentofu/kubeadm/node-01.tf
Normal file
70
opentofu/kubeadm/node-01.tf
Normal file
@@ -0,0 +1,70 @@
|
||||
# Машинка
|
||||
resource "proxmox_virtual_environment_vm" "kubeadm-node-01" {
|
||||
name = "kubeadm-node-01"
|
||||
migrate = true
|
||||
description = "Managed by OpenTofu"
|
||||
tags = ["kubeadm", "test"]
|
||||
on_boot = true
|
||||
|
||||
# Указываем целевой узел, на котором будет запущена ВМ
|
||||
node_name = "pve-01"
|
||||
|
||||
# Шоблон из которого будет создавать ВМ
|
||||
clone {
|
||||
vm_id = "2204"
|
||||
node_name = "pve-01"
|
||||
retries = 2
|
||||
}
|
||||
|
||||
# Активируем QEMU для этов ВМ
|
||||
agent {
|
||||
enabled = true
|
||||
}
|
||||
|
||||
operating_system {
|
||||
type = "l26"
|
||||
}
|
||||
|
||||
cpu {
|
||||
cores = 4
|
||||
type = "host"
|
||||
numa = true
|
||||
}
|
||||
|
||||
memory {
|
||||
dedicated = 32768
|
||||
}
|
||||
|
||||
disk {
|
||||
size = "500"
|
||||
interface = "virtio0"
|
||||
datastore_id = "k8s-data-01"
|
||||
file_format = "raw"
|
||||
}
|
||||
|
||||
network_device {
|
||||
bridge = "vmbr0"
|
||||
model = "virtio"
|
||||
}
|
||||
|
||||
initialization {
|
||||
datastore_id = "k8s-data-01"
|
||||
ip_config {
|
||||
ipv4 {
|
||||
address = "10.0.70.71/24"
|
||||
gateway = "10.0.70.101"
|
||||
}
|
||||
}
|
||||
dns {
|
||||
servers = [
|
||||
"77.88.8.8"
|
||||
]
|
||||
}
|
||||
user_account {
|
||||
username = "infra"
|
||||
keys = [
|
||||
"ssh-rsa..."
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
70
opentofu/kubeadm/node-02.tf
Normal file
70
opentofu/kubeadm/node-02.tf
Normal file
@@ -0,0 +1,70 @@
|
||||
# Машинка
|
||||
resource "proxmox_virtual_environment_vm" "kubeadm-node-02" {
|
||||
name = "kubeadm-node-02"
|
||||
migrate = true
|
||||
description = "Managed by OpenTofu"
|
||||
tags = ["kubeadm", "test"]
|
||||
on_boot = true
|
||||
|
||||
# Указываем целевой узел, на котором будет запущена ВМ
|
||||
node_name = "pve-02"
|
||||
|
||||
# Шоблон из которого будет создавать ВМ
|
||||
clone {
|
||||
vm_id = "2204"
|
||||
node_name = "pve-01"
|
||||
retries = 2
|
||||
}
|
||||
|
||||
# Активируем QEMU для этов ВМ
|
||||
agent {
|
||||
enabled = true
|
||||
}
|
||||
|
||||
operating_system {
|
||||
type = "l26"
|
||||
}
|
||||
|
||||
cpu {
|
||||
cores = 4
|
||||
type = "host"
|
||||
numa = true
|
||||
}
|
||||
|
||||
memory {
|
||||
dedicated = 32768
|
||||
}
|
||||
|
||||
disk {
|
||||
size = "500"
|
||||
interface = "virtio0"
|
||||
datastore_id = "k8s-data-01"
|
||||
file_format = "raw"
|
||||
}
|
||||
|
||||
network_device {
|
||||
bridge = "vmbr0"
|
||||
model = "virtio"
|
||||
}
|
||||
|
||||
initialization {
|
||||
datastore_id = "k8s-data-01"
|
||||
ip_config {
|
||||
ipv4 {
|
||||
address = "10.0.70.77/24"
|
||||
gateway = "10.0.70.101"
|
||||
}
|
||||
}
|
||||
dns {
|
||||
servers = [
|
||||
"77.88.8.8"
|
||||
]
|
||||
}
|
||||
user_account {
|
||||
username = "infra"
|
||||
keys = [
|
||||
"ssh-rsa..."
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
70
opentofu/kubeadm/node-03.tf
Normal file
70
opentofu/kubeadm/node-03.tf
Normal file
@@ -0,0 +1,70 @@
|
||||
# Машинка
|
||||
resource "proxmox_virtual_environment_vm" "kubeadm-node-03" {
|
||||
name = "kubeadm-node-03"
|
||||
migrate = true
|
||||
description = "Managed by OpenTofu"
|
||||
tags = ["kubeadm", "test"]
|
||||
on_boot = true
|
||||
|
||||
# Указываем целевой узел, на котором будет запущена ВМ
|
||||
node_name = "pve-03"
|
||||
|
||||
# Шоблон из которого будет создавать ВМ
|
||||
clone {
|
||||
vm_id = "2204"
|
||||
node_name = "pve-01"
|
||||
retries = 2
|
||||
}
|
||||
|
||||
# Активируем QEMU для этов ВМ
|
||||
agent {
|
||||
enabled = true
|
||||
}
|
||||
|
||||
operating_system {
|
||||
type = "l26"
|
||||
}
|
||||
|
||||
cpu {
|
||||
cores = 4
|
||||
type = "host"
|
||||
numa = true
|
||||
}
|
||||
|
||||
memory {
|
||||
dedicated = 32768
|
||||
}
|
||||
|
||||
disk {
|
||||
size = "500"
|
||||
interface = "virtio0"
|
||||
datastore_id = "k8s-data-01"
|
||||
file_format = "raw"
|
||||
}
|
||||
|
||||
network_device {
|
||||
bridge = "vmbr0"
|
||||
model = "virtio"
|
||||
}
|
||||
|
||||
initialization {
|
||||
datastore_id = "k8s-data-01"
|
||||
ip_config {
|
||||
ipv4 {
|
||||
address = "10.0.70.74/24"
|
||||
gateway = "10.0.70.101"
|
||||
}
|
||||
}
|
||||
dns {
|
||||
servers = [
|
||||
"77.88.8.8"
|
||||
]
|
||||
}
|
||||
user_account {
|
||||
username = "infra"
|
||||
keys = [
|
||||
"ssh-rsa..."
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
17
opentofu/kubeadm/provider.tf
Normal file
17
opentofu/kubeadm/provider.tf
Normal file
@@ -0,0 +1,17 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
proxmox = {
|
||||
source = "bpg/proxmox"
|
||||
version = ">= 0.51.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "proxmox" {
|
||||
endpoint = var.virtual_environment_endpoint
|
||||
api_token = var.virtual_environment_api_token
|
||||
insecure = true
|
||||
ssh {
|
||||
agent = false
|
||||
}
|
||||
}
|
||||
2
opentofu/kubeadm/terraform.tfvars.example
Normal file
2
opentofu/kubeadm/terraform.tfvars.example
Normal file
@@ -0,0 +1,2 @@
|
||||
virtual_environment_api_token = "root@pam!for-terraform-provider=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
virtual_environment_endpoint = "https://10.0.70.116:8006/"
|
||||
9
opentofu/kubeadm/variables.tf
Normal file
9
opentofu/kubeadm/variables.tf
Normal file
@@ -0,0 +1,9 @@
|
||||
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)"
|
||||
}
|
||||
Reference in New Issue
Block a user