changes to nodepool and beging to set up flux.

This commit is contained in:
sirius0xdev 2026-01-05 01:18:37 +00:00
parent 824bd2d112
commit 3f1f343921
3 changed files with 11 additions and 73 deletions

View file

@ -1,5 +1,5 @@
resource "google_container_cluster" "default" { resource "google_container_cluster" "primary" {
name = "devops-lab-cluster" name = "devops-lab-cluster"
location = "us-central1-a" location = "us-central1-a"
initial_node_count = 1 initial_node_count = 1
@ -7,11 +7,16 @@ resource "google_container_cluster" "default" {
datapath_provider = "ADVANCED_DATAPATH" datapath_provider = "ADVANCED_DATAPATH"
enable_cilium_clusterwide_network_policy = true enable_cilium_clusterwide_network_policy = true
remove_default_node_pool = true
network = google_compute_network.default.id network = google_compute_network.default.id
subnetwork = google_compute_subnetwork.default.id subnetwork = google_compute_subnetwork.default.id
node_config { node_config {
machine_type = "e2-standard-2"
disk_size_gb = 25
disk_type = "pd-ssd"
oauth_scopes = [
"https://www.googleapis.com/auth/cloud-platform"
]
taint { taint {
key = "node.cilium.io/agent-not-ready" key = "node.cilium.io/agent-not-ready"
value = "true" value = "true"

View file

@ -2,12 +2,13 @@
resource "google_container_node_pool" "cluster" { resource "google_container_node_pool" "cluster" {
name = "devops-lab-nodepool" name = "devops-lab-nodepool"
location = "us-central1-a" location = "us-central1-a"
cluster = google_container_cluster.default.name cluster = google_container_cluster.primary.name
network_config { network_config {
pod_range = "pod-ranges-ext" pod_range = "pod-ranges-ext"
} }
initial_node_count = 2 initial_node_count = 2
autoscaling { autoscaling {
min_node_count = 1 min_node_count = 1
max_node_count = 16 max_node_count = 16
@ -15,12 +16,12 @@ resource "google_container_node_pool" "cluster" {
node_config { node_config {
machine_type = "e2-standard-2" machine_type = "e2-standard-2"
disk_size_gb = 50 disk_size_gb = 25
disk_type = "pd-ssd" disk_type = "pd-ssd"
oauth_scopes = [ oauth_scopes = [
"https://www.googleapis.com/auth/cloud-platform" "https://www.googleapis.com/auth/cloud-platform"
] ]
} }
depends_on = [google_container_cluster.default] depends_on = [google_container_cluster.primary]
} }

View file

@ -1,68 +0,0 @@
resource "google_project_service" "sqladmin_api" {
service = "sqladmin.googleapis.com"
disable_on_destroy = false
}
# Create a Cloud SQL instance for PostgreSQL
resource "google_sql_database_instance" "postgres_instance" {
name = "pg-instance-via-tf"
database_version = "POSTGRES_15" # Specify the desired PostgreSQL version
region = "us-central1"
settings {
# The tier for the Cloud SQL instance, determines CPU and memory
tier = "db-f1-micro"
# Set disk size and enable disk auto-resize
disk_size = 10
disk_autoresize = true
# Network configuration for private IP
# If you need public IP, adjust authorized_networks
ip_configuration {
authorized_networks {
value = "0.0.0.0/0"
}
}
}
# Prevents accidental deletion of the instance
deletion_protection = false
depends_on = [google_project_service.sqladmin_api]
}
# Generate a random password for the default user
resource "random_password" "db_password" {
length = 16
special = true
override_special = "!#$%*()_-+="
keepers = {
rotatation_version = "2"
}
}
# Create a database user
resource "google_sql_user" "db_user" {
name = "sirius"
instance = google_sql_database_instance.postgres_instance.name
password = random_password.db_password.result
}
# Create the initial database
resource "google_sql_database" "database" {
name = "n8ndb"
instance = google_sql_database_instance.postgres_instance.name
}
# Output the connection name and generated password
output "instance_connection_name" {
value = google_sql_database_instance.postgres_instance.connection_name
description = "The connection name of the instance, used for the Cloud SQL Proxy"
}
output "database_user_password" {
value = random_password.db_password.result
sensitive = true
}