mirror of
https://github.com/rodneyosodo/homelab.git
synced 2026-06-23 04:10:19 +00:00
feat(k8s): add k3s kubernetes cluster
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
# Kubernetes
|
||||
|
||||
## Requirements
|
||||
|
||||
- [Galana](terraform/galana)
|
||||
- [Turkwel](terraform/turkwel)
|
||||
- [Yala](terraform/yala)
|
||||
|
||||
## Setup
|
||||
|
||||
### Galana
|
||||
|
||||
```bash
|
||||
ssh rodneyosodo@galana
|
||||
curl -sfL https://get.k3s.io | sh -
|
||||
sudo scp /etc/rancher/k3s/k3s.yaml rodneyosodo@thor:/home/rodneyosodo/Downloads/k3s-config
|
||||
sudo cat /var/lib/rancher/k3s/server/node-token
|
||||
```
|
||||
|
||||
Change server address to `https://galana:6443`
|
||||
|
||||
### Turkwel & Yala
|
||||
|
||||
```bash
|
||||
ssh rodneyosodo@turkwel
|
||||
ssh rodneyosodo@yala
|
||||
curl -sfL https://get.k3s.io | K3S_URL=https://galana:6443 K3S_TOKEN=mynodetoken sh -
|
||||
```
|
||||
Generated
+25
@@ -0,0 +1,25 @@
|
||||
# This file is maintained automatically by "terraform init".
|
||||
# Manual edits may be lost in future updates.
|
||||
|
||||
provider "registry.terraform.io/bpg/proxmox" {
|
||||
version = "0.66.3"
|
||||
constraints = "0.66.3"
|
||||
hashes = [
|
||||
"h1:pvHmVDhXF7Yv45MxTiB0nY3NEkFkCh4AJ5nYU1jYoK8=",
|
||||
"zh:372c7e42af71ea4be52fd61a9b29caa8cff913c38c2e639d84797060f0e78f8a",
|
||||
"zh:45b15873f78b13051fa8eaf59bc1d480ad1feaba7074ea97fb3775787a9bdadb",
|
||||
"zh:50792893b1d7441e39433b10ad706a14468fb43326842b06e2bc95fb3c9801fb",
|
||||
"zh:591ad7b8d2d4f12d617201caf5bacddca69e68ba396e6ff60d9d1ca0ee59a6f5",
|
||||
"zh:8d63f1eaf8a1731abffed0ef1ce15423bd56faebb1819743884841f7f9ab4126",
|
||||
"zh:90400a0beb68c99e262f9a6bc93daf9dfaeefdb3af673c2a86c17853c73fa868",
|
||||
"zh:9c0ff725d5a0c2095144a6eeb8c98fb9a3dc5f36c80e526ad63b51ce4094973a",
|
||||
"zh:a099fea3db1a858fc8688bf9e711a2962ab83fbb94d6507a773239aba8985834",
|
||||
"zh:a2a4d184e923e5d2ad92ebc414cba87c82b3c38e4183a825fbac573f7f8f5076",
|
||||
"zh:be762328a2608a2bb0a0a265964af57efe403bb3b11aa0fc2863355855fc4b9f",
|
||||
"zh:c84c8e17dc739132f85c2041a2493f7caa1f08850c4ee427462c98552a114371",
|
||||
"zh:d3daa7e19371fbedc3f4ddab47feb099205c6141ebc2fa1236b36aad52173723",
|
||||
"zh:d64ad91e29a6291ababd9ca86b32e6a36f50b806ca1079e74005a7ca2d037a8b",
|
||||
"zh:dc7eb38a771762570523f01cf6ae8def5b5f8acd5e173ca06b48f4f8511b7227",
|
||||
"zh:f26e0763dbe6a6b2195c94b44696f2110f7f55433dc142839be16b9697fa5597",
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
# Galana
|
||||
|
||||
This directory contains the Terraform configuration files for my homelab server.
|
||||
|
||||
## Requirements
|
||||
|
||||
- [Terraform](https://developer.hashicorp.com/terraform/install)
|
||||
|
||||
## Environment Variables
|
||||
|
||||
Create a copy of the [`terraform.tfvars.example`](./terraform.tfvars.example) file and rename it to `terraform.tfvars`.
|
||||
|
||||
```bash
|
||||
cp terraform.tfvars.example terraform.tfvars
|
||||
```
|
||||
|
||||
Edit the `terraform.tfvars` file and update the values.
|
||||
|
||||
## Usage
|
||||
|
||||
### Plan
|
||||
|
||||
```bash
|
||||
terraform plan
|
||||
```
|
||||
|
||||
### Apply
|
||||
|
||||
```bash
|
||||
terraform apply
|
||||
```
|
||||
|
||||
### Destroy
|
||||
|
||||
```bash
|
||||
terraform destroy
|
||||
```
|
||||
@@ -0,0 +1,36 @@
|
||||
#cloud-config
|
||||
package_update: true
|
||||
package_upgrade: true
|
||||
|
||||
disable_root: true
|
||||
|
||||
users:
|
||||
- default
|
||||
- name: ${username}
|
||||
gecos: ${vm_username_gecos}
|
||||
groups: sudo
|
||||
sudo:
|
||||
- ALL=(ALL:ALL) NOPASSWD:ALL
|
||||
shell: /bin/bash
|
||||
|
||||
chpasswd:
|
||||
list: |
|
||||
${username}:${password}
|
||||
expire: false
|
||||
|
||||
ssh_pwauth: false
|
||||
|
||||
hostname: ${hostname}
|
||||
create_hostname_file: true
|
||||
fqdn: ${fqdn}
|
||||
|
||||
packages:
|
||||
- curl
|
||||
- qemu-guest-agent
|
||||
- git
|
||||
- sshpass
|
||||
|
||||
runcmd:
|
||||
- curl -fsSL https://tailscale.com/install.sh | sh
|
||||
- tailscale up --ssh --authkey=${tailscale_auth_key}
|
||||
- qemu-ga -d
|
||||
@@ -0,0 +1,117 @@
|
||||
resource "proxmox_virtual_environment_vm" "debian_vm" {
|
||||
name = "galana"
|
||||
node_name = "odin"
|
||||
vm_id = 500
|
||||
on_boot = true
|
||||
tags = ["k8s", "master", "debian", "production"]
|
||||
bios = "ovmf"
|
||||
|
||||
operating_system {
|
||||
type = "l26"
|
||||
}
|
||||
|
||||
efi_disk {
|
||||
datastore_id = "yatta"
|
||||
file_format = "raw"
|
||||
type = "4m"
|
||||
}
|
||||
|
||||
agent {
|
||||
enabled = true
|
||||
}
|
||||
|
||||
disk {
|
||||
datastore_id = "yatta"
|
||||
file_id = "local-btrfs:iso/debian-12-generic-amd64.img"
|
||||
size = 100
|
||||
interface = "scsi0"
|
||||
}
|
||||
|
||||
cpu {
|
||||
architecture = "x86_64"
|
||||
cores = 4
|
||||
sockets = 1
|
||||
type = "x86-64-v2-AES"
|
||||
}
|
||||
|
||||
memory {
|
||||
dedicated = 8192
|
||||
floating = 8192
|
||||
}
|
||||
|
||||
network_device {
|
||||
bridge = "vmbr0"
|
||||
}
|
||||
|
||||
initialization {
|
||||
datastore_id = "yatta"
|
||||
user_data_file_id = proxmox_virtual_environment_file.cloud_config.id
|
||||
|
||||
ip_config {
|
||||
ipv4 {
|
||||
address = "192.168.100.50/24"
|
||||
gateway = "192.168.100.1"
|
||||
}
|
||||
}
|
||||
|
||||
dns {
|
||||
servers = ["1.1.1.1", "8.8.8.8", "100.100.100.100"]
|
||||
}
|
||||
}
|
||||
|
||||
serial_device {
|
||||
device = "socket"
|
||||
}
|
||||
|
||||
keyboard_layout = "en-us"
|
||||
|
||||
machine = "q35"
|
||||
|
||||
scsi_hardware = "virtio-scsi-single"
|
||||
|
||||
vga {
|
||||
memory = 128
|
||||
type = "virtio-gl"
|
||||
}
|
||||
}
|
||||
|
||||
variable "vm_username" {
|
||||
type = string
|
||||
description = "VM username"
|
||||
}
|
||||
|
||||
variable "vm_password" {
|
||||
type = string
|
||||
description = "VM password for the user"
|
||||
}
|
||||
|
||||
variable "vm_username_gecos" {
|
||||
type = string
|
||||
description = "VM username gecos"
|
||||
}
|
||||
|
||||
variable "vm_hostname" {
|
||||
type = string
|
||||
description = "VM hostname"
|
||||
}
|
||||
|
||||
variable "vm_fqdn" {
|
||||
type = string
|
||||
description = "VM fqdn"
|
||||
}
|
||||
|
||||
variable "tailscale_auth_key" {
|
||||
type = string
|
||||
description = "Tailscale auth key"
|
||||
}
|
||||
|
||||
resource "proxmox_virtual_environment_file" "cloud_config" {
|
||||
content_type = "snippets"
|
||||
datastore_id = "local-btrfs"
|
||||
node_name = "odin"
|
||||
|
||||
source_raw {
|
||||
data = templatefile("cloudinit.tfpl", { username = var.vm_username, vm_username_gecos = var.vm_username_gecos, password = var.vm_password, hostname = var.vm_hostname, fqdn = var.vm_fqdn, tailscale_auth_key = var.tailscale_auth_key })
|
||||
file_name = "galana-cloud-init.yaml"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
proxmox = {
|
||||
source = "bpg/proxmox"
|
||||
version = "0.66.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
variable "proxmox_url" {
|
||||
type = string
|
||||
description = "Proxmox URL"
|
||||
}
|
||||
|
||||
variable "proxmox_username" {
|
||||
type = string
|
||||
description = "Proxmox username"
|
||||
}
|
||||
|
||||
variable "proxmox_password" {
|
||||
type = string
|
||||
description = "Proxmox password for the user"
|
||||
}
|
||||
|
||||
provider "proxmox" {
|
||||
endpoint = var.proxmox_url
|
||||
username = var.proxmox_username
|
||||
password = var.proxmox_password
|
||||
insecure = true
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
# Proxmox
|
||||
proxmox_url=""
|
||||
proxmox_username=""
|
||||
proxmox_password=""
|
||||
|
||||
# VM
|
||||
vm_username=""
|
||||
vm_username_gecos=""
|
||||
vm_password=""
|
||||
vm_hostname=""
|
||||
vm_fqdn=""
|
||||
tailscale_auth_key=""
|
||||
Generated
+25
@@ -0,0 +1,25 @@
|
||||
# This file is maintained automatically by "terraform init".
|
||||
# Manual edits may be lost in future updates.
|
||||
|
||||
provider "registry.terraform.io/bpg/proxmox" {
|
||||
version = "0.66.3"
|
||||
constraints = "0.66.3"
|
||||
hashes = [
|
||||
"h1:pvHmVDhXF7Yv45MxTiB0nY3NEkFkCh4AJ5nYU1jYoK8=",
|
||||
"zh:372c7e42af71ea4be52fd61a9b29caa8cff913c38c2e639d84797060f0e78f8a",
|
||||
"zh:45b15873f78b13051fa8eaf59bc1d480ad1feaba7074ea97fb3775787a9bdadb",
|
||||
"zh:50792893b1d7441e39433b10ad706a14468fb43326842b06e2bc95fb3c9801fb",
|
||||
"zh:591ad7b8d2d4f12d617201caf5bacddca69e68ba396e6ff60d9d1ca0ee59a6f5",
|
||||
"zh:8d63f1eaf8a1731abffed0ef1ce15423bd56faebb1819743884841f7f9ab4126",
|
||||
"zh:90400a0beb68c99e262f9a6bc93daf9dfaeefdb3af673c2a86c17853c73fa868",
|
||||
"zh:9c0ff725d5a0c2095144a6eeb8c98fb9a3dc5f36c80e526ad63b51ce4094973a",
|
||||
"zh:a099fea3db1a858fc8688bf9e711a2962ab83fbb94d6507a773239aba8985834",
|
||||
"zh:a2a4d184e923e5d2ad92ebc414cba87c82b3c38e4183a825fbac573f7f8f5076",
|
||||
"zh:be762328a2608a2bb0a0a265964af57efe403bb3b11aa0fc2863355855fc4b9f",
|
||||
"zh:c84c8e17dc739132f85c2041a2493f7caa1f08850c4ee427462c98552a114371",
|
||||
"zh:d3daa7e19371fbedc3f4ddab47feb099205c6141ebc2fa1236b36aad52173723",
|
||||
"zh:d64ad91e29a6291ababd9ca86b32e6a36f50b806ca1079e74005a7ca2d037a8b",
|
||||
"zh:dc7eb38a771762570523f01cf6ae8def5b5f8acd5e173ca06b48f4f8511b7227",
|
||||
"zh:f26e0763dbe6a6b2195c94b44696f2110f7f55433dc142839be16b9697fa5597",
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
# Turkwel
|
||||
|
||||
This directory contains the Terraform configuration files for my homelab server.
|
||||
|
||||
## Requirements
|
||||
|
||||
- [Terraform](https://developer.hashicorp.com/terraform/install)
|
||||
|
||||
## Environment Variables
|
||||
|
||||
Create a copy of the [`terraform.tfvars.example`](./terraform.tfvars.example) file and rename it to `terraform.tfvars`.
|
||||
|
||||
```bash
|
||||
cp terraform.tfvars.example terraform.tfvars
|
||||
```
|
||||
|
||||
Edit the `terraform.tfvars` file and update the values.
|
||||
|
||||
## Usage
|
||||
|
||||
### Plan
|
||||
|
||||
```bash
|
||||
terraform plan
|
||||
```
|
||||
|
||||
### Apply
|
||||
|
||||
```bash
|
||||
terraform apply
|
||||
```
|
||||
|
||||
### Destroy
|
||||
|
||||
```bash
|
||||
terraform destroy
|
||||
```
|
||||
@@ -0,0 +1,36 @@
|
||||
#cloud-config
|
||||
package_update: true
|
||||
package_upgrade: true
|
||||
|
||||
disable_root: true
|
||||
|
||||
users:
|
||||
- default
|
||||
- name: ${username}
|
||||
gecos: ${vm_username_gecos}
|
||||
groups: sudo
|
||||
sudo:
|
||||
- ALL=(ALL:ALL) NOPASSWD:ALL
|
||||
shell: /bin/bash
|
||||
|
||||
chpasswd:
|
||||
list: |
|
||||
${username}:${password}
|
||||
expire: false
|
||||
|
||||
ssh_pwauth: false
|
||||
|
||||
hostname: ${hostname}
|
||||
create_hostname_file: true
|
||||
fqdn: ${fqdn}
|
||||
|
||||
packages:
|
||||
- curl
|
||||
- qemu-guest-agent
|
||||
- git
|
||||
- sshpass
|
||||
|
||||
runcmd:
|
||||
- curl -fsSL https://tailscale.com/install.sh | sh
|
||||
- tailscale up --ssh --authkey=${tailscale_auth_key}
|
||||
- qemu-ga -d
|
||||
@@ -0,0 +1,117 @@
|
||||
resource "proxmox_virtual_environment_vm" "debian_vm" {
|
||||
name = "turkwel"
|
||||
node_name = "odin"
|
||||
vm_id = 520
|
||||
on_boot = true
|
||||
tags = ["k8s", "worker", "debian", "production"]
|
||||
bios = "ovmf"
|
||||
|
||||
operating_system {
|
||||
type = "l26"
|
||||
}
|
||||
|
||||
efi_disk {
|
||||
datastore_id = "yatta"
|
||||
file_format = "raw"
|
||||
type = "4m"
|
||||
}
|
||||
|
||||
agent {
|
||||
enabled = true
|
||||
}
|
||||
|
||||
disk {
|
||||
datastore_id = "yatta"
|
||||
file_id = "local-btrfs:iso/debian-12-generic-amd64.img"
|
||||
size = 100
|
||||
interface = "scsi0"
|
||||
}
|
||||
|
||||
cpu {
|
||||
architecture = "x86_64"
|
||||
cores = 4
|
||||
sockets = 1
|
||||
type = "x86-64-v2-AES"
|
||||
}
|
||||
|
||||
memory {
|
||||
dedicated = 8192
|
||||
floating = 8192
|
||||
}
|
||||
|
||||
network_device {
|
||||
bridge = "vmbr0"
|
||||
}
|
||||
|
||||
initialization {
|
||||
datastore_id = "yatta"
|
||||
user_data_file_id = proxmox_virtual_environment_file.cloud_config.id
|
||||
|
||||
ip_config {
|
||||
ipv4 {
|
||||
address = "192.168.100.52/24"
|
||||
gateway = "192.168.100.1"
|
||||
}
|
||||
}
|
||||
|
||||
dns {
|
||||
servers = ["1.1.1.1", "8.8.8.8", "100.100.100.100"]
|
||||
}
|
||||
}
|
||||
|
||||
serial_device {
|
||||
device = "socket"
|
||||
}
|
||||
|
||||
keyboard_layout = "en-us"
|
||||
|
||||
machine = "q35"
|
||||
|
||||
scsi_hardware = "virtio-scsi-single"
|
||||
|
||||
vga {
|
||||
memory = 128
|
||||
type = "virtio-gl"
|
||||
}
|
||||
}
|
||||
|
||||
variable "vm_username" {
|
||||
type = string
|
||||
description = "VM username"
|
||||
}
|
||||
|
||||
variable "vm_password" {
|
||||
type = string
|
||||
description = "VM password for the user"
|
||||
}
|
||||
|
||||
variable "vm_username_gecos" {
|
||||
type = string
|
||||
description = "VM username gecos"
|
||||
}
|
||||
|
||||
variable "vm_hostname" {
|
||||
type = string
|
||||
description = "VM hostname"
|
||||
}
|
||||
|
||||
variable "vm_fqdn" {
|
||||
type = string
|
||||
description = "VM fqdn"
|
||||
}
|
||||
|
||||
variable "tailscale_auth_key" {
|
||||
type = string
|
||||
description = "Tailscale auth key"
|
||||
}
|
||||
|
||||
resource "proxmox_virtual_environment_file" "cloud_config" {
|
||||
content_type = "snippets"
|
||||
datastore_id = "local-btrfs"
|
||||
node_name = "odin"
|
||||
|
||||
source_raw {
|
||||
data = templatefile("cloudinit.tfpl", { username = var.vm_username, vm_username_gecos = var.vm_username_gecos, password = var.vm_password, hostname = var.vm_hostname, fqdn = var.vm_fqdn, tailscale_auth_key = var.tailscale_auth_key })
|
||||
file_name = "turkwel-cloud-init.yaml"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
proxmox = {
|
||||
source = "bpg/proxmox"
|
||||
version = "0.66.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
variable "proxmox_url" {
|
||||
type = string
|
||||
description = "Proxmox URL"
|
||||
}
|
||||
|
||||
variable "proxmox_username" {
|
||||
type = string
|
||||
description = "Proxmox username"
|
||||
}
|
||||
|
||||
variable "proxmox_password" {
|
||||
type = string
|
||||
description = "Proxmox password for the user"
|
||||
}
|
||||
|
||||
provider "proxmox" {
|
||||
endpoint = var.proxmox_url
|
||||
username = var.proxmox_username
|
||||
password = var.proxmox_password
|
||||
insecure = true
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
# Proxmox
|
||||
proxmox_url=""
|
||||
proxmox_username=""
|
||||
proxmox_password=""
|
||||
|
||||
# VM
|
||||
vm_username=""
|
||||
vm_username_gecos=""
|
||||
vm_password=""
|
||||
vm_hostname=""
|
||||
vm_fqdn=""
|
||||
tailscale_auth_key=""
|
||||
Generated
+25
@@ -0,0 +1,25 @@
|
||||
# This file is maintained automatically by "terraform init".
|
||||
# Manual edits may be lost in future updates.
|
||||
|
||||
provider "registry.terraform.io/bpg/proxmox" {
|
||||
version = "0.66.3"
|
||||
constraints = "0.66.3"
|
||||
hashes = [
|
||||
"h1:pvHmVDhXF7Yv45MxTiB0nY3NEkFkCh4AJ5nYU1jYoK8=",
|
||||
"zh:372c7e42af71ea4be52fd61a9b29caa8cff913c38c2e639d84797060f0e78f8a",
|
||||
"zh:45b15873f78b13051fa8eaf59bc1d480ad1feaba7074ea97fb3775787a9bdadb",
|
||||
"zh:50792893b1d7441e39433b10ad706a14468fb43326842b06e2bc95fb3c9801fb",
|
||||
"zh:591ad7b8d2d4f12d617201caf5bacddca69e68ba396e6ff60d9d1ca0ee59a6f5",
|
||||
"zh:8d63f1eaf8a1731abffed0ef1ce15423bd56faebb1819743884841f7f9ab4126",
|
||||
"zh:90400a0beb68c99e262f9a6bc93daf9dfaeefdb3af673c2a86c17853c73fa868",
|
||||
"zh:9c0ff725d5a0c2095144a6eeb8c98fb9a3dc5f36c80e526ad63b51ce4094973a",
|
||||
"zh:a099fea3db1a858fc8688bf9e711a2962ab83fbb94d6507a773239aba8985834",
|
||||
"zh:a2a4d184e923e5d2ad92ebc414cba87c82b3c38e4183a825fbac573f7f8f5076",
|
||||
"zh:be762328a2608a2bb0a0a265964af57efe403bb3b11aa0fc2863355855fc4b9f",
|
||||
"zh:c84c8e17dc739132f85c2041a2493f7caa1f08850c4ee427462c98552a114371",
|
||||
"zh:d3daa7e19371fbedc3f4ddab47feb099205c6141ebc2fa1236b36aad52173723",
|
||||
"zh:d64ad91e29a6291ababd9ca86b32e6a36f50b806ca1079e74005a7ca2d037a8b",
|
||||
"zh:dc7eb38a771762570523f01cf6ae8def5b5f8acd5e173ca06b48f4f8511b7227",
|
||||
"zh:f26e0763dbe6a6b2195c94b44696f2110f7f55433dc142839be16b9697fa5597",
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
# Yala
|
||||
|
||||
This directory contains the Terraform configuration files for my homelab server.
|
||||
|
||||
## Requirements
|
||||
|
||||
- [Terraform](https://developer.hashicorp.com/terraform/install)
|
||||
|
||||
## Environment Variables
|
||||
|
||||
Create a copy of the [`terraform.tfvars.example`](./terraform.tfvars.example) file and rename it to `terraform.tfvars`.
|
||||
|
||||
```bash
|
||||
cp terraform.tfvars.example terraform.tfvars
|
||||
```
|
||||
|
||||
Edit the `terraform.tfvars` file and update the values.
|
||||
|
||||
## Usage
|
||||
|
||||
### Plan
|
||||
|
||||
```bash
|
||||
terraform plan
|
||||
```
|
||||
|
||||
### Apply
|
||||
|
||||
```bash
|
||||
terraform apply
|
||||
```
|
||||
|
||||
### Destroy
|
||||
|
||||
```bash
|
||||
terraform destroy
|
||||
```
|
||||
@@ -0,0 +1,36 @@
|
||||
#cloud-config
|
||||
package_update: true
|
||||
package_upgrade: true
|
||||
|
||||
disable_root: true
|
||||
|
||||
users:
|
||||
- default
|
||||
- name: ${username}
|
||||
gecos: ${vm_username_gecos}
|
||||
groups: sudo
|
||||
sudo:
|
||||
- ALL=(ALL:ALL) NOPASSWD:ALL
|
||||
shell: /bin/bash
|
||||
|
||||
chpasswd:
|
||||
list: |
|
||||
${username}:${password}
|
||||
expire: false
|
||||
|
||||
ssh_pwauth: false
|
||||
|
||||
hostname: ${hostname}
|
||||
create_hostname_file: true
|
||||
fqdn: ${fqdn}
|
||||
|
||||
packages:
|
||||
- curl
|
||||
- qemu-guest-agent
|
||||
- git
|
||||
- sshpass
|
||||
|
||||
runcmd:
|
||||
- curl -fsSL https://tailscale.com/install.sh | sh
|
||||
- tailscale up --ssh --authkey=${tailscale_auth_key}
|
||||
- qemu-ga -d
|
||||
@@ -0,0 +1,117 @@
|
||||
resource "proxmox_virtual_environment_vm" "debian_vm" {
|
||||
name = "yala"
|
||||
node_name = "odin"
|
||||
vm_id = 510
|
||||
on_boot = true
|
||||
tags = ["k8s", "worker", "debian", "production"]
|
||||
bios = "ovmf"
|
||||
|
||||
operating_system {
|
||||
type = "l26"
|
||||
}
|
||||
|
||||
efi_disk {
|
||||
datastore_id = "yatta"
|
||||
file_format = "raw"
|
||||
type = "4m"
|
||||
}
|
||||
|
||||
agent {
|
||||
enabled = true
|
||||
}
|
||||
|
||||
disk {
|
||||
datastore_id = "yatta"
|
||||
file_id = "local-btrfs:iso/debian-12-generic-amd64.img"
|
||||
size = 100
|
||||
interface = "scsi0"
|
||||
}
|
||||
|
||||
cpu {
|
||||
architecture = "x86_64"
|
||||
cores = 4
|
||||
sockets = 1
|
||||
type = "x86-64-v2-AES"
|
||||
}
|
||||
|
||||
memory {
|
||||
dedicated = 8192
|
||||
floating = 8192
|
||||
}
|
||||
|
||||
network_device {
|
||||
bridge = "vmbr0"
|
||||
}
|
||||
|
||||
initialization {
|
||||
datastore_id = "yatta"
|
||||
user_data_file_id = proxmox_virtual_environment_file.cloud_config.id
|
||||
|
||||
ip_config {
|
||||
ipv4 {
|
||||
address = "192.168.100.51/24"
|
||||
gateway = "192.168.100.1"
|
||||
}
|
||||
}
|
||||
|
||||
dns {
|
||||
servers = ["1.1.1.1", "8.8.8.8", "100.100.100.100"]
|
||||
}
|
||||
}
|
||||
|
||||
serial_device {
|
||||
device = "socket"
|
||||
}
|
||||
|
||||
keyboard_layout = "en-us"
|
||||
|
||||
machine = "q35"
|
||||
|
||||
scsi_hardware = "virtio-scsi-single"
|
||||
|
||||
vga {
|
||||
memory = 128
|
||||
type = "virtio-gl"
|
||||
}
|
||||
}
|
||||
|
||||
variable "vm_username" {
|
||||
type = string
|
||||
description = "VM username"
|
||||
}
|
||||
|
||||
variable "vm_password" {
|
||||
type = string
|
||||
description = "VM password for the user"
|
||||
}
|
||||
|
||||
variable "vm_username_gecos" {
|
||||
type = string
|
||||
description = "VM username gecos"
|
||||
}
|
||||
|
||||
variable "vm_hostname" {
|
||||
type = string
|
||||
description = "VM hostname"
|
||||
}
|
||||
|
||||
variable "vm_fqdn" {
|
||||
type = string
|
||||
description = "VM fqdn"
|
||||
}
|
||||
|
||||
variable "tailscale_auth_key" {
|
||||
type = string
|
||||
description = "Tailscale auth key"
|
||||
}
|
||||
|
||||
resource "proxmox_virtual_environment_file" "cloud_config" {
|
||||
content_type = "snippets"
|
||||
datastore_id = "local-btrfs"
|
||||
node_name = "odin"
|
||||
|
||||
source_raw {
|
||||
data = templatefile("cloudinit.tfpl", { username = var.vm_username, vm_username_gecos = var.vm_username_gecos, password = var.vm_password, hostname = var.vm_hostname, fqdn = var.vm_fqdn, tailscale_auth_key = var.tailscale_auth_key })
|
||||
file_name = "yala-cloud-init.yaml"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
proxmox = {
|
||||
source = "bpg/proxmox"
|
||||
version = "0.66.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
variable "proxmox_url" {
|
||||
type = string
|
||||
description = "Proxmox URL"
|
||||
}
|
||||
|
||||
variable "proxmox_username" {
|
||||
type = string
|
||||
description = "Proxmox username"
|
||||
}
|
||||
|
||||
variable "proxmox_password" {
|
||||
type = string
|
||||
description = "Proxmox password for the user"
|
||||
}
|
||||
|
||||
provider "proxmox" {
|
||||
endpoint = var.proxmox_url
|
||||
username = var.proxmox_username
|
||||
password = var.proxmox_password
|
||||
insecure = true
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
# Proxmox
|
||||
proxmox_url=""
|
||||
proxmox_username=""
|
||||
proxmox_password=""
|
||||
|
||||
# VM
|
||||
vm_username=""
|
||||
vm_username_gecos=""
|
||||
vm_password=""
|
||||
vm_hostname=""
|
||||
vm_fqdn=""
|
||||
tailscale_auth_key=""
|
||||
Reference in New Issue
Block a user