Add Google Cloud K3s infrastructure support
- Add Terraform configuration for GCP instance and storage - Add startup script for K3s installation and configuration - Add pipeline scripts for deployment and management - Add Forgejo deployment manifests and configuration
This commit is contained in:
parent
7384722305
commit
2ab7872af1
30 changed files with 1024 additions and 324 deletions
95
gcloud/tf/main.tf
Normal file
95
gcloud/tf/main.tf
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
|
||||
|
||||
// Compute
|
||||
// ----------------------------------
|
||||
|
||||
// The instance for K3S
|
||||
resource "google_compute_instance" "k3s" {
|
||||
name = "k3s-vm-1"
|
||||
machine_type = "e2-small" # This instance will have 2 Gb of RAM
|
||||
zone = var.zone
|
||||
|
||||
tags = ["web"]
|
||||
|
||||
// Set the boot disk and the image (10 Gb)
|
||||
boot_disk {
|
||||
initialize_params {
|
||||
image = "debian-cloud/debian-12"
|
||||
size = 10
|
||||
}
|
||||
}
|
||||
|
||||
// ensures that the instance is a Spot VM
|
||||
// means it can be preempted, but it's cheaper
|
||||
# scheduling {
|
||||
# automatic_restart = false
|
||||
# provisioning_model = "SPOT"
|
||||
# preemptible = true
|
||||
# }
|
||||
|
||||
// attach a disk for K3S
|
||||
attached_disk {
|
||||
source = google_compute_disk.k3s_disk.id
|
||||
device_name = "k3s-disk"
|
||||
}
|
||||
|
||||
// attach a disk for app data
|
||||
attached_disk {
|
||||
source = google_compute_disk.app_data_disk.id
|
||||
device_name = "app-data-disk"
|
||||
}
|
||||
|
||||
network_interface {
|
||||
network = "default"
|
||||
|
||||
// enable ephemeral ip
|
||||
access_config {}
|
||||
}
|
||||
|
||||
labels = {
|
||||
env = var.env
|
||||
region = var.region
|
||||
app = var.app_name
|
||||
sensitive = "false"
|
||||
}
|
||||
|
||||
metadata_startup_script = file("scripts/k3s-vm-startup.sh")
|
||||
allow_stopping_for_update = true
|
||||
}
|
||||
|
||||
|
||||
// Storage
|
||||
// ----------------------------------
|
||||
|
||||
// The disk attached to the instance (15 Gb)
|
||||
resource "google_compute_disk" "k3s_disk" {
|
||||
name = "k3s-disk"
|
||||
size = 15
|
||||
type = "pd-standard"
|
||||
zone = var.zone
|
||||
}
|
||||
|
||||
// The disk for app data (20 Gb)
|
||||
resource "google_compute_disk" "app_data_disk" {
|
||||
name = "app-data-disk"
|
||||
size = 20
|
||||
type = "pd-standard"
|
||||
zone = var.zone
|
||||
}
|
||||
|
||||
// Outputs
|
||||
// ----------------------------------
|
||||
|
||||
data "google_project" "project" {
|
||||
project_id = var.project_name # Use variable from tfvars
|
||||
}
|
||||
|
||||
output "project_number" {
|
||||
value = data.google_project.project.number
|
||||
}
|
||||
|
||||
output "k3s_vm_public_ip" {
|
||||
value = google_compute_instance.k3s.network_interface[0].access_config[0].nat_ip
|
||||
description = "Ephemeral public IP of the k3s VM"
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue