Compare commits
65 Commits
28979b6e60
...
feature/ch
| Author | SHA1 | Date | |
|---|---|---|---|
| 4641e6b319 | |||
| 97e0e48271 | |||
| df663c8193 | |||
| 612b5ffb28 | |||
| c49d03d7f7 | |||
| d47dba2ae5 | |||
| cf9eb47ecf | |||
| 3eca723f05 | |||
| f36996da11 | |||
| 6bf7db21d0 | |||
| 2641d55784 | |||
| 117297effc | |||
| fda90f9e01 | |||
| 1124377d97 | |||
| c0710b89bb | |||
| d7bda18aea | |||
| 2796e1b9d3 | |||
| d7a0c26117 | |||
| 693f2f9168 | |||
| 2509ef062c | |||
| 957757e557 | |||
| 070799da05 | |||
| 1a2817e537 | |||
| b47b0035f5 | |||
| d3fac4d43e | |||
| c37bd3ef04 | |||
| ad661ba3dd | |||
| a9625f96e6 | |||
| cb64edc927 | |||
| ac1c242fb9 | |||
| 4b29c07fd6 | |||
| 52732626e5 | |||
| 8634436dd4 | |||
| a8baa169e9 | |||
| 73ef3a6e12 | |||
| 302705d374 | |||
| f3286ef77e | |||
| 74f4f86770 | |||
| f2c56156bf | |||
| 21fb50ba00 | |||
| b90b630b06 | |||
| 66de9b8a0a | |||
| 716c552be9 | |||
| f048b47a0f | |||
| 66f40427ee | |||
| 332881cbd0 | |||
| f363afa087 | |||
| bc42347cb6 | |||
| 80d7bff4bc | |||
| 3644a3ec87 | |||
| bd478478f1 | |||
| 67b1d95509 | |||
| fff95d98a5 | |||
| 8b743efa43 | |||
| 4ca9039686 | |||
| 6a9eadbde8 | |||
| f19f7c9237 | |||
| 5a459d486e | |||
| 31fb476a78 | |||
| a088425b70 | |||
| b3b3edf82c | |||
| 308755a4b3 | |||
| db6afaf180 | |||
| 5a2f9a1b88 | |||
| 1c6f18b67c |
8
.gitignore
vendored
8
.gitignore
vendored
@@ -16,11 +16,3 @@ devbox.d/
|
|||||||
devbox.lock
|
devbox.lock
|
||||||
.devbox/
|
.devbox/
|
||||||
bash.exe.stackdump
|
bash.exe.stackdump
|
||||||
|
|
||||||
# OpenTofu
|
|
||||||
.tofu/configs/*.env
|
|
||||||
.tofu/scripts/*.config
|
|
||||||
.tofu/platforms/**/.terraform/
|
|
||||||
.tofu/platforms/**/terraform.tfstate*
|
|
||||||
.tofu/platforms/**/tfplan
|
|
||||||
.tofu/platforms/**/.terraform.lock.hcl
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
# Azure AKS credentials — copy to aks.env and fill in values
|
|
||||||
# NEVER commit aks.env to git!
|
|
||||||
|
|
||||||
# Required
|
|
||||||
AZURE_TENANT_ID=your-azure-tenant-id
|
|
||||||
AZURE_SUBSCRIPTION_ID=your-azure-subscription-id
|
|
||||||
|
|
||||||
# Optional — defaults to cluster name if not set
|
|
||||||
ARM_RESOURCE_GROUP=
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
# AWS EKS credentials — copy to eks.env and fill in values
|
|
||||||
# NEVER commit eks.env to git!
|
|
||||||
|
|
||||||
# Required — AWS CLI profile or access key
|
|
||||||
AWS_PROFILE=default
|
|
||||||
AWS_REGION=eu-west-1
|
|
||||||
|
|
||||||
# Optional — override with explicit keys instead of profile
|
|
||||||
# AWS_ACCESS_KEY_ID=
|
|
||||||
# AWS_SECRET_ACCESS_KEY=
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
# GCP GKE credentials — copy to gke.env and fill in values
|
|
||||||
# NEVER commit gke.env to git!
|
|
||||||
|
|
||||||
# Required
|
|
||||||
GCP_PROJECT_ID=your-gcp-project-id
|
|
||||||
GCP_REGION=europe-west4
|
|
||||||
|
|
||||||
# Optional — path to service account JSON key (if not using gcloud auth)
|
|
||||||
# GOOGLE_APPLICATION_CREDENTIALS=/path/to/sa-key.json
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
# UpCloud credentials — copy to upc.env and fill in values
|
|
||||||
# NEVER commit upc.env to git!
|
|
||||||
|
|
||||||
# Required
|
|
||||||
UPCLOUD_TOKEN=your-upcloud-api-token
|
|
||||||
|
|
||||||
# Optional — set after cluster creation for kubeconfig retrieval
|
|
||||||
UPCLOUD_CLUSTER_ID=
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
module "cluster" {
|
|
||||||
source = "../modules/cluster"
|
|
||||||
|
|
||||||
prefix = "clst-dev"
|
|
||||||
location = "norwayeast"
|
|
||||||
resource_group_name = "clst-dev-rg"
|
|
||||||
|
|
||||||
# AKS — small dev nodes
|
|
||||||
aks_node_vm_size = "Standard_B2s"
|
|
||||||
aks_node_count = 2
|
|
||||||
|
|
||||||
enable_delete_lock = false
|
|
||||||
|
|
||||||
tags = {
|
|
||||||
Environment = "dev"
|
|
||||||
ManagedBy = "tofu"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
# ─── Cluster ─────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
output "cluster_name" {
|
|
||||||
value = module.cluster.cluster_name
|
|
||||||
}
|
|
||||||
|
|
||||||
output "resource_group_name" {
|
|
||||||
value = module.cluster.resource_group_name
|
|
||||||
}
|
|
||||||
|
|
||||||
output "kubernetes_version" {
|
|
||||||
value = module.cluster.kubernetes_version
|
|
||||||
}
|
|
||||||
|
|
||||||
output "location" {
|
|
||||||
value = module.cluster.location
|
|
||||||
}
|
|
||||||
|
|
||||||
output "oidc_issuer_url" {
|
|
||||||
value = module.cluster.oidc_issuer_url
|
|
||||||
}
|
|
||||||
|
|
||||||
output "kubeconfig" {
|
|
||||||
value = module.cluster.kubeconfig
|
|
||||||
sensitive = true
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
terraform {
|
|
||||||
required_version = ">= 1.0"
|
|
||||||
|
|
||||||
required_providers {
|
|
||||||
azurerm = {
|
|
||||||
source = "hashicorp/azurerm"
|
|
||||||
version = "~> 4.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
provider "azurerm" {
|
|
||||||
features {}
|
|
||||||
# Credentials via environment variables:
|
|
||||||
# ARM_SUBSCRIPTION_ID, ARM_TENANT_ID, ARM_CLIENT_ID, ARM_CLIENT_SECRET
|
|
||||||
# Or: az login (uses your Azure CLI session)
|
|
||||||
}
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
# Current Azure/Entra ID context — provides tenant_id used in outputs
|
|
||||||
data "azurerm_client_config" "current" {}
|
|
||||||
|
|
||||||
# ─── Resource Group ───────────────────────────────────────────────────
|
|
||||||
|
|
||||||
resource "azurerm_resource_group" "main" {
|
|
||||||
name = var.resource_group_name
|
|
||||||
location = var.location
|
|
||||||
tags = var.tags
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "azurerm_management_lock" "main" {
|
|
||||||
count = var.enable_delete_lock ? 1 : 0
|
|
||||||
name = "${var.prefix}-delete-lock"
|
|
||||||
scope = azurerm_resource_group.main.id
|
|
||||||
lock_level = "CanNotDelete"
|
|
||||||
notes = "Prevents accidental deletion of production resources"
|
|
||||||
}
|
|
||||||
|
|
||||||
# ─── Networking ───────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
resource "azurerm_virtual_network" "main" {
|
|
||||||
name = "${var.prefix}-vnet"
|
|
||||||
resource_group_name = azurerm_resource_group.main.name
|
|
||||||
location = azurerm_resource_group.main.location
|
|
||||||
address_space = [var.vnet_address_space]
|
|
||||||
tags = var.tags
|
|
||||||
}
|
|
||||||
|
|
||||||
# AKS nodes subnet
|
|
||||||
resource "azurerm_subnet" "aks" {
|
|
||||||
name = "${var.prefix}-aks-subnet"
|
|
||||||
resource_group_name = azurerm_resource_group.main.name
|
|
||||||
virtual_network_name = azurerm_virtual_network.main.name
|
|
||||||
address_prefixes = [var.aks_subnet_cidr]
|
|
||||||
}
|
|
||||||
|
|
||||||
# ─── AKS Cluster ──────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
resource "azurerm_kubernetes_cluster" "main" {
|
|
||||||
name = "${var.prefix}-aks"
|
|
||||||
resource_group_name = azurerm_resource_group.main.name
|
|
||||||
location = azurerm_resource_group.main.location
|
|
||||||
dns_prefix = replace(var.prefix, "-", "")
|
|
||||||
kubernetes_version = var.aks_kubernetes_version
|
|
||||||
tags = var.tags
|
|
||||||
|
|
||||||
default_node_pool {
|
|
||||||
name = "system"
|
|
||||||
node_count = var.aks_node_count
|
|
||||||
vm_size = var.aks_node_vm_size
|
|
||||||
vnet_subnet_id = azurerm_subnet.aks.id
|
|
||||||
node_labels = {
|
|
||||||
prefix = var.prefix
|
|
||||||
role = "worker"
|
|
||||||
env = lookup(var.tags, "Environment", "dev")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
identity {
|
|
||||||
type = "SystemAssigned"
|
|
||||||
}
|
|
||||||
|
|
||||||
network_profile {
|
|
||||||
network_plugin = "azure"
|
|
||||||
network_policy = "azure"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Enable Workload Identity for keyless Azure service access (MSI)
|
|
||||||
oidc_issuer_enabled = true
|
|
||||||
workload_identity_enabled = true
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
# ─── Cluster ─────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
output "cluster_name" {
|
|
||||||
description = "AKS cluster name"
|
|
||||||
value = azurerm_kubernetes_cluster.main.name
|
|
||||||
}
|
|
||||||
|
|
||||||
output "resource_group_name" {
|
|
||||||
description = "Resource group name"
|
|
||||||
value = azurerm_resource_group.main.name
|
|
||||||
}
|
|
||||||
|
|
||||||
output "kubernetes_version" {
|
|
||||||
description = "Kubernetes version"
|
|
||||||
value = azurerm_kubernetes_cluster.main.kubernetes_version
|
|
||||||
}
|
|
||||||
|
|
||||||
output "location" {
|
|
||||||
description = "Azure region"
|
|
||||||
value = azurerm_resource_group.main.location
|
|
||||||
}
|
|
||||||
|
|
||||||
output "oidc_issuer_url" {
|
|
||||||
description = "AKS OIDC issuer URL (for workload identity federation)"
|
|
||||||
value = azurerm_kubernetes_cluster.main.oidc_issuer_url
|
|
||||||
}
|
|
||||||
|
|
||||||
output "kubeconfig" {
|
|
||||||
description = "Kubeconfig for the AKS cluster"
|
|
||||||
value = azurerm_kubernetes_cluster.main.kube_config_raw
|
|
||||||
sensitive = true
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
terraform {
|
|
||||||
required_version = ">= 1.0"
|
|
||||||
|
|
||||||
required_providers {
|
|
||||||
azurerm = {
|
|
||||||
source = "hashicorp/azurerm"
|
|
||||||
version = "~> 4.0"
|
|
||||||
}
|
|
||||||
azuread = {
|
|
||||||
source = "hashicorp/azuread"
|
|
||||||
version = "~> 3.0"
|
|
||||||
}
|
|
||||||
random = {
|
|
||||||
source = "hashicorp/random"
|
|
||||||
version = "~> 3.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
# ─── Cluster ─────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
variable "prefix" {
|
|
||||||
description = "Prefix for resource names"
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "location" {
|
|
||||||
description = "Azure region (e.g., norwayeast, westeurope, northeurope)"
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "resource_group_name" {
|
|
||||||
description = "Name of the Azure Resource Group to create"
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "vnet_address_space" {
|
|
||||||
description = "Address space for the virtual network"
|
|
||||||
type = string
|
|
||||||
default = "10.100.0.0/16"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "aks_subnet_cidr" {
|
|
||||||
description = "CIDR block for the AKS node subnet"
|
|
||||||
type = string
|
|
||||||
default = "10.100.0.0/22"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "aks_node_vm_size" {
|
|
||||||
description = "VM size for AKS worker nodes (e.g., Standard_B2s, Standard_D4s_v3)"
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "aks_node_count" {
|
|
||||||
description = "Number of AKS worker nodes"
|
|
||||||
type = number
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "aks_kubernetes_version" {
|
|
||||||
description = "Kubernetes version for AKS (null = latest stable)"
|
|
||||||
type = string
|
|
||||||
default = null
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "enable_delete_lock" {
|
|
||||||
description = "Protect the resource group from accidental deletion"
|
|
||||||
type = bool
|
|
||||||
default = false
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "tags" {
|
|
||||||
description = "Tags applied to all resources"
|
|
||||||
type = map(string)
|
|
||||||
default = {}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
module "cluster" {
|
|
||||||
source = "../modules/cluster"
|
|
||||||
|
|
||||||
prefix = "clst"
|
|
||||||
location = "westeurope"
|
|
||||||
resource_group_name = "clst-prod-rg"
|
|
||||||
|
|
||||||
# AKS — general-purpose nodes for production
|
|
||||||
aks_node_vm_size = "Standard_D4s_v3"
|
|
||||||
aks_node_count = 3
|
|
||||||
|
|
||||||
enable_delete_lock = true
|
|
||||||
|
|
||||||
tags = {
|
|
||||||
Environment = "prod"
|
|
||||||
ManagedBy = "tofu"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
# ─── Cluster ─────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
output "cluster_name" {
|
|
||||||
value = module.cluster.cluster_name
|
|
||||||
}
|
|
||||||
|
|
||||||
output "resource_group_name" {
|
|
||||||
value = module.cluster.resource_group_name
|
|
||||||
}
|
|
||||||
|
|
||||||
output "kubernetes_version" {
|
|
||||||
value = module.cluster.kubernetes_version
|
|
||||||
}
|
|
||||||
|
|
||||||
output "location" {
|
|
||||||
value = module.cluster.location
|
|
||||||
}
|
|
||||||
|
|
||||||
output "oidc_issuer_url" {
|
|
||||||
value = module.cluster.oidc_issuer_url
|
|
||||||
}
|
|
||||||
|
|
||||||
output "kubeconfig" {
|
|
||||||
value = module.cluster.kubeconfig
|
|
||||||
sensitive = true
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
terraform {
|
|
||||||
required_version = ">= 1.0"
|
|
||||||
|
|
||||||
required_providers {
|
|
||||||
azurerm = {
|
|
||||||
source = "hashicorp/azurerm"
|
|
||||||
version = "~> 4.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
provider "azurerm" {
|
|
||||||
features {}
|
|
||||||
# Credentials via environment variables:
|
|
||||||
# ARM_SUBSCRIPTION_ID, ARM_TENANT_ID, ARM_CLIENT_ID, ARM_CLIENT_SECRET
|
|
||||||
# Or: az login (uses your Azure CLI session)
|
|
||||||
}
|
|
||||||
@@ -1,173 +0,0 @@
|
|||||||
# =============================================================================
|
|
||||||
# Azure Workload Cluster
|
|
||||||
# =============================================================================
|
|
||||||
# A lean AKS cluster for running application workloads. No managed data
|
|
||||||
# services — those live on the platform cluster. ArgoCD (on the platform
|
|
||||||
# cluster) deploys apps to this cluster via the app-of-apps pattern.
|
|
||||||
#
|
|
||||||
# Platform components deployed by deploy-workload.sh:
|
|
||||||
# nginx-ingress, cert-manager, external-dns, external-secrets, alloy
|
|
||||||
#
|
|
||||||
# Usage:
|
|
||||||
# tofu init && tofu plan && tofu apply
|
|
||||||
# ./sync-tofu-outputs.sh --env azure-workload
|
|
||||||
# ./deploy-workload.sh --env azure-workload
|
|
||||||
# =============================================================================
|
|
||||||
|
|
||||||
variable "prefix" {
|
|
||||||
description = "Prefix for resource names (e.g., clst-workload)"
|
|
||||||
type = string
|
|
||||||
default = "clst-workload"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "location" {
|
|
||||||
description = "Azure region"
|
|
||||||
type = string
|
|
||||||
default = "norwayeast"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "resource_group_name" {
|
|
||||||
description = "Name of the Azure Resource Group to create"
|
|
||||||
type = string
|
|
||||||
default = "clst-workload-rg"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "vnet_address_space" {
|
|
||||||
description = "Address space for the virtual network"
|
|
||||||
type = string
|
|
||||||
default = "10.110.0.0/16"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "aks_subnet_cidr" {
|
|
||||||
description = "CIDR block for the AKS node subnet"
|
|
||||||
type = string
|
|
||||||
default = "10.110.0.0/22"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "aks_node_vm_size" {
|
|
||||||
description = "VM size for AKS worker nodes"
|
|
||||||
type = string
|
|
||||||
default = "Standard_B2s"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "aks_node_count" {
|
|
||||||
description = "Number of AKS worker nodes"
|
|
||||||
type = number
|
|
||||||
default = 2
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "aks_kubernetes_version" {
|
|
||||||
description = "Kubernetes version for AKS (null = latest stable)"
|
|
||||||
type = string
|
|
||||||
default = null
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "domain" {
|
|
||||||
description = "Public domain name — must have an existing Azure DNS zone"
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "dns_zone_resource_group" {
|
|
||||||
description = "Resource group containing the Azure DNS zone (defaults to cluster RG)"
|
|
||||||
type = string
|
|
||||||
default = ""
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "tags" {
|
|
||||||
description = "Tags applied to all resources"
|
|
||||||
type = map(string)
|
|
||||||
default = {
|
|
||||||
Environment = "workload"
|
|
||||||
ManagedBy = "tofu"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# ─── Resource Group ───────────────────────────────────────────────────
|
|
||||||
|
|
||||||
resource "azurerm_resource_group" "main" {
|
|
||||||
name = var.resource_group_name
|
|
||||||
location = var.location
|
|
||||||
tags = var.tags
|
|
||||||
}
|
|
||||||
|
|
||||||
# ─── Networking ───────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
resource "azurerm_virtual_network" "main" {
|
|
||||||
name = "${var.prefix}-vnet"
|
|
||||||
resource_group_name = azurerm_resource_group.main.name
|
|
||||||
location = azurerm_resource_group.main.location
|
|
||||||
address_space = [var.vnet_address_space]
|
|
||||||
tags = var.tags
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "azurerm_subnet" "aks" {
|
|
||||||
name = "${var.prefix}-aks-subnet"
|
|
||||||
resource_group_name = azurerm_resource_group.main.name
|
|
||||||
virtual_network_name = azurerm_virtual_network.main.name
|
|
||||||
address_prefixes = [var.aks_subnet_cidr]
|
|
||||||
}
|
|
||||||
|
|
||||||
# ─── AKS Cluster ──────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
resource "azurerm_kubernetes_cluster" "main" {
|
|
||||||
name = "${var.prefix}-aks"
|
|
||||||
resource_group_name = azurerm_resource_group.main.name
|
|
||||||
location = azurerm_resource_group.main.location
|
|
||||||
dns_prefix = replace(var.prefix, "-", "")
|
|
||||||
kubernetes_version = var.aks_kubernetes_version
|
|
||||||
tags = var.tags
|
|
||||||
|
|
||||||
default_node_pool {
|
|
||||||
name = "system"
|
|
||||||
node_count = var.aks_node_count
|
|
||||||
vm_size = var.aks_node_vm_size
|
|
||||||
vnet_subnet_id = azurerm_subnet.aks.id
|
|
||||||
node_labels = {
|
|
||||||
prefix = var.prefix
|
|
||||||
role = "worker"
|
|
||||||
env = lookup(var.tags, "Environment", "workload")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
identity {
|
|
||||||
type = "SystemAssigned"
|
|
||||||
}
|
|
||||||
|
|
||||||
network_profile {
|
|
||||||
network_plugin = "azure"
|
|
||||||
network_policy = "azure"
|
|
||||||
}
|
|
||||||
|
|
||||||
oidc_issuer_enabled = true
|
|
||||||
workload_identity_enabled = true
|
|
||||||
}
|
|
||||||
|
|
||||||
# ─── External-DNS Workload Identity ──────────────────────────────────
|
|
||||||
# Allows external-dns to manage Azure DNS records for app ingresses.
|
|
||||||
|
|
||||||
data "azurerm_dns_zone" "main" {
|
|
||||||
name = var.domain
|
|
||||||
resource_group_name = var.dns_zone_resource_group != "" ? var.dns_zone_resource_group : azurerm_resource_group.main.name
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "azurerm_user_assigned_identity" "external_dns" {
|
|
||||||
name = "${var.prefix}-external-dns-identity"
|
|
||||||
resource_group_name = azurerm_resource_group.main.name
|
|
||||||
location = azurerm_resource_group.main.location
|
|
||||||
tags = var.tags
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "azurerm_role_assignment" "external_dns_dns_contributor" {
|
|
||||||
scope = data.azurerm_dns_zone.main.id
|
|
||||||
role_definition_name = "DNS Zone Contributor"
|
|
||||||
principal_id = azurerm_user_assigned_identity.external_dns.principal_id
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "azurerm_federated_identity_credential" "external_dns" {
|
|
||||||
name = "${var.prefix}-external-dns-fedcred"
|
|
||||||
resource_group_name = azurerm_resource_group.main.name
|
|
||||||
parent_id = azurerm_user_assigned_identity.external_dns.id
|
|
||||||
audience = ["api://AzureADTokenExchange"]
|
|
||||||
issuer = azurerm_kubernetes_cluster.main.oidc_issuer_url
|
|
||||||
subject = "system:serviceaccount:external-dns:external-dns"
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
output "cluster_name" { value = azurerm_kubernetes_cluster.main.name }
|
|
||||||
output "resource_group_name" { value = azurerm_resource_group.main.name }
|
|
||||||
output "location" { value = azurerm_resource_group.main.location }
|
|
||||||
output "external_dns_identity_client_id" { value = azurerm_user_assigned_identity.external_dns.client_id }
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
terraform {
|
|
||||||
required_version = ">= 1.0"
|
|
||||||
|
|
||||||
required_providers {
|
|
||||||
azurerm = {
|
|
||||||
source = "hashicorp/azurerm"
|
|
||||||
version = "~> 4.0"
|
|
||||||
}
|
|
||||||
random = {
|
|
||||||
source = "hashicorp/random"
|
|
||||||
version = "~> 3.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
provider "azurerm" {
|
|
||||||
features {}
|
|
||||||
# Credentials via environment variables:
|
|
||||||
# ARM_SUBSCRIPTION_ID, ARM_TENANT_ID, ARM_CLIENT_ID, ARM_CLIENT_SECRET
|
|
||||||
# Or: az login (uses your Azure CLI session)
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
module "cluster" {
|
|
||||||
source = "../modules/cluster"
|
|
||||||
|
|
||||||
region = var.region
|
|
||||||
prefix = "clst-dev"
|
|
||||||
|
|
||||||
# VPC
|
|
||||||
availability_zones = ["${var.region}a", "${var.region}b"]
|
|
||||||
|
|
||||||
# EKS — small dev nodes
|
|
||||||
node_instance_type = "t3.medium"
|
|
||||||
node_count = 2
|
|
||||||
node_min_count = 1
|
|
||||||
node_max_count = 4
|
|
||||||
kubernetes_version = "1.30"
|
|
||||||
|
|
||||||
tags = {
|
|
||||||
Environment = "dev"
|
|
||||||
ManagedBy = "tofu"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
output "cluster_name" { value = module.cluster.cluster_name }
|
|
||||||
output "aws_region" { value = module.cluster.aws_region }
|
|
||||||
output "oidc_issuer_url" { value = module.cluster.oidc_issuer_url }
|
|
||||||
output "oidc_provider_arn" { value = module.cluster.oidc_provider_arn }
|
|
||||||
output "vpc_id" { value = module.cluster.vpc_id }
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
terraform {
|
|
||||||
required_providers {
|
|
||||||
aws = {
|
|
||||||
source = "hashicorp/aws"
|
|
||||||
version = "~> 5.0"
|
|
||||||
}
|
|
||||||
tls = {
|
|
||||||
source = "hashicorp/tls"
|
|
||||||
version = "~> 4.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Authentication: set AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN
|
|
||||||
# or configure an AWS profile: export AWS_PROFILE=clst
|
|
||||||
provider "aws" {
|
|
||||||
region = var.region
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "region" {
|
|
||||||
description = "AWS region for dev environment"
|
|
||||||
type = string
|
|
||||||
default = "eu-west-1"
|
|
||||||
}
|
|
||||||
@@ -1,207 +0,0 @@
|
|||||||
# ─── VPC ──────────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
resource "aws_vpc" "main" {
|
|
||||||
cidr_block = var.vpc_cidr
|
|
||||||
enable_dns_hostnames = true
|
|
||||||
enable_dns_support = true
|
|
||||||
|
|
||||||
tags = merge(var.tags, { Name = "${var.prefix}-vpc" })
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_internet_gateway" "main" {
|
|
||||||
vpc_id = aws_vpc.main.id
|
|
||||||
tags = merge(var.tags, { Name = "${var.prefix}-igw" })
|
|
||||||
}
|
|
||||||
|
|
||||||
# Public subnets (one per AZ) — for NAT gateways and load balancers
|
|
||||||
resource "aws_subnet" "public" {
|
|
||||||
count = length(var.availability_zones)
|
|
||||||
vpc_id = aws_vpc.main.id
|
|
||||||
cidr_block = cidrsubnet(var.vpc_cidr, 4, count.index)
|
|
||||||
availability_zone = var.availability_zones[count.index]
|
|
||||||
|
|
||||||
map_public_ip_on_launch = true
|
|
||||||
|
|
||||||
tags = merge(var.tags, {
|
|
||||||
Name = "${var.prefix}-public-${count.index + 1}"
|
|
||||||
"kubernetes.io/cluster/${var.prefix}-eks" = "shared"
|
|
||||||
"kubernetes.io/role/elb" = "1"
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
# Private subnets (one per AZ) — for EKS nodes
|
|
||||||
resource "aws_subnet" "private" {
|
|
||||||
count = length(var.availability_zones)
|
|
||||||
vpc_id = aws_vpc.main.id
|
|
||||||
cidr_block = cidrsubnet(var.vpc_cidr, 4, count.index + length(var.availability_zones))
|
|
||||||
availability_zone = var.availability_zones[count.index]
|
|
||||||
|
|
||||||
tags = merge(var.tags, {
|
|
||||||
Name = "${var.prefix}-private-${count.index + 1}"
|
|
||||||
"kubernetes.io/cluster/${var.prefix}-eks" = "shared"
|
|
||||||
"kubernetes.io/role/internal-elb" = "1"
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
# NAT Gateway (single, in first public subnet — use one per AZ for prod HA)
|
|
||||||
resource "aws_eip" "nat" {
|
|
||||||
domain = "vpc"
|
|
||||||
tags = merge(var.tags, { Name = "${var.prefix}-nat-eip" })
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_nat_gateway" "main" {
|
|
||||||
allocation_id = aws_eip.nat.id
|
|
||||||
subnet_id = aws_subnet.public[0].id
|
|
||||||
tags = merge(var.tags, { Name = "${var.prefix}-nat" })
|
|
||||||
|
|
||||||
depends_on = [aws_internet_gateway.main]
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_route_table" "public" {
|
|
||||||
vpc_id = aws_vpc.main.id
|
|
||||||
|
|
||||||
route {
|
|
||||||
cidr_block = "0.0.0.0/0"
|
|
||||||
gateway_id = aws_internet_gateway.main.id
|
|
||||||
}
|
|
||||||
|
|
||||||
tags = merge(var.tags, { Name = "${var.prefix}-public-rt" })
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_route_table_association" "public" {
|
|
||||||
count = length(var.availability_zones)
|
|
||||||
subnet_id = aws_subnet.public[count.index].id
|
|
||||||
route_table_id = aws_route_table.public.id
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_route_table" "private" {
|
|
||||||
vpc_id = aws_vpc.main.id
|
|
||||||
|
|
||||||
route {
|
|
||||||
cidr_block = "0.0.0.0/0"
|
|
||||||
nat_gateway_id = aws_nat_gateway.main.id
|
|
||||||
}
|
|
||||||
|
|
||||||
tags = merge(var.tags, { Name = "${var.prefix}-private-rt" })
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_route_table_association" "private" {
|
|
||||||
count = length(var.availability_zones)
|
|
||||||
subnet_id = aws_subnet.private[count.index].id
|
|
||||||
route_table_id = aws_route_table.private.id
|
|
||||||
}
|
|
||||||
|
|
||||||
# ─── EKS Cluster ──────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
resource "aws_iam_role" "eks_cluster" {
|
|
||||||
name_prefix = "${var.prefix}-eks-cluster-"
|
|
||||||
|
|
||||||
assume_role_policy = jsonencode({
|
|
||||||
Version = "2012-10-17"
|
|
||||||
Statement = [{
|
|
||||||
Action = "sts:AssumeRole"
|
|
||||||
Effect = "Allow"
|
|
||||||
Principal = { Service = "eks.amazonaws.com" }
|
|
||||||
}]
|
|
||||||
})
|
|
||||||
|
|
||||||
tags = var.tags
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_iam_role_policy_attachment" "eks_cluster_policy" {
|
|
||||||
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSClusterPolicy"
|
|
||||||
role = aws_iam_role.eks_cluster.name
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_eks_cluster" "main" {
|
|
||||||
name = "${var.prefix}-eks"
|
|
||||||
role_arn = aws_iam_role.eks_cluster.arn
|
|
||||||
version = var.kubernetes_version
|
|
||||||
|
|
||||||
vpc_config {
|
|
||||||
subnet_ids = concat(aws_subnet.private[*].id, aws_subnet.public[*].id)
|
|
||||||
endpoint_private_access = true
|
|
||||||
endpoint_public_access = true
|
|
||||||
}
|
|
||||||
|
|
||||||
# Enable OIDC issuer for IRSA (IAM Roles for Service Accounts)
|
|
||||||
access_config {
|
|
||||||
authentication_mode = "API_AND_CONFIG_MAP"
|
|
||||||
}
|
|
||||||
|
|
||||||
tags = var.tags
|
|
||||||
|
|
||||||
depends_on = [aws_iam_role_policy_attachment.eks_cluster_policy]
|
|
||||||
}
|
|
||||||
|
|
||||||
# OIDC provider — required for IRSA (IAM Roles for Service Accounts)
|
|
||||||
data "tls_certificate" "eks" {
|
|
||||||
url = aws_eks_cluster.main.identity[0].oidc[0].issuer
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_iam_openid_connect_provider" "eks" {
|
|
||||||
client_id_list = ["sts.amazonaws.com"]
|
|
||||||
thumbprint_list = [data.tls_certificate.eks.certificates[0].sha1_fingerprint]
|
|
||||||
url = aws_eks_cluster.main.identity[0].oidc[0].issuer
|
|
||||||
|
|
||||||
tags = var.tags
|
|
||||||
}
|
|
||||||
|
|
||||||
# EKS Node Group
|
|
||||||
|
|
||||||
resource "aws_iam_role" "eks_nodes" {
|
|
||||||
name_prefix = "${var.prefix}-eks-nodes-"
|
|
||||||
|
|
||||||
assume_role_policy = jsonencode({
|
|
||||||
Version = "2012-10-17"
|
|
||||||
Statement = [{
|
|
||||||
Action = "sts:AssumeRole"
|
|
||||||
Effect = "Allow"
|
|
||||||
Principal = { Service = "ec2.amazonaws.com" }
|
|
||||||
}]
|
|
||||||
})
|
|
||||||
|
|
||||||
tags = var.tags
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_iam_role_policy_attachment" "eks_worker_node_policy" {
|
|
||||||
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy"
|
|
||||||
role = aws_iam_role.eks_nodes.name
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_iam_role_policy_attachment" "eks_cni_policy" {
|
|
||||||
policy_arn = "arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy"
|
|
||||||
role = aws_iam_role.eks_nodes.name
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_iam_role_policy_attachment" "eks_ecr_readonly" {
|
|
||||||
policy_arn = "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly"
|
|
||||||
role = aws_iam_role.eks_nodes.name
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_eks_node_group" "main" {
|
|
||||||
cluster_name = aws_eks_cluster.main.name
|
|
||||||
node_group_name = "${var.prefix}-nodes"
|
|
||||||
node_role_arn = aws_iam_role.eks_nodes.arn
|
|
||||||
subnet_ids = aws_subnet.private[*].id
|
|
||||||
|
|
||||||
instance_types = [var.node_instance_type]
|
|
||||||
|
|
||||||
scaling_config {
|
|
||||||
desired_size = var.node_count
|
|
||||||
max_size = var.node_max_count
|
|
||||||
min_size = var.node_min_count
|
|
||||||
}
|
|
||||||
|
|
||||||
update_config {
|
|
||||||
max_unavailable = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
tags = var.tags
|
|
||||||
|
|
||||||
depends_on = [
|
|
||||||
aws_iam_role_policy_attachment.eks_worker_node_policy,
|
|
||||||
aws_iam_role_policy_attachment.eks_cni_policy,
|
|
||||||
aws_iam_role_policy_attachment.eks_ecr_readonly,
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
# ─── Cluster ─────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
output "cluster_name" {
|
|
||||||
description = "EKS cluster name"
|
|
||||||
value = aws_eks_cluster.main.name
|
|
||||||
}
|
|
||||||
|
|
||||||
output "aws_region" {
|
|
||||||
description = "AWS region"
|
|
||||||
value = var.region
|
|
||||||
}
|
|
||||||
|
|
||||||
output "oidc_issuer_url" {
|
|
||||||
description = "EKS OIDC issuer URL (for IRSA)"
|
|
||||||
value = aws_eks_cluster.main.identity[0].oidc[0].issuer
|
|
||||||
}
|
|
||||||
|
|
||||||
output "oidc_provider_arn" {
|
|
||||||
description = "IAM OIDC provider ARN (for IRSA trust policies)"
|
|
||||||
value = aws_iam_openid_connect_provider.eks.arn
|
|
||||||
}
|
|
||||||
|
|
||||||
output "vpc_id" {
|
|
||||||
description = "VPC ID"
|
|
||||||
value = aws_vpc.main.id
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
terraform {
|
|
||||||
required_providers {
|
|
||||||
aws = {
|
|
||||||
source = "hashicorp/aws"
|
|
||||||
version = "~> 5.0"
|
|
||||||
}
|
|
||||||
tls = {
|
|
||||||
source = "hashicorp/tls"
|
|
||||||
version = "~> 4.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
# ─── Region ──────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
variable "region" {
|
|
||||||
description = "AWS region (e.g., eu-west-1, us-east-1)"
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "prefix" {
|
|
||||||
description = "Prefix for resource names (e.g., clst-dev)"
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
# ─── Networking ───────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
variable "vpc_cidr" {
|
|
||||||
description = "VPC CIDR block"
|
|
||||||
type = string
|
|
||||||
default = "10.100.0.0/16"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "availability_zones" {
|
|
||||||
description = "List of AZs for subnets (2–3 recommended)"
|
|
||||||
type = list(string)
|
|
||||||
}
|
|
||||||
|
|
||||||
# ─── EKS Cluster ─────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
variable "node_instance_type" {
|
|
||||||
description = "EKS node instance type (e.g., t3.medium, m5.xlarge)"
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "node_count" {
|
|
||||||
description = "Desired number of EKS worker nodes"
|
|
||||||
type = number
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "node_min_count" {
|
|
||||||
description = "Minimum number of EKS worker nodes"
|
|
||||||
type = number
|
|
||||||
default = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "node_max_count" {
|
|
||||||
description = "Maximum number of EKS worker nodes"
|
|
||||||
type = number
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "kubernetes_version" {
|
|
||||||
description = "Kubernetes version for EKS (e.g., \"1.30\")"
|
|
||||||
type = string
|
|
||||||
default = "1.30"
|
|
||||||
}
|
|
||||||
|
|
||||||
# ─── Tags ─────────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
variable "tags" {
|
|
||||||
description = "Tags applied to all resources"
|
|
||||||
type = map(string)
|
|
||||||
default = {}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
module "cluster" {
|
|
||||||
source = "../modules/cluster"
|
|
||||||
|
|
||||||
region = var.region
|
|
||||||
prefix = "clst"
|
|
||||||
|
|
||||||
# VPC
|
|
||||||
availability_zones = ["${var.region}a", "${var.region}b", "${var.region}c"]
|
|
||||||
|
|
||||||
# EKS — general-purpose nodes for production
|
|
||||||
node_instance_type = "m5.xlarge"
|
|
||||||
node_count = 3
|
|
||||||
node_min_count = 3
|
|
||||||
node_max_count = 6
|
|
||||||
kubernetes_version = "1.30"
|
|
||||||
|
|
||||||
tags = {
|
|
||||||
Environment = "prod"
|
|
||||||
ManagedBy = "tofu"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
output "cluster_name" { value = module.cluster.cluster_name }
|
|
||||||
output "aws_region" { value = module.cluster.aws_region }
|
|
||||||
output "oidc_issuer_url" { value = module.cluster.oidc_issuer_url }
|
|
||||||
output "oidc_provider_arn" { value = module.cluster.oidc_provider_arn }
|
|
||||||
output "vpc_id" { value = module.cluster.vpc_id }
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
terraform {
|
|
||||||
required_providers {
|
|
||||||
aws = {
|
|
||||||
source = "hashicorp/aws"
|
|
||||||
version = "~> 5.0"
|
|
||||||
}
|
|
||||||
tls = {
|
|
||||||
source = "hashicorp/tls"
|
|
||||||
version = "~> 4.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
provider "aws" {
|
|
||||||
region = var.region
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "region" {
|
|
||||||
description = "AWS region for prod environment"
|
|
||||||
type = string
|
|
||||||
default = "eu-west-1"
|
|
||||||
}
|
|
||||||
@@ -1,339 +0,0 @@
|
|||||||
# =============================================================================
|
|
||||||
# AWS Workload Cluster
|
|
||||||
# =============================================================================
|
|
||||||
# A lean EKS cluster for running application workloads. No managed data
|
|
||||||
# services — those live on the platform cluster. ArgoCD (on the platform
|
|
||||||
# cluster) deploys apps to this cluster via the app-of-apps pattern.
|
|
||||||
#
|
|
||||||
# Platform components deployed by deploy-workload.sh:
|
|
||||||
# nginx-ingress, cert-manager, external-dns, external-secrets, alloy
|
|
||||||
#
|
|
||||||
# Usage:
|
|
||||||
# tofu init && tofu plan && tofu apply
|
|
||||||
# ./sync-tofu-outputs.sh --env aws-workload
|
|
||||||
# ./deploy-workload.sh --env aws-workload
|
|
||||||
# =============================================================================
|
|
||||||
|
|
||||||
variable "prefix" {
|
|
||||||
description = "Prefix for resource names (e.g., clst-workload)"
|
|
||||||
type = string
|
|
||||||
default = "clst-workload"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "availability_zones" {
|
|
||||||
description = "List of AZs for subnets"
|
|
||||||
type = list(string)
|
|
||||||
default = ["eu-west-1a", "eu-west-1b"]
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "vpc_cidr" {
|
|
||||||
description = "VPC CIDR block"
|
|
||||||
type = string
|
|
||||||
default = "10.110.0.0/16"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "node_instance_type" {
|
|
||||||
description = "EKS node instance type"
|
|
||||||
type = string
|
|
||||||
default = "t3.medium"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "node_count" {
|
|
||||||
description = "Desired number of EKS worker nodes"
|
|
||||||
type = number
|
|
||||||
default = 2
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "node_min_count" {
|
|
||||||
description = "Minimum number of EKS worker nodes"
|
|
||||||
type = number
|
|
||||||
default = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "node_max_count" {
|
|
||||||
description = "Maximum number of EKS worker nodes"
|
|
||||||
type = number
|
|
||||||
default = 4
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "kubernetes_version" {
|
|
||||||
description = "Kubernetes version for EKS"
|
|
||||||
type = string
|
|
||||||
default = "1.30"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "domain" {
|
|
||||||
description = "Public domain name — must have an existing Route53 hosted zone"
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "tags" {
|
|
||||||
description = "Tags applied to all resources"
|
|
||||||
type = map(string)
|
|
||||||
default = {
|
|
||||||
Environment = "workload"
|
|
||||||
ManagedBy = "tofu"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# ─── VPC ──────────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
resource "aws_vpc" "main" {
|
|
||||||
cidr_block = var.vpc_cidr
|
|
||||||
enable_dns_hostnames = true
|
|
||||||
enable_dns_support = true
|
|
||||||
|
|
||||||
tags = merge(var.tags, { Name = "${var.prefix}-vpc" })
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_internet_gateway" "main" {
|
|
||||||
vpc_id = aws_vpc.main.id
|
|
||||||
tags = merge(var.tags, { Name = "${var.prefix}-igw" })
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_subnet" "public" {
|
|
||||||
count = length(var.availability_zones)
|
|
||||||
vpc_id = aws_vpc.main.id
|
|
||||||
cidr_block = cidrsubnet(var.vpc_cidr, 4, count.index)
|
|
||||||
availability_zone = var.availability_zones[count.index]
|
|
||||||
|
|
||||||
map_public_ip_on_launch = true
|
|
||||||
|
|
||||||
tags = merge(var.tags, {
|
|
||||||
Name = "${var.prefix}-public-${count.index + 1}"
|
|
||||||
"kubernetes.io/cluster/${var.prefix}-eks" = "shared"
|
|
||||||
"kubernetes.io/role/elb" = "1"
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_subnet" "private" {
|
|
||||||
count = length(var.availability_zones)
|
|
||||||
vpc_id = aws_vpc.main.id
|
|
||||||
cidr_block = cidrsubnet(var.vpc_cidr, 4, count.index + length(var.availability_zones))
|
|
||||||
availability_zone = var.availability_zones[count.index]
|
|
||||||
|
|
||||||
tags = merge(var.tags, {
|
|
||||||
Name = "${var.prefix}-private-${count.index + 1}"
|
|
||||||
"kubernetes.io/cluster/${var.prefix}-eks" = "shared"
|
|
||||||
"kubernetes.io/role/internal-elb" = "1"
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_eip" "nat" {
|
|
||||||
domain = "vpc"
|
|
||||||
tags = merge(var.tags, { Name = "${var.prefix}-nat-eip" })
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_nat_gateway" "main" {
|
|
||||||
allocation_id = aws_eip.nat.id
|
|
||||||
subnet_id = aws_subnet.public[0].id
|
|
||||||
tags = merge(var.tags, { Name = "${var.prefix}-nat" })
|
|
||||||
|
|
||||||
depends_on = [aws_internet_gateway.main]
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_route_table" "public" {
|
|
||||||
vpc_id = aws_vpc.main.id
|
|
||||||
|
|
||||||
route {
|
|
||||||
cidr_block = "0.0.0.0/0"
|
|
||||||
gateway_id = aws_internet_gateway.main.id
|
|
||||||
}
|
|
||||||
|
|
||||||
tags = merge(var.tags, { Name = "${var.prefix}-public-rt" })
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_route_table_association" "public" {
|
|
||||||
count = length(var.availability_zones)
|
|
||||||
subnet_id = aws_subnet.public[count.index].id
|
|
||||||
route_table_id = aws_route_table.public.id
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_route_table" "private" {
|
|
||||||
vpc_id = aws_vpc.main.id
|
|
||||||
|
|
||||||
route {
|
|
||||||
cidr_block = "0.0.0.0/0"
|
|
||||||
nat_gateway_id = aws_nat_gateway.main.id
|
|
||||||
}
|
|
||||||
|
|
||||||
tags = merge(var.tags, { Name = "${var.prefix}-private-rt" })
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_route_table_association" "private" {
|
|
||||||
count = length(var.availability_zones)
|
|
||||||
subnet_id = aws_subnet.private[count.index].id
|
|
||||||
route_table_id = aws_route_table.private.id
|
|
||||||
}
|
|
||||||
|
|
||||||
# ─── EKS Cluster ──────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
resource "aws_iam_role" "eks_cluster" {
|
|
||||||
name_prefix = "${var.prefix}-eks-cluster-"
|
|
||||||
|
|
||||||
assume_role_policy = jsonencode({
|
|
||||||
Version = "2012-10-17"
|
|
||||||
Statement = [{
|
|
||||||
Action = "sts:AssumeRole"
|
|
||||||
Effect = "Allow"
|
|
||||||
Principal = { Service = "eks.amazonaws.com" }
|
|
||||||
}]
|
|
||||||
})
|
|
||||||
|
|
||||||
tags = var.tags
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_iam_role_policy_attachment" "eks_cluster_policy" {
|
|
||||||
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSClusterPolicy"
|
|
||||||
role = aws_iam_role.eks_cluster.name
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_eks_cluster" "main" {
|
|
||||||
name = "${var.prefix}-eks"
|
|
||||||
role_arn = aws_iam_role.eks_cluster.arn
|
|
||||||
version = var.kubernetes_version
|
|
||||||
|
|
||||||
vpc_config {
|
|
||||||
subnet_ids = concat(aws_subnet.private[*].id, aws_subnet.public[*].id)
|
|
||||||
endpoint_private_access = true
|
|
||||||
endpoint_public_access = true
|
|
||||||
}
|
|
||||||
|
|
||||||
access_config {
|
|
||||||
authentication_mode = "API_AND_CONFIG_MAP"
|
|
||||||
}
|
|
||||||
|
|
||||||
tags = var.tags
|
|
||||||
|
|
||||||
depends_on = [aws_iam_role_policy_attachment.eks_cluster_policy]
|
|
||||||
}
|
|
||||||
|
|
||||||
# OIDC provider — required for IRSA
|
|
||||||
data "tls_certificate" "eks" {
|
|
||||||
url = aws_eks_cluster.main.identity[0].oidc[0].issuer
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_iam_openid_connect_provider" "eks" {
|
|
||||||
client_id_list = ["sts.amazonaws.com"]
|
|
||||||
thumbprint_list = [data.tls_certificate.eks.certificates[0].sha1_fingerprint]
|
|
||||||
url = aws_eks_cluster.main.identity[0].oidc[0].issuer
|
|
||||||
|
|
||||||
tags = var.tags
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_iam_role" "eks_nodes" {
|
|
||||||
name_prefix = "${var.prefix}-eks-nodes-"
|
|
||||||
|
|
||||||
assume_role_policy = jsonencode({
|
|
||||||
Version = "2012-10-17"
|
|
||||||
Statement = [{
|
|
||||||
Action = "sts:AssumeRole"
|
|
||||||
Effect = "Allow"
|
|
||||||
Principal = { Service = "ec2.amazonaws.com" }
|
|
||||||
}]
|
|
||||||
})
|
|
||||||
|
|
||||||
tags = var.tags
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_iam_role_policy_attachment" "eks_worker_node_policy" {
|
|
||||||
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy"
|
|
||||||
role = aws_iam_role.eks_nodes.name
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_iam_role_policy_attachment" "eks_cni_policy" {
|
|
||||||
policy_arn = "arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy"
|
|
||||||
role = aws_iam_role.eks_nodes.name
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_iam_role_policy_attachment" "eks_ecr_readonly" {
|
|
||||||
policy_arn = "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly"
|
|
||||||
role = aws_iam_role.eks_nodes.name
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_eks_node_group" "main" {
|
|
||||||
cluster_name = aws_eks_cluster.main.name
|
|
||||||
node_group_name = "${var.prefix}-nodes"
|
|
||||||
node_role_arn = aws_iam_role.eks_nodes.arn
|
|
||||||
subnet_ids = aws_subnet.private[*].id
|
|
||||||
|
|
||||||
instance_types = [var.node_instance_type]
|
|
||||||
|
|
||||||
scaling_config {
|
|
||||||
desired_size = var.node_count
|
|
||||||
max_size = var.node_max_count
|
|
||||||
min_size = var.node_min_count
|
|
||||||
}
|
|
||||||
|
|
||||||
update_config {
|
|
||||||
max_unavailable = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
tags = var.tags
|
|
||||||
|
|
||||||
depends_on = [
|
|
||||||
aws_iam_role_policy_attachment.eks_worker_node_policy,
|
|
||||||
aws_iam_role_policy_attachment.eks_cni_policy,
|
|
||||||
aws_iam_role_policy_attachment.eks_ecr_readonly,
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
# ─── External-DNS IRSA ───────────────────────────────────────────────
|
|
||||||
# Allows external-dns to manage Route53 records for app ingresses.
|
|
||||||
|
|
||||||
data "aws_route53_zone" "main" {
|
|
||||||
name = var.domain
|
|
||||||
private_zone = false
|
|
||||||
}
|
|
||||||
|
|
||||||
data "aws_iam_policy_document" "external_dns_assume_role" {
|
|
||||||
statement {
|
|
||||||
effect = "Allow"
|
|
||||||
|
|
||||||
principals {
|
|
||||||
type = "Federated"
|
|
||||||
identifiers = [aws_iam_openid_connect_provider.eks.arn]
|
|
||||||
}
|
|
||||||
|
|
||||||
actions = ["sts:AssumeRoleWithWebIdentity"]
|
|
||||||
|
|
||||||
condition {
|
|
||||||
test = "StringEquals"
|
|
||||||
variable = "${replace(aws_iam_openid_connect_provider.eks.url, "https://", "")}:sub"
|
|
||||||
values = ["system:serviceaccount:external-dns:external-dns"]
|
|
||||||
}
|
|
||||||
|
|
||||||
condition {
|
|
||||||
test = "StringEquals"
|
|
||||||
variable = "${replace(aws_iam_openid_connect_provider.eks.url, "https://", "")}:aud"
|
|
||||||
values = ["sts.amazonaws.com"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_iam_role" "external_dns_irsa" {
|
|
||||||
name_prefix = "${var.prefix}-external-dns-irsa-"
|
|
||||||
assume_role_policy = data.aws_iam_policy_document.external_dns_assume_role.json
|
|
||||||
|
|
||||||
tags = var.tags
|
|
||||||
}
|
|
||||||
|
|
||||||
data "aws_iam_policy_document" "external_dns_route53" {
|
|
||||||
statement {
|
|
||||||
effect = "Allow"
|
|
||||||
actions = ["route53:ChangeResourceRecordSets"]
|
|
||||||
resources = ["arn:aws:route53:::hostedzone/${data.aws_route53_zone.main.zone_id}"]
|
|
||||||
}
|
|
||||||
|
|
||||||
statement {
|
|
||||||
effect = "Allow"
|
|
||||||
actions = ["route53:ListHostedZones", "route53:ListResourceRecordSets", "route53:ListTagsForResource"]
|
|
||||||
resources = ["*"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_iam_role_policy" "external_dns_route53" {
|
|
||||||
name_prefix = "${var.prefix}-external-dns-route53-"
|
|
||||||
role = aws_iam_role.external_dns_irsa.id
|
|
||||||
policy = data.aws_iam_policy_document.external_dns_route53.json
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
output "cluster_name" { value = aws_eks_cluster.main.name }
|
|
||||||
output "aws_region" { value = var.region }
|
|
||||||
output "external_dns_irsa_role_arn" { value = aws_iam_role.external_dns_irsa.arn }
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
terraform {
|
|
||||||
required_providers {
|
|
||||||
aws = {
|
|
||||||
source = "hashicorp/aws"
|
|
||||||
version = "~> 5.0"
|
|
||||||
}
|
|
||||||
tls = {
|
|
||||||
source = "hashicorp/tls"
|
|
||||||
version = "~> 4.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Authentication: set AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN
|
|
||||||
# or configure an AWS profile: export AWS_PROFILE=clst
|
|
||||||
provider "aws" {
|
|
||||||
region = var.region
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "region" {
|
|
||||||
description = "AWS region for the workload environment"
|
|
||||||
type = string
|
|
||||||
default = "eu-west-1"
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
module "cluster" {
|
|
||||||
source = "../modules/cluster"
|
|
||||||
|
|
||||||
project_id = var.project_id
|
|
||||||
region = var.region
|
|
||||||
prefix = "clst-dev"
|
|
||||||
|
|
||||||
# GKE — small dev nodes
|
|
||||||
node_machine_type = "e2-standard-2"
|
|
||||||
node_count = 2
|
|
||||||
deletion_protection = false
|
|
||||||
|
|
||||||
labels = {
|
|
||||||
environment = "dev"
|
|
||||||
managed-by = "tofu"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
output "cluster_name" { value = module.cluster.cluster_name }
|
|
||||||
output "project_id" { value = module.cluster.project_id }
|
|
||||||
output "region" { value = module.cluster.region }
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
terraform {
|
|
||||||
required_providers {
|
|
||||||
google = {
|
|
||||||
source = "hashicorp/google"
|
|
||||||
version = "~> 6.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Authentication: use Application Default Credentials (gcloud auth application-default login)
|
|
||||||
# or set GOOGLE_APPLICATION_CREDENTIALS to a service account key file.
|
|
||||||
provider "google" {
|
|
||||||
project = var.project_id
|
|
||||||
region = var.region
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "project_id" {
|
|
||||||
description = "GCP project ID for the dev environment"
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "region" {
|
|
||||||
description = "GCP region"
|
|
||||||
type = string
|
|
||||||
default = "europe-west4"
|
|
||||||
}
|
|
||||||
@@ -1,115 +0,0 @@
|
|||||||
# ─── Required APIs ────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
resource "google_project_service" "compute" {
|
|
||||||
project = var.project_id
|
|
||||||
service = "compute.googleapis.com"
|
|
||||||
disable_on_destroy = false
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "google_project_service" "container" {
|
|
||||||
project = var.project_id
|
|
||||||
service = "container.googleapis.com"
|
|
||||||
disable_on_destroy = false
|
|
||||||
}
|
|
||||||
|
|
||||||
# ─── Networking ───────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
resource "google_compute_network" "main" {
|
|
||||||
project = var.project_id
|
|
||||||
name = "${var.prefix}-vpc"
|
|
||||||
auto_create_subnetworks = false
|
|
||||||
|
|
||||||
depends_on = [google_project_service.compute]
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "google_compute_subnetwork" "main" {
|
|
||||||
project = var.project_id
|
|
||||||
name = "${var.prefix}-subnet"
|
|
||||||
ip_cidr_range = "10.100.0.0/22"
|
|
||||||
region = var.region
|
|
||||||
network = google_compute_network.main.id
|
|
||||||
|
|
||||||
# Secondary ranges required for GKE VPC-native cluster
|
|
||||||
secondary_ip_range {
|
|
||||||
range_name = "pods"
|
|
||||||
ip_cidr_range = "10.200.0.0/14" # /14 = ~262k pod IPs
|
|
||||||
}
|
|
||||||
|
|
||||||
secondary_ip_range {
|
|
||||||
range_name = "services"
|
|
||||||
ip_cidr_range = "10.204.0.0/20" # /20 = ~4k service IPs
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# ─── GKE Cluster ──────────────────────────────────────────────────────
|
|
||||||
#
|
|
||||||
# Regional cluster (3 control-plane replicas) for HA.
|
|
||||||
# Workload Identity enabled — allows K8s service accounts to impersonate
|
|
||||||
# Google Service Accounts for keyless access to GCP services.
|
|
||||||
|
|
||||||
resource "google_container_cluster" "main" {
|
|
||||||
project = var.project_id
|
|
||||||
name = "${var.prefix}-gke"
|
|
||||||
location = var.region # regional cluster
|
|
||||||
|
|
||||||
network = google_compute_network.main.id
|
|
||||||
subnetwork = google_compute_subnetwork.main.id
|
|
||||||
|
|
||||||
# VPC-native cluster with alias IP ranges
|
|
||||||
ip_allocation_policy {
|
|
||||||
cluster_secondary_range_name = "pods"
|
|
||||||
services_secondary_range_name = "services"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Workload Identity pool — enables OIDC token projection for pods
|
|
||||||
workload_identity_config {
|
|
||||||
workload_pool = "${var.project_id}.svc.id.goog"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Remove default node pool — we manage our own below
|
|
||||||
remove_default_node_pool = true
|
|
||||||
initial_node_count = 1
|
|
||||||
|
|
||||||
deletion_protection = var.deletion_protection
|
|
||||||
|
|
||||||
dynamic "release_channel" {
|
|
||||||
for_each = var.kubernetes_version == null ? [1] : []
|
|
||||||
content {
|
|
||||||
channel = "STABLE"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
resource_labels = var.labels
|
|
||||||
|
|
||||||
depends_on = [google_project_service.container]
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "google_container_node_pool" "main" {
|
|
||||||
project = var.project_id
|
|
||||||
name = "${var.prefix}-nodes"
|
|
||||||
location = var.region
|
|
||||||
cluster = google_container_cluster.main.name
|
|
||||||
node_count = var.node_count
|
|
||||||
|
|
||||||
node_config {
|
|
||||||
machine_type = var.node_machine_type
|
|
||||||
|
|
||||||
# GKE_METADATA mode is required for Workload Identity
|
|
||||||
workload_metadata_config {
|
|
||||||
mode = "GKE_METADATA"
|
|
||||||
}
|
|
||||||
|
|
||||||
oauth_scopes = [
|
|
||||||
"https://www.googleapis.com/auth/cloud-platform",
|
|
||||||
]
|
|
||||||
|
|
||||||
labels = merge(var.labels, {
|
|
||||||
role = "worker"
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
management {
|
|
||||||
auto_repair = true
|
|
||||||
auto_upgrade = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
# ─── Cluster ─────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
output "cluster_name" {
|
|
||||||
description = "GKE cluster name"
|
|
||||||
value = google_container_cluster.main.name
|
|
||||||
}
|
|
||||||
|
|
||||||
output "project_id" {
|
|
||||||
description = "GCP project ID"
|
|
||||||
value = var.project_id
|
|
||||||
}
|
|
||||||
|
|
||||||
output "region" {
|
|
||||||
description = "GCP region"
|
|
||||||
value = var.region
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
terraform {
|
|
||||||
required_providers {
|
|
||||||
google = {
|
|
||||||
source = "hashicorp/google"
|
|
||||||
version = "~> 6.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
# ─── Project / Region ────────────────────────────────────────────────
|
|
||||||
|
|
||||||
variable "project_id" {
|
|
||||||
description = "GCP project ID"
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "region" {
|
|
||||||
description = "GCP region (e.g., europe-west4, europe-west1)"
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "prefix" {
|
|
||||||
description = "Prefix for resource names (e.g., clst-dev)"
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
# ─── GKE Cluster ─────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
variable "node_machine_type" {
|
|
||||||
description = "GKE node machine type (e.g., e2-standard-2, e2-standard-4)"
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "node_count" {
|
|
||||||
description = "Number of nodes per zone (regional cluster spawns nodes in each zone)"
|
|
||||||
type = number
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "kubernetes_version" {
|
|
||||||
description = "GKE Kubernetes version channel (null = STABLE release channel)"
|
|
||||||
type = string
|
|
||||||
default = null
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "deletion_protection" {
|
|
||||||
description = "Prevent cluster deletion (set true for production)"
|
|
||||||
type = bool
|
|
||||||
default = false
|
|
||||||
}
|
|
||||||
|
|
||||||
# ─── Labels ──────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
variable "labels" {
|
|
||||||
description = "Labels applied to all resources"
|
|
||||||
type = map(string)
|
|
||||||
default = {}
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
module "cluster" {
|
|
||||||
source = "../modules/cluster"
|
|
||||||
|
|
||||||
project_id = var.project_id
|
|
||||||
region = var.region
|
|
||||||
prefix = "clst"
|
|
||||||
|
|
||||||
# GKE — general-purpose nodes for production
|
|
||||||
node_machine_type = "e2-standard-4"
|
|
||||||
node_count = 3
|
|
||||||
deletion_protection = true
|
|
||||||
|
|
||||||
labels = {
|
|
||||||
environment = "prod"
|
|
||||||
managed-by = "tofu"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
output "cluster_name" { value = module.cluster.cluster_name }
|
|
||||||
output "project_id" { value = module.cluster.project_id }
|
|
||||||
output "region" { value = module.cluster.region }
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
terraform {
|
|
||||||
required_providers {
|
|
||||||
google = {
|
|
||||||
source = "hashicorp/google"
|
|
||||||
version = "~> 6.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
provider "google" {
|
|
||||||
project = var.project_id
|
|
||||||
region = var.region
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "project_id" {
|
|
||||||
description = "GCP project ID for the prod environment"
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "region" {
|
|
||||||
description = "GCP region"
|
|
||||||
type = string
|
|
||||||
default = "europe-west1"
|
|
||||||
}
|
|
||||||
@@ -1,194 +0,0 @@
|
|||||||
# =============================================================================
|
|
||||||
# GCP Workload Cluster
|
|
||||||
# =============================================================================
|
|
||||||
# A lean GKE cluster for running application workloads. No managed data
|
|
||||||
# services — those live on the platform cluster. ArgoCD (on the platform
|
|
||||||
# cluster) deploys apps to this cluster via the app-of-apps pattern.
|
|
||||||
#
|
|
||||||
# Platform components deployed by deploy-workload.sh:
|
|
||||||
# nginx-ingress, cert-manager, external-dns, external-secrets, alloy
|
|
||||||
#
|
|
||||||
# Usage:
|
|
||||||
# tofu init && tofu plan && tofu apply
|
|
||||||
# ./sync-tofu-outputs.sh --env gcp-workload
|
|
||||||
# ./deploy-workload.sh --env gcp-workload
|
|
||||||
# =============================================================================
|
|
||||||
|
|
||||||
variable "prefix" {
|
|
||||||
description = "Prefix for resource names (e.g., clst-workload)"
|
|
||||||
type = string
|
|
||||||
default = "clst-workload"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "node_machine_type" {
|
|
||||||
description = "GKE node machine type"
|
|
||||||
type = string
|
|
||||||
default = "e2-standard-2"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "node_count" {
|
|
||||||
description = "Number of nodes per zone"
|
|
||||||
type = number
|
|
||||||
default = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "kubernetes_version" {
|
|
||||||
description = "GKE Kubernetes version (null = STABLE release channel)"
|
|
||||||
type = string
|
|
||||||
default = null
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "deletion_protection" {
|
|
||||||
description = "Prevent cluster deletion"
|
|
||||||
type = bool
|
|
||||||
default = false
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "labels" {
|
|
||||||
description = "Labels applied to all resources"
|
|
||||||
type = map(string)
|
|
||||||
default = {
|
|
||||||
environment = "workload"
|
|
||||||
managed-by = "tofu"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# ─── Required APIs ────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
resource "google_project_service" "compute" {
|
|
||||||
project = var.project_id
|
|
||||||
service = "compute.googleapis.com"
|
|
||||||
disable_on_destroy = false
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "google_project_service" "container" {
|
|
||||||
project = var.project_id
|
|
||||||
service = "container.googleapis.com"
|
|
||||||
disable_on_destroy = false
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "google_project_service" "iam" {
|
|
||||||
project = var.project_id
|
|
||||||
service = "iam.googleapis.com"
|
|
||||||
disable_on_destroy = false
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "google_project_service" "dns" {
|
|
||||||
project = var.project_id
|
|
||||||
service = "dns.googleapis.com"
|
|
||||||
disable_on_destroy = false
|
|
||||||
}
|
|
||||||
|
|
||||||
# ─── Networking ───────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
resource "google_compute_network" "main" {
|
|
||||||
project = var.project_id
|
|
||||||
name = "${var.prefix}-vpc"
|
|
||||||
auto_create_subnetworks = false
|
|
||||||
|
|
||||||
depends_on = [google_project_service.compute]
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "google_compute_subnetwork" "main" {
|
|
||||||
project = var.project_id
|
|
||||||
name = "${var.prefix}-subnet"
|
|
||||||
ip_cidr_range = "10.110.0.0/22"
|
|
||||||
region = var.region
|
|
||||||
network = google_compute_network.main.id
|
|
||||||
|
|
||||||
secondary_ip_range {
|
|
||||||
range_name = "pods"
|
|
||||||
ip_cidr_range = "10.210.0.0/14"
|
|
||||||
}
|
|
||||||
|
|
||||||
secondary_ip_range {
|
|
||||||
range_name = "services"
|
|
||||||
ip_cidr_range = "10.214.0.0/20"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# ─── GKE Cluster ──────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
resource "google_container_cluster" "main" {
|
|
||||||
project = var.project_id
|
|
||||||
name = "${var.prefix}-gke"
|
|
||||||
location = var.region
|
|
||||||
|
|
||||||
network = google_compute_network.main.id
|
|
||||||
subnetwork = google_compute_subnetwork.main.id
|
|
||||||
|
|
||||||
ip_allocation_policy {
|
|
||||||
cluster_secondary_range_name = "pods"
|
|
||||||
services_secondary_range_name = "services"
|
|
||||||
}
|
|
||||||
|
|
||||||
workload_identity_config {
|
|
||||||
workload_pool = "${var.project_id}.svc.id.goog"
|
|
||||||
}
|
|
||||||
|
|
||||||
remove_default_node_pool = true
|
|
||||||
initial_node_count = 1
|
|
||||||
|
|
||||||
deletion_protection = var.deletion_protection
|
|
||||||
|
|
||||||
dynamic "release_channel" {
|
|
||||||
for_each = var.kubernetes_version == null ? [1] : []
|
|
||||||
content {
|
|
||||||
channel = "STABLE"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
resource_labels = var.labels
|
|
||||||
|
|
||||||
depends_on = [google_project_service.container]
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "google_container_node_pool" "main" {
|
|
||||||
project = var.project_id
|
|
||||||
name = "${var.prefix}-nodes"
|
|
||||||
location = var.region
|
|
||||||
cluster = google_container_cluster.main.name
|
|
||||||
node_count = var.node_count
|
|
||||||
|
|
||||||
node_config {
|
|
||||||
machine_type = var.node_machine_type
|
|
||||||
|
|
||||||
workload_metadata_config {
|
|
||||||
mode = "GKE_METADATA"
|
|
||||||
}
|
|
||||||
|
|
||||||
oauth_scopes = [
|
|
||||||
"https://www.googleapis.com/auth/cloud-platform",
|
|
||||||
]
|
|
||||||
|
|
||||||
labels = merge(var.labels, { role = "worker" })
|
|
||||||
}
|
|
||||||
|
|
||||||
management {
|
|
||||||
auto_repair = true
|
|
||||||
auto_upgrade = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# ─── External-DNS Workload Identity ──────────────────────────────────
|
|
||||||
# Allows external-dns to manage Cloud DNS records for app ingresses.
|
|
||||||
|
|
||||||
resource "google_service_account" "external_dns" {
|
|
||||||
project = var.project_id
|
|
||||||
account_id = "${var.prefix}-external-dns"
|
|
||||||
display_name = "External-DNS Service Account (Workload Identity)"
|
|
||||||
|
|
||||||
depends_on = [google_project_service.iam]
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "google_project_iam_member" "external_dns_dns_admin" {
|
|
||||||
project = var.project_id
|
|
||||||
role = "roles/dns.admin"
|
|
||||||
member = "serviceAccount:${google_service_account.external_dns.email}"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "google_service_account_iam_member" "external_dns_workload_identity" {
|
|
||||||
service_account_id = google_service_account.external_dns.name
|
|
||||||
role = "roles/iam.workloadIdentityUser"
|
|
||||||
member = "serviceAccount:${var.project_id}.svc.id.goog[external-dns/external-dns]"
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
output "cluster_name" { value = google_container_cluster.main.name }
|
|
||||||
output "project_id" { value = var.project_id }
|
|
||||||
output "region" { value = var.region }
|
|
||||||
output "external_dns_gsa_email" { value = google_service_account.external_dns.email }
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
terraform {
|
|
||||||
required_providers {
|
|
||||||
google = {
|
|
||||||
source = "hashicorp/google"
|
|
||||||
version = "~> 6.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Authentication: use Application Default Credentials (gcloud auth application-default login)
|
|
||||||
# or set GOOGLE_APPLICATION_CREDENTIALS to a service account key file.
|
|
||||||
provider "google" {
|
|
||||||
project = var.project_id
|
|
||||||
region = var.region
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "project_id" {
|
|
||||||
description = "GCP project ID for the workload environment"
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "region" {
|
|
||||||
description = "GCP region"
|
|
||||||
type = string
|
|
||||||
default = "europe-west4"
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
module "cluster" {
|
|
||||||
source = "../modules/cluster"
|
|
||||||
|
|
||||||
prefix = "clst-dev"
|
|
||||||
zone = "no-svg1"
|
|
||||||
node_plan = "DEV-1xCPU-2GB"
|
|
||||||
node_count = 2
|
|
||||||
network_cidr = "10.100.0.0/24"
|
|
||||||
|
|
||||||
tags = {
|
|
||||||
Environment = "dev"
|
|
||||||
ManagedBy = "tofu"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
# ─── Cluster ─────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
output "cluster_id" {
|
|
||||||
value = module.cluster.cluster_id
|
|
||||||
}
|
|
||||||
|
|
||||||
output "cluster_name" {
|
|
||||||
value = module.cluster.cluster_name
|
|
||||||
}
|
|
||||||
|
|
||||||
output "zone" {
|
|
||||||
value = module.cluster.zone
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
terraform {
|
|
||||||
required_version = ">= 1.0"
|
|
||||||
|
|
||||||
required_providers {
|
|
||||||
upcloud = {
|
|
||||||
source = "UpCloudLtd/upcloud"
|
|
||||||
version = "~> 5.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
provider "upcloud" {
|
|
||||||
# Set via environment variables: UPCLOUD_USERNAME, UPCLOUD_PASSWORD
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
# Router for the private network
|
|
||||||
resource "upcloud_router" "kubernetes" {
|
|
||||||
name = "${var.prefix}-${var.cluster_name}-router"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Gateway for internet connectivity
|
|
||||||
resource "upcloud_gateway" "kubernetes" {
|
|
||||||
name = "${var.prefix}-${var.cluster_name}-gateway"
|
|
||||||
zone = var.zone
|
|
||||||
features = ["nat"]
|
|
||||||
router {
|
|
||||||
id = upcloud_router.kubernetes.id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Private network for the Kubernetes cluster
|
|
||||||
resource "upcloud_network" "kubernetes" {
|
|
||||||
name = "${var.prefix}-${var.cluster_name}-network"
|
|
||||||
zone = var.zone
|
|
||||||
router = upcloud_router.kubernetes.id
|
|
||||||
|
|
||||||
ip_network {
|
|
||||||
address = var.network_cidr
|
|
||||||
dhcp = true
|
|
||||||
dhcp_default_route = true
|
|
||||||
family = "IPv4"
|
|
||||||
gateway = cidrhost(var.network_cidr, 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
depends_on = [upcloud_gateway.kubernetes]
|
|
||||||
}
|
|
||||||
|
|
||||||
# Kubernetes cluster
|
|
||||||
resource "upcloud_kubernetes_cluster" "main" {
|
|
||||||
name = "${var.prefix}-${var.cluster_name}"
|
|
||||||
zone = var.zone
|
|
||||||
network = upcloud_network.kubernetes.id
|
|
||||||
control_plane_ip_filter = var.control_plane_ip_filter
|
|
||||||
|
|
||||||
private_node_groups = true
|
|
||||||
}
|
|
||||||
|
|
||||||
# Node group for worker nodes
|
|
||||||
resource "upcloud_kubernetes_node_group" "workers" {
|
|
||||||
cluster = upcloud_kubernetes_cluster.main.id
|
|
||||||
name = "${var.prefix}-${var.cluster_name}-workers"
|
|
||||||
node_count = var.node_count
|
|
||||||
plan = var.node_plan
|
|
||||||
anti_affinity = var.node_count > 1
|
|
||||||
labels = {
|
|
||||||
prefix = var.prefix
|
|
||||||
cluster = var.cluster_name
|
|
||||||
role = "worker"
|
|
||||||
env = lookup(var.tags, "Environment", "dev")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
# ─── Cluster ─────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
output "cluster_id" {
|
|
||||||
description = "The ID of the Kubernetes cluster"
|
|
||||||
value = upcloud_kubernetes_cluster.main.id
|
|
||||||
}
|
|
||||||
|
|
||||||
output "cluster_name" {
|
|
||||||
description = "The name of the Kubernetes cluster"
|
|
||||||
value = upcloud_kubernetes_cluster.main.name
|
|
||||||
}
|
|
||||||
|
|
||||||
output "network_id" {
|
|
||||||
description = "The ID of the private network"
|
|
||||||
value = upcloud_network.kubernetes.id
|
|
||||||
}
|
|
||||||
|
|
||||||
output "network_cidr" {
|
|
||||||
description = "The CIDR block of the private network"
|
|
||||||
value = var.network_cidr
|
|
||||||
}
|
|
||||||
|
|
||||||
output "kubernetes_version" {
|
|
||||||
description = "The Kubernetes version of the cluster"
|
|
||||||
value = upcloud_kubernetes_cluster.main.version
|
|
||||||
}
|
|
||||||
|
|
||||||
output "zone" {
|
|
||||||
description = "The zone where the cluster is deployed"
|
|
||||||
value = var.zone
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
terraform {
|
|
||||||
required_providers {
|
|
||||||
upcloud = {
|
|
||||||
source = "UpCloudLtd/upcloud"
|
|
||||||
version = "~> 5.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
# ─── Cluster ─────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
variable "prefix" {
|
|
||||||
description = "Prefix for resource names"
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "cluster_name" {
|
|
||||||
description = "Name of the Kubernetes cluster"
|
|
||||||
type = string
|
|
||||||
default = "main"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "zone" {
|
|
||||||
description = "UpCloud zone"
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "node_plan" {
|
|
||||||
description = "UpCloud server plan for worker nodes"
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "node_count" {
|
|
||||||
description = "Number of worker nodes"
|
|
||||||
type = number
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "network_cidr" {
|
|
||||||
description = "CIDR block for the private network"
|
|
||||||
type = string
|
|
||||||
default = "10.100.0.0/24"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "control_plane_ip_filter" {
|
|
||||||
description = "CIDRs allowed to access the K8s API"
|
|
||||||
type = list(string)
|
|
||||||
default = ["0.0.0.0/0"]
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "tags" {
|
|
||||||
description = "Labels to apply to resources"
|
|
||||||
type = map(string)
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
module "cluster" {
|
|
||||||
source = "../modules/cluster"
|
|
||||||
|
|
||||||
prefix = "clst"
|
|
||||||
zone = "de-fra1"
|
|
||||||
node_plan = "4xCPU-8GB"
|
|
||||||
node_count = 3
|
|
||||||
network_cidr = "10.100.0.0/24"
|
|
||||||
|
|
||||||
control_plane_ip_filter = ["0.0.0.0/0"] # TODO: restrict to known CIDRs
|
|
||||||
|
|
||||||
tags = {
|
|
||||||
Environment = "prod"
|
|
||||||
ManagedBy = "tofu"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
# ─── Cluster ─────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
output "cluster_id" {
|
|
||||||
value = module.cluster.cluster_id
|
|
||||||
}
|
|
||||||
|
|
||||||
output "cluster_name" {
|
|
||||||
value = module.cluster.cluster_name
|
|
||||||
}
|
|
||||||
|
|
||||||
output "zone" {
|
|
||||||
value = module.cluster.zone
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
terraform {
|
|
||||||
required_version = ">= 1.0"
|
|
||||||
|
|
||||||
required_providers {
|
|
||||||
upcloud = {
|
|
||||||
source = "UpCloudLtd/upcloud"
|
|
||||||
version = "~> 5.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
provider "upcloud" {
|
|
||||||
# Set via environment variables: UPCLOUD_USERNAME, UPCLOUD_PASSWORD
|
|
||||||
}
|
|
||||||
@@ -1,116 +0,0 @@
|
|||||||
# =============================================================================
|
|
||||||
# UpCloud Workload Cluster
|
|
||||||
# =============================================================================
|
|
||||||
# A lean UCS cluster for running application workloads. No managed data
|
|
||||||
# services — those live on the platform cluster. ArgoCD (on the platform
|
|
||||||
# cluster) deploys apps to this cluster via the app-of-apps pattern.
|
|
||||||
#
|
|
||||||
# Platform components deployed by deploy-workload.sh:
|
|
||||||
# nginx-ingress, cert-manager, external-dns, external-secrets, alloy
|
|
||||||
#
|
|
||||||
# Usage:
|
|
||||||
# tofu init && tofu plan && tofu apply
|
|
||||||
# ./sync-tofu-outputs.sh --env upcloud-workload
|
|
||||||
# ./deploy-workload.sh --env upcloud-workload
|
|
||||||
# =============================================================================
|
|
||||||
|
|
||||||
variable "prefix" {
|
|
||||||
description = "Prefix for resource names"
|
|
||||||
type = string
|
|
||||||
default = "clst-workload"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "zone" {
|
|
||||||
description = "UpCloud zone"
|
|
||||||
type = string
|
|
||||||
default = "fi-hel1"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "node_plan" {
|
|
||||||
description = "UpCloud server plan for worker nodes"
|
|
||||||
type = string
|
|
||||||
default = "2xCPU-4GB"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "node_count" {
|
|
||||||
description = "Number of worker nodes"
|
|
||||||
type = number
|
|
||||||
default = 2
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "network_cidr" {
|
|
||||||
description = "CIDR block for the private network"
|
|
||||||
type = string
|
|
||||||
default = "10.110.0.0/24"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "control_plane_ip_filter" {
|
|
||||||
description = "CIDRs allowed to access the K8s API"
|
|
||||||
type = list(string)
|
|
||||||
default = ["0.0.0.0/0"]
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "tags" {
|
|
||||||
description = "Labels to apply to resources"
|
|
||||||
type = map(string)
|
|
||||||
default = {
|
|
||||||
Environment = "workload"
|
|
||||||
ManagedBy = "tofu"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# ─── Networking ───────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
resource "upcloud_router" "kubernetes" {
|
|
||||||
name = "${var.prefix}-workload-router"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "upcloud_gateway" "kubernetes" {
|
|
||||||
name = "${var.prefix}-workload-gateway"
|
|
||||||
zone = var.zone
|
|
||||||
features = ["nat"]
|
|
||||||
router {
|
|
||||||
id = upcloud_router.kubernetes.id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "upcloud_network" "kubernetes" {
|
|
||||||
name = "${var.prefix}-workload-network"
|
|
||||||
zone = var.zone
|
|
||||||
router = upcloud_router.kubernetes.id
|
|
||||||
|
|
||||||
ip_network {
|
|
||||||
address = var.network_cidr
|
|
||||||
dhcp = true
|
|
||||||
dhcp_default_route = true
|
|
||||||
family = "IPv4"
|
|
||||||
gateway = cidrhost(var.network_cidr, 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
depends_on = [upcloud_gateway.kubernetes]
|
|
||||||
}
|
|
||||||
|
|
||||||
# ─── Kubernetes Cluster ───────────────────────────────────────────────
|
|
||||||
|
|
||||||
resource "upcloud_kubernetes_cluster" "main" {
|
|
||||||
name = "${var.prefix}-workload"
|
|
||||||
zone = var.zone
|
|
||||||
network = upcloud_network.kubernetes.id
|
|
||||||
control_plane_ip_filter = var.control_plane_ip_filter
|
|
||||||
|
|
||||||
private_node_groups = true
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "upcloud_kubernetes_node_group" "workers" {
|
|
||||||
cluster = upcloud_kubernetes_cluster.main.id
|
|
||||||
name = "${var.prefix}-workload-workers"
|
|
||||||
node_count = var.node_count
|
|
||||||
plan = var.node_plan
|
|
||||||
anti_affinity = var.node_count > 1
|
|
||||||
labels = {
|
|
||||||
prefix = var.prefix
|
|
||||||
cluster = "workload"
|
|
||||||
role = "worker"
|
|
||||||
env = lookup(var.tags, "Environment", "workload")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
output "cluster_name" { value = upcloud_kubernetes_cluster.main.name }
|
|
||||||
output "cluster_id" { value = upcloud_kubernetes_cluster.main.id }
|
|
||||||
output "zone" { value = var.zone }
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
terraform {
|
|
||||||
required_version = ">= 1.0"
|
|
||||||
|
|
||||||
required_providers {
|
|
||||||
upcloud = {
|
|
||||||
source = "UpCloudLtd/upcloud"
|
|
||||||
version = "~> 5.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
provider "upcloud" {
|
|
||||||
# Set via environment variables: UPCLOUD_USERNAME, UPCLOUD_PASSWORD
|
|
||||||
}
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
||||||
TOFU_ROOT="$(dirname "$SCRIPT_DIR")"
|
|
||||||
PROJECT_ROOT="$(dirname "$TOFU_ROOT")"
|
|
||||||
|
|
||||||
CLUSTER="${1:?Usage: $0 <cluster> (e.g., aks-dev, eks-prod)}"
|
|
||||||
PLATFORM="${CLUSTER%%-*}"
|
|
||||||
ENV="${CLUSTER#*-}"
|
|
||||||
|
|
||||||
KUBECONFIG_FILE="$PROJECT_ROOT/private/$CLUSTER/kubeconfig"
|
|
||||||
|
|
||||||
if [[ -f "$KUBECONFIG_FILE" ]]; then
|
|
||||||
echo "Kubeconfig already exists: $KUBECONFIG_FILE"
|
|
||||||
echo ""
|
|
||||||
echo " export KUBECONFIG=$KUBECONFIG_FILE"
|
|
||||||
else
|
|
||||||
echo "No cached kubeconfig. Fetching from platform..."
|
|
||||||
|
|
||||||
# Load platform credentials
|
|
||||||
ENV_FILE="$TOFU_ROOT/configs/$PLATFORM.env"
|
|
||||||
if [[ -f "$ENV_FILE" ]]; then
|
|
||||||
set -a; source "$ENV_FILE"; set +a
|
|
||||||
fi
|
|
||||||
|
|
||||||
TOFU_DIR="$TOFU_ROOT/platforms/$PLATFORM/$ENV"
|
|
||||||
mkdir -p "$(dirname "$KUBECONFIG_FILE")"
|
|
||||||
|
|
||||||
case "$PLATFORM" in
|
|
||||||
aks)
|
|
||||||
cd "$TOFU_DIR"
|
|
||||||
RG=$(tofu output -raw resource_group_name 2>/dev/null || echo "$CLUSTER-rg")
|
|
||||||
NAME=$(tofu output -raw cluster_name 2>/dev/null || echo "$CLUSTER")
|
|
||||||
az aks get-credentials --resource-group "$RG" --name "$NAME" --file "$KUBECONFIG_FILE" --overwrite-existing
|
|
||||||
;;
|
|
||||||
eks)
|
|
||||||
cd "$TOFU_DIR"
|
|
||||||
NAME=$(tofu output -raw cluster_name 2>/dev/null || echo "$CLUSTER")
|
|
||||||
REGION=$(tofu output -raw aws_region 2>/dev/null || echo "${AWS_REGION:-eu-west-1}")
|
|
||||||
aws eks update-kubeconfig --name "$NAME" --region "$REGION" --kubeconfig "$KUBECONFIG_FILE"
|
|
||||||
;;
|
|
||||||
gke)
|
|
||||||
cd "$TOFU_DIR"
|
|
||||||
NAME=$(tofu output -raw cluster_name 2>/dev/null || echo "$CLUSTER")
|
|
||||||
REGION=$(tofu output -raw region 2>/dev/null || echo "${GCP_REGION:-europe-west4}")
|
|
||||||
PROJECT=$(tofu output -raw project_id 2>/dev/null || echo "${GCP_PROJECT_ID:-}")
|
|
||||||
gcloud container clusters get-credentials "$NAME" --region "$REGION" --project "$PROJECT"
|
|
||||||
cp ~/.kube/config "$KUBECONFIG_FILE"
|
|
||||||
;;
|
|
||||||
upc)
|
|
||||||
cd "$TOFU_DIR"
|
|
||||||
CLUSTER_ID=$(tofu output -raw cluster_id 2>/dev/null || echo "${UPCLOUD_CLUSTER_ID:-}")
|
|
||||||
upctl kubernetes config "$CLUSTER_ID" > "$KUBECONFIG_FILE"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Error: unknown platform '$PLATFORM'"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
chmod 600 "$KUBECONFIG_FILE"
|
|
||||||
echo "Kubeconfig saved: $KUBECONFIG_FILE"
|
|
||||||
echo ""
|
|
||||||
echo " export KUBECONFIG=$KUBECONFIG_FILE"
|
|
||||||
fi
|
|
||||||
@@ -1,246 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
||||||
TOFU_ROOT="$(dirname "$SCRIPT_DIR")"
|
|
||||||
PROJECT_ROOT="$(dirname "$TOFU_ROOT")"
|
|
||||||
|
|
||||||
# ─── Usage ────────────────────────────────────────────────────────────
|
|
||||||
usage() {
|
|
||||||
cat <<EOF
|
|
||||||
Usage: $0 <cluster> [options]
|
|
||||||
|
|
||||||
Provision a Kubernetes cluster using OpenTofu.
|
|
||||||
Mirrors bootstrap.sh convention: cluster = <platform>-<env>
|
|
||||||
|
|
||||||
Clusters: aks-dev | aks-prod | eks-dev | eks-prod
|
|
||||||
gke-dev | gke-prod | upc-dev | upc-prod
|
|
||||||
<platform>-workload (for workload clusters)
|
|
||||||
|
|
||||||
Options:
|
|
||||||
--plan Plan only, don't apply
|
|
||||||
--destroy Destroy the cluster (use teardown-cluster.sh instead)
|
|
||||||
--auto Skip confirmation prompts
|
|
||||||
-h, --help Show this help
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
$0 aks-dev
|
|
||||||
$0 eks-prod --plan
|
|
||||||
$0 upc-dev --auto
|
|
||||||
|
|
||||||
Prerequisites:
|
|
||||||
- tofu, kubectl, helm installed
|
|
||||||
- Platform credentials in .tofu/configs/<platform>.env
|
|
||||||
- Cluster config in clusters/<cluster>.yaml
|
|
||||||
|
|
||||||
After provisioning, run:
|
|
||||||
./bootstrap.sh <cluster>
|
|
||||||
EOF
|
|
||||||
exit "${1:-0}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# ─── Parse arguments ──────────────────────────────────────────────────
|
|
||||||
CLUSTER=""
|
|
||||||
PLAN_ONLY=false
|
|
||||||
DESTROY=false
|
|
||||||
AUTO_APPROVE=false
|
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
|
||||||
case "$1" in
|
|
||||||
--plan) PLAN_ONLY=true; shift ;;
|
|
||||||
--destroy) DESTROY=true; shift ;;
|
|
||||||
--auto) AUTO_APPROVE=true; shift ;;
|
|
||||||
-h|--help) usage 0 ;;
|
|
||||||
-*) echo "Unknown option: $1"; usage 1 ;;
|
|
||||||
*)
|
|
||||||
if [[ -z "$CLUSTER" ]]; then
|
|
||||||
CLUSTER="$1"
|
|
||||||
else
|
|
||||||
echo "Error: unexpected argument '$1'"
|
|
||||||
usage 1
|
|
||||||
fi
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
[[ -z "$CLUSTER" ]] && { echo "Error: <cluster> argument required"; usage 1; }
|
|
||||||
|
|
||||||
# ─── Map cluster → platform + env ────────────────────────────────────
|
|
||||||
PLATFORM="${CLUSTER%%-*}" # aks-dev → aks
|
|
||||||
ENV="${CLUSTER#*-}" # aks-dev → dev
|
|
||||||
|
|
||||||
case "$PLATFORM" in
|
|
||||||
aks|eks|gke|upc) ;;
|
|
||||||
*) echo "Error: unknown platform '$PLATFORM'. Expected: aks, eks, gke, upc"; exit 1 ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
TOFU_DIR="$TOFU_ROOT/platforms/$PLATFORM/$ENV"
|
|
||||||
if [[ ! -d "$TOFU_DIR" ]]; then
|
|
||||||
echo "Error: tofu directory not found: $TOFU_DIR"
|
|
||||||
echo "Available environments for $PLATFORM:"
|
|
||||||
ls -1 "$TOFU_ROOT/platforms/$PLATFORM/" 2>/dev/null | grep -v modules || echo " (none)"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "========================================="
|
|
||||||
echo " Kubernetes Cluster Setup"
|
|
||||||
echo "========================================="
|
|
||||||
echo ""
|
|
||||||
echo " Cluster: $CLUSTER"
|
|
||||||
echo " Platform: $PLATFORM"
|
|
||||||
echo " Env: $ENV"
|
|
||||||
echo " Tofu dir: $TOFU_DIR"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# ─── Prerequisites ────────────────────────────────────────────────────
|
|
||||||
echo "=== Checking Prerequisites ==="
|
|
||||||
command -v tofu >/dev/null 2>&1 || { echo "Error: tofu is not installed."; exit 1; }
|
|
||||||
command -v kubectl >/dev/null 2>&1 || { echo "Error: kubectl is not installed."; exit 1; }
|
|
||||||
command -v helm >/dev/null 2>&1 || { echo "Error: helm is not installed."; exit 1; }
|
|
||||||
echo " tofu, kubectl, helm: OK"
|
|
||||||
|
|
||||||
# ─── Load platform credentials ────────────────────────────────────────
|
|
||||||
ENV_FILE="$TOFU_ROOT/configs/$PLATFORM.env"
|
|
||||||
if [[ -f "$ENV_FILE" ]]; then
|
|
||||||
echo " Loading credentials from configs/$PLATFORM.env"
|
|
||||||
set -a
|
|
||||||
# shellcheck disable=SC1090
|
|
||||||
source "$ENV_FILE"
|
|
||||||
set +a
|
|
||||||
else
|
|
||||||
echo " Warning: $ENV_FILE not found — using existing environment/CLI auth"
|
|
||||||
echo " Copy configs/$PLATFORM.env.example → configs/$PLATFORM.env to configure"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ─── Load cluster config (if exists) ──────────────────────────────────
|
|
||||||
CLUSTER_CONFIG="$PROJECT_ROOT/clusters/$CLUSTER.yaml"
|
|
||||||
if [[ -f "$CLUSTER_CONFIG" ]]; then
|
|
||||||
echo " Loading cluster config from clusters/$CLUSTER.yaml"
|
|
||||||
if command -v yq >/dev/null 2>&1; then
|
|
||||||
eval "$(yq -r 'to_entries[] | "export CLUSTER_\(.key)=\"\(.value)\""' "$CLUSTER_CONFIG")"
|
|
||||||
echo " Cluster name: ${CLUSTER_clusterName:-$CLUSTER}"
|
|
||||||
else
|
|
||||||
echo " Warning: yq not installed — cluster config not loaded"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo " Warning: $CLUSTER_CONFIG not found — using defaults"
|
|
||||||
fi
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# ─── Run OpenTofu ─────────────────────────────────────────────────────
|
|
||||||
cd "$TOFU_DIR"
|
|
||||||
|
|
||||||
echo "=== Initializing OpenTofu ==="
|
|
||||||
tofu init
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
if $DESTROY; then
|
|
||||||
echo "=== Planning Destruction ==="
|
|
||||||
tofu plan -destroy -out=tfplan
|
|
||||||
|
|
||||||
if ! $AUTO_APPROVE; then
|
|
||||||
echo ""
|
|
||||||
read -rp "DESTROY cluster $CLUSTER? This is irreversible. (yes/no) " REPLY
|
|
||||||
[[ "$REPLY" == "yes" ]] || { echo "Cancelled."; exit 1; }
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Destroying infrastructure..."
|
|
||||||
tofu apply tfplan
|
|
||||||
echo ""
|
|
||||||
echo "=== Cluster $CLUSTER Destroyed ==="
|
|
||||||
|
|
||||||
elif $PLAN_ONLY; then
|
|
||||||
echo "=== Planning Infrastructure ==="
|
|
||||||
tofu plan
|
|
||||||
echo ""
|
|
||||||
echo "=== Plan complete (--plan mode, no changes applied) ==="
|
|
||||||
|
|
||||||
else
|
|
||||||
echo "=== Planning Infrastructure ==="
|
|
||||||
tofu plan -out=tfplan
|
|
||||||
|
|
||||||
if ! $AUTO_APPROVE; then
|
|
||||||
echo ""
|
|
||||||
read -rp "Apply this plan for $CLUSTER? (y/n) " -n 1 REPLY
|
|
||||||
echo
|
|
||||||
[[ "$REPLY" =~ ^[Yy]$ ]] || { echo "Cancelled."; exit 1; }
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Applying infrastructure..."
|
|
||||||
tofu apply tfplan
|
|
||||||
|
|
||||||
# ─── Save kubeconfig ──────────────────────────────────────────────
|
|
||||||
KUBECONFIG_DIR="$PROJECT_ROOT/private/$CLUSTER"
|
|
||||||
mkdir -p "$KUBECONFIG_DIR"
|
|
||||||
KUBECONFIG_FILE="$KUBECONFIG_DIR/kubeconfig"
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "=== Saving Kubeconfig ==="
|
|
||||||
|
|
||||||
case "$PLATFORM" in
|
|
||||||
aks)
|
|
||||||
if tofu output -raw kubeconfig > "$KUBECONFIG_FILE" 2>/dev/null; then
|
|
||||||
echo " Saved from tofu output"
|
|
||||||
else
|
|
||||||
echo " Fetching from Azure CLI..."
|
|
||||||
RG=$(tofu output -raw resource_group_name 2>/dev/null || echo "${CLUSTER_clusterName:-$CLUSTER}-rg")
|
|
||||||
NAME=$(tofu output -raw cluster_name 2>/dev/null || echo "${CLUSTER_clusterName:-$CLUSTER}")
|
|
||||||
az aks get-credentials --resource-group "$RG" --name "$NAME" --file "$KUBECONFIG_FILE" --overwrite-existing
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
eks)
|
|
||||||
NAME=$(tofu output -raw cluster_name 2>/dev/null || echo "${CLUSTER_clusterName:-$CLUSTER}")
|
|
||||||
REGION=$(tofu output -raw aws_region 2>/dev/null || echo "${AWS_REGION:-eu-west-1}")
|
|
||||||
aws eks update-kubeconfig --name "$NAME" --region "$REGION" --kubeconfig "$KUBECONFIG_FILE"
|
|
||||||
;;
|
|
||||||
gke)
|
|
||||||
NAME=$(tofu output -raw cluster_name 2>/dev/null || echo "${CLUSTER_clusterName:-$CLUSTER}")
|
|
||||||
REGION=$(tofu output -raw region 2>/dev/null || echo "${GCP_REGION:-europe-west4}")
|
|
||||||
PROJECT=$(tofu output -raw project_id 2>/dev/null || echo "${GCP_PROJECT_ID:-}")
|
|
||||||
gcloud container clusters get-credentials "$NAME" --region "$REGION" --project "$PROJECT" 2>/dev/null \
|
|
||||||
&& cp ~/.kube/config "$KUBECONFIG_FILE" \
|
|
||||||
|| echo " Warning: could not fetch kubeconfig via gcloud"
|
|
||||||
;;
|
|
||||||
upc)
|
|
||||||
if tofu output -raw kubeconfig > "$KUBECONFIG_FILE" 2>/dev/null; then
|
|
||||||
echo " Saved from tofu output"
|
|
||||||
else
|
|
||||||
CLUSTER_ID=$(tofu output -raw cluster_id 2>/dev/null || echo "${UPCLOUD_CLUSTER_ID:-}")
|
|
||||||
if [[ -n "$CLUSTER_ID" ]]; then
|
|
||||||
upctl kubernetes config "$CLUSTER_ID" > "$KUBECONFIG_FILE"
|
|
||||||
else
|
|
||||||
echo " Warning: could not determine cluster ID for kubeconfig"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [[ -f "$KUBECONFIG_FILE" ]]; then
|
|
||||||
chmod 600 "$KUBECONFIG_FILE"
|
|
||||||
echo " Kubeconfig: $KUBECONFIG_FILE"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ─── Wait for nodes ──────────────────────────────────────────────
|
|
||||||
echo ""
|
|
||||||
echo "=== Waiting for Cluster Nodes ==="
|
|
||||||
export KUBECONFIG="$KUBECONFIG_FILE"
|
|
||||||
if kubectl wait --for=condition=Ready nodes --all --timeout=300s 2>/dev/null; then
|
|
||||||
echo " All nodes ready"
|
|
||||||
else
|
|
||||||
echo " Warning: nodes not ready within timeout — check cluster status"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ─── Summary ─────────────────────────────────────────────────────
|
|
||||||
echo ""
|
|
||||||
echo "========================================="
|
|
||||||
echo " Cluster $CLUSTER Provisioned"
|
|
||||||
echo "========================================="
|
|
||||||
echo ""
|
|
||||||
echo " Kubeconfig: $KUBECONFIG_FILE"
|
|
||||||
echo ""
|
|
||||||
echo " Next steps:"
|
|
||||||
echo " export KUBECONFIG=$KUBECONFIG_FILE"
|
|
||||||
echo " ./bootstrap.sh $CLUSTER"
|
|
||||||
echo ""
|
|
||||||
fi
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
||||||
|
|
||||||
# Delegate to setup-cluster.sh with --destroy flag
|
|
||||||
exec "$SCRIPT_DIR/setup-cluster.sh" "$@" --destroy
|
|
||||||
21
README.md
21
README.md
@@ -57,7 +57,7 @@ This repository contains the complete GitOps configuration for our Kubernetes cl
|
|||||||
|
|
||||||
### What's Inside
|
### What's Inside
|
||||||
|
|
||||||
- **Infrastructure Applications**: Traefik, Cert-Manager, Kyverno, Prometheus, Grafana, Loki, Tempo, Sealed Secrets
|
- **Infrastructure Applications**: Traefik, Cert-Manager, Kyverno, Prometheus, Grafana, Loki, Tempo, Sealed Secrets, Homepage (platform dashboard)
|
||||||
- **Business Applications**: MCP10X, MusicMan, Dot-AI Stack, ArgoCD MCP
|
- **Business Applications**: MCP10X, MusicMan, Dot-AI Stack, ArgoCD MCP
|
||||||
- **Policies**: Kyverno security policies for secret management, namespace controls, pod verification
|
- **Policies**: Kyverno security policies for secret management, namespace controls, pod verification
|
||||||
- **Monitoring**: Full observability stack with metrics, logs, traces, and alerting
|
- **Monitoring**: Full observability stack with metrics, logs, traces, and alerting
|
||||||
@@ -80,23 +80,8 @@ This repository contains the complete GitOps configuration for our Kubernetes cl
|
|||||||
|
|
||||||
```
|
```
|
||||||
.
|
.
|
||||||
├── bootstrap.sh # Cluster initialization (ArgoCD + GitOps)
|
├── bootstrap.sh # Cluster initialization script
|
||||||
├── _app-of-apps-{cluster}.yaml # Root ArgoCD Application (per cluster)
|
├── _app-of-apps.yaml # Root ArgoCD Application (App-of-Apps pattern)
|
||||||
│
|
|
||||||
├── .tofu/ # Infrastructure provisioning (OpenTofu)
|
|
||||||
│ ├── platforms/ # Per-platform IaC (one dir per cloud)
|
|
||||||
│ │ ├── aks/ # Azure AKS (modules/ + dev/ + prod/ + workload/)
|
|
||||||
│ │ ├── eks/ # AWS EKS
|
|
||||||
│ │ ├── gke/ # GCP GKE
|
|
||||||
│ │ └── upc/ # UpCloud
|
|
||||||
│ ├── configs/ # Platform credentials (git-ignored)
|
|
||||||
│ │ └── *.env.example # Template for each platform
|
|
||||||
│ └── scripts/ # Cluster lifecycle scripts
|
|
||||||
│ ├── setup-cluster.sh # Create cluster: ./setup-cluster.sh aks-dev
|
|
||||||
│ ├── teardown-cluster.sh
|
|
||||||
│ └── get-kubeconfig.sh
|
|
||||||
│
|
|
||||||
├── clusters/ # Cluster metadata (domain, trustedIPs, etc.)
|
|
||||||
│
|
│
|
||||||
├── infra/ # Infrastructure ArgoCD Applications (Kustomize multi-cluster)
|
├── infra/ # Infrastructure ArgoCD Applications (Kustomize multi-cluster)
|
||||||
│ ├── base/ # Base ArgoCD Application manifests (one dir per component)
|
│ ├── base/ # Base ArgoCD Application manifests (one dir per component)
|
||||||
|
|||||||
47
apps/overlays/upc-dev/dbunk-demo/dbunk-demo.yaml
Normal file
47
apps/overlays/upc-dev/dbunk-demo/dbunk-demo.yaml
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
apiVersion: argoproj.io/v1alpha1
|
||||||
|
kind: Application
|
||||||
|
metadata:
|
||||||
|
name: dbunk-demo
|
||||||
|
namespace: argocd
|
||||||
|
annotations:
|
||||||
|
argocd.argoproj.io/sync-wave: "12"
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: dbunk-demo
|
||||||
|
app.kubernetes.io/part-of: apps
|
||||||
|
app.kubernetes.io/managed-by: argocd
|
||||||
|
finalizers:
|
||||||
|
- resources-finalizer.argocd.argoproj.io
|
||||||
|
spec:
|
||||||
|
project: default
|
||||||
|
|
||||||
|
sources:
|
||||||
|
- repoURL: ssh://git@git.forteapps.net:2222/Forte/forte-helm.git
|
||||||
|
path: forteapp
|
||||||
|
targetRevision: HEAD
|
||||||
|
helm:
|
||||||
|
valueFiles:
|
||||||
|
- $values/dbunk-demo/values.yaml
|
||||||
|
|
||||||
|
- repoURL: ssh://git@git.forteapps.net:2222/Forte/helm-prod-values.git
|
||||||
|
targetRevision: HEAD
|
||||||
|
ref: values
|
||||||
|
|
||||||
|
destination:
|
||||||
|
server: https://kubernetes.default.svc
|
||||||
|
namespace: dbunk-demo
|
||||||
|
|
||||||
|
syncPolicy:
|
||||||
|
automated:
|
||||||
|
prune: true
|
||||||
|
selfHeal: true
|
||||||
|
allowEmpty: false
|
||||||
|
syncOptions:
|
||||||
|
- CreateNamespace=true
|
||||||
|
- Validate=true
|
||||||
|
- ServerSideApply=true
|
||||||
|
retry:
|
||||||
|
limit: 5
|
||||||
|
backoff:
|
||||||
|
duration: 5s
|
||||||
|
factor: 2
|
||||||
|
maxDuration: 3m
|
||||||
4
apps/overlays/upc-dev/dbunk-demo/kustomization.yaml
Normal file
4
apps/overlays/upc-dev/dbunk-demo/kustomization.yaml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- dbunk-demo.yaml
|
||||||
@@ -2,6 +2,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1
|
|||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
resources:
|
resources:
|
||||||
- ../../base
|
- ../../base
|
||||||
|
- dbunk-demo
|
||||||
|
|
||||||
# No patches needed — base already has "upc-dev" paths
|
# No patches needed — base already has "upc-dev" paths
|
||||||
# upc-dev is the default/base cluster
|
# upc-dev is the default/base cluster
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ Bootstrap()
|
|||||||
Gitea()
|
Gitea()
|
||||||
{
|
{
|
||||||
echo "Installing secret..."
|
echo "Installing secret..."
|
||||||
kubectl apply -f "secrets/"
|
|
||||||
kubectl apply -f "private/${CLUSTER}/gitea-repo-main.yaml"
|
kubectl apply -f "private/${CLUSTER}/gitea-repo-main.yaml"
|
||||||
kubectl apply -f "private/${CLUSTER}/main.key"
|
kubectl apply -f "private/${CLUSTER}/main.key"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,30 +115,9 @@ This Kubernetes cluster uses a **GitOps approach** powered by **ArgoCD**, where
|
|||||||
|
|
||||||
```
|
```
|
||||||
launchpad/
|
launchpad/
|
||||||
├── bootstrap.sh # Cluster initialization (ArgoCD + GitOps)
|
├── bootstrap.sh # Cluster initialization script
|
||||||
├── _app-of-apps-{cluster}.yaml # Root ArgoCD Application (per cluster)
|
├── _app-of-apps-upc-dev.yaml # Root ArgoCD Application (upc-dev cluster)
|
||||||
│
|
├── _app-of-apps-upc-prod.yaml # Root ArgoCD Application (upc-prod cluster)
|
||||||
├── .tofu/ # Infrastructure provisioning (OpenTofu)
|
|
||||||
│ ├── platforms/ # Per-platform IaC
|
|
||||||
│ │ ├── aks/ # Azure AKS
|
|
||||||
│ │ │ ├── modules/cluster/ # Reusable AKS module
|
|
||||||
│ │ │ ├── dev/ # tofu root for aks-dev
|
|
||||||
│ │ │ ├── prod/ # tofu root for aks-prod
|
|
||||||
│ │ │ └── workload/ # workload cluster (no data services)
|
|
||||||
│ │ ├── eks/ # AWS EKS (same structure)
|
|
||||||
│ │ ├── gke/ # GCP GKE
|
|
||||||
│ │ └── upc/ # UpCloud
|
|
||||||
│ ├── configs/ # Platform credentials (git-ignored)
|
|
||||||
│ │ └── {platform}.env.example # Template per platform
|
|
||||||
│ └── scripts/
|
|
||||||
│ ├── setup-cluster.sh # ./setup-cluster.sh <cluster> [--plan|--auto]
|
|
||||||
│ ├── teardown-cluster.sh # ./teardown-cluster.sh <cluster>
|
|
||||||
│ └── get-kubeconfig.sh # ./get-kubeconfig.sh <cluster>
|
|
||||||
│
|
|
||||||
├── clusters/ # Cluster metadata YAML (domain, IPs, etc.)
|
|
||||||
│ ├── aks-dev.yaml
|
|
||||||
│ ├── upc-dev.yaml
|
|
||||||
│ └── ...
|
|
||||||
│
|
│
|
||||||
├── infra/ # Infrastructure ArgoCD Applications (Kustomize)
|
├── infra/ # Infrastructure ArgoCD Applications (Kustomize)
|
||||||
│ ├── base/ # Base Application manifests (one dir per component)
|
│ ├── base/ # Base Application manifests (one dir per component)
|
||||||
|
|||||||
@@ -72,22 +72,9 @@ Internet
|
|||||||
|
|
||||||
```
|
```
|
||||||
launchpad/
|
launchpad/
|
||||||
├── bootstrap.sh # Cluster initialization (ArgoCD + GitOps)
|
├── bootstrap.sh # Cluster initialization script
|
||||||
├── _app-of-apps-{cluster}.yaml # Root ArgoCD Application (per cluster)
|
├── _app-of-apps-upc-dev.yaml # Root ArgoCD Application (upc-dev)
|
||||||
│
|
├── _app-of-apps-upc-prod.yaml # Root ArgoCD Application (upc-prod)
|
||||||
├── .tofu/ # Infrastructure provisioning (OpenTofu)
|
|
||||||
│ ├── platforms/ # Per-platform IaC
|
|
||||||
│ │ ├── aks/ # Azure: modules/cluster/, dev/, prod/, workload/
|
|
||||||
│ │ ├── eks/ # AWS: same structure
|
|
||||||
│ │ ├── gke/ # GCP
|
|
||||||
│ │ └── upc/ # UpCloud
|
|
||||||
│ ├── configs/ # Platform credentials (git-ignored)
|
|
||||||
│ └── scripts/ # setup-cluster.sh, teardown-cluster.sh, get-kubeconfig.sh
|
|
||||||
│
|
|
||||||
├── clusters/ # Cluster metadata YAML
|
|
||||||
│ ├── aks-dev.yaml
|
|
||||||
│ ├── upc-dev.yaml
|
|
||||||
│ └── ...
|
|
||||||
│
|
│
|
||||||
├── infra/ # Infrastructure applications (Kustomize)
|
├── infra/ # Infrastructure applications (Kustomize)
|
||||||
│ ├── base/ # One subdirectory per component
|
│ ├── base/ # One subdirectory per component
|
||||||
@@ -738,6 +725,59 @@ TLS terminates at Traefik; ArgoCD runs in insecure mode behind the proxy.
|
|||||||
|
|
||||||
## Infrastructure Components
|
## Infrastructure Components
|
||||||
|
|
||||||
|
### Homepage (Platform Dashboard)
|
||||||
|
|
||||||
|
**Chart**: `jameswynn/homepage`
|
||||||
|
**Namespace**: `homepage`
|
||||||
|
**URL**: `https://start.forteapps.net`
|
||||||
|
|
||||||
|
Platform dashboard that auto-discovers deployed apps via Kubernetes service annotations.
|
||||||
|
|
||||||
|
**Discovery mechanism**: Services annotated with `gethomepage.dev/enabled: "true"` appear in the dashboard. Apps not deployed = annotations absent = not shown. Fully dynamic per environment.
|
||||||
|
|
||||||
|
**Annotated services**:
|
||||||
|
| Service | Namespace | Group | Widget |
|
||||||
|
|---------|-----------|-------|--------|
|
||||||
|
| `gitea-http` | `gitea` | DevOps | `gitea` |
|
||||||
|
| `argocd-server` | `argocd` | DevOps | `argocd` |
|
||||||
|
| `keycloak` | `keycloak` | Identity | none |
|
||||||
|
| `grafana` | `monitoring` | Monitoring | `grafana` |
|
||||||
|
| `karpor-server` | `karpor` | DevOps | none |
|
||||||
|
|
||||||
|
**Adding a new app**: Annotate the app's Service in its Helm values:
|
||||||
|
```yaml
|
||||||
|
service:
|
||||||
|
annotations:
|
||||||
|
gethomepage.dev/enabled: "true"
|
||||||
|
gethomepage.dev/name: "My App"
|
||||||
|
gethomepage.dev/description: "What it does"
|
||||||
|
gethomepage.dev/group: "GroupName"
|
||||||
|
gethomepage.dev/icon: "icon-name" # https://github.com/walkxcode/dashboard-icons
|
||||||
|
gethomepage.dev/href: "https://myapp.forteapps.net"
|
||||||
|
# Optional live widget:
|
||||||
|
gethomepage.dev/widget.type: "myapp"
|
||||||
|
gethomepage.dev/widget.url: "https://myapp.forteapps.net"
|
||||||
|
# gethomepage.dev/widget.key: "{{HOMEPAGE_VAR_MYAPP_TOKEN}}"
|
||||||
|
```
|
||||||
|
|
||||||
|
**Widget API credentials**: Inject via env vars into the Homepage pod:
|
||||||
|
```yaml
|
||||||
|
# In homepage-values.yaml per environment
|
||||||
|
env:
|
||||||
|
- name: HOMEPAGE_VAR_GRAFANA_TOKEN
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: homepage-widget-credentials
|
||||||
|
key: grafana-token
|
||||||
|
```
|
||||||
|
Then reference as `gethomepage.dev/widget.key: "{{HOMEPAGE_VAR_GRAFANA_TOKEN}}"`.
|
||||||
|
|
||||||
|
**Values files**:
|
||||||
|
- `infra/values/base/homepage-values.yaml` — RBAC, kubernetes mode, layout
|
||||||
|
- `infra/values/{env}/homepage-values.yaml` — hostname per environment
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
### Traefik
|
### Traefik
|
||||||
|
|
||||||
**Chart**: `traefik/traefik`
|
**Chart**: `traefik/traefik`
|
||||||
@@ -1023,6 +1063,102 @@ dind:
|
|||||||
- Gitea admin panel (`/admin/runners`) — runners show as Online
|
- Gitea admin panel (`/admin/runners`) — runners show as Online
|
||||||
- Create test workflow in `.gitea/workflows/test.yml` — job executes
|
- Create test workflow in `.gitea/workflows/test.yml` — job executes
|
||||||
|
|
||||||
|
### Vaultwarden
|
||||||
|
|
||||||
|
**Chart**: `guerzon/vaultwarden`
|
||||||
|
**Version**: 0.36.4 (app v1.36.0-alpine)
|
||||||
|
**Namespace**: `vaultwarden`
|
||||||
|
|
||||||
|
**Purpose**: Self-hosted Bitwarden-compatible password manager.
|
||||||
|
|
||||||
|
**Configuration**:
|
||||||
|
```yaml
|
||||||
|
# infra/overlays/upc-dev/vaultwarden/ + infra/values/
|
||||||
|
domain: "https://bitwarden.forteapps.net"
|
||||||
|
|
||||||
|
ingress:
|
||||||
|
enabled: true
|
||||||
|
class: "traefik"
|
||||||
|
tls: true
|
||||||
|
tlsSecret: vaultwarden-tls
|
||||||
|
hostname: bitwarden.forteapps.net
|
||||||
|
additionalAnnotations:
|
||||||
|
cert-manager.io/cluster-issuer: letsencrypt-prod
|
||||||
|
|
||||||
|
database:
|
||||||
|
type: postgresql
|
||||||
|
host: vaultwarden-postgresql # StatefulSet in overlay
|
||||||
|
existingSecret: prod-db-creds
|
||||||
|
|
||||||
|
storage:
|
||||||
|
data: 5Gi (ReadWriteOnce)
|
||||||
|
attachments: 5Gi (ReadWriteOnce)
|
||||||
|
```
|
||||||
|
|
||||||
|
**TLS**: cert-manager auto-provisions Let's Encrypt certificate via `letsencrypt-prod` ClusterIssuer (same pattern as Gitea, Grafana, etc).
|
||||||
|
|
||||||
|
**SSO**: Keycloak OIDC via `forte` realm (client ID: `vaultwarden`). Self-service client config Secret (`keycloak-client-vaultwarden`) triggers registrar to create KC client and sync credentials to `vaultwarden-oidc-credentials`. PKCE enabled.
|
||||||
|
|
||||||
|
**Endpoints**:
|
||||||
|
- Web UI: `https://bitwarden.forteapps.net`
|
||||||
|
|
||||||
|
**Database**: Separate ArgoCD Application `vaultwarden-postgresql` (sync-wave `"0"`) deploys PostgreSQL 16 StatefulSet + SealedSecret before Vaultwarden (wave `"1"`). 2Gi PVC. Chart does NOT include a PostgreSQL subchart — must be provisioned separately.
|
||||||
|
|
||||||
|
**Secrets**:
|
||||||
|
- `prod-db-creds` (SealedSecret) — PostgreSQL credentials (`pgusername`, `pgpassword`) + SMTP credentials
|
||||||
|
- `vaultwarden-oidc-credentials` (registrar-managed) — OIDC client ID + secret
|
||||||
|
- `vaultwarden-tls` — auto-managed by cert-manager
|
||||||
|
|
||||||
|
### Chibisafe
|
||||||
|
|
||||||
|
**Chart**: `l4gdev/chibisafe`
|
||||||
|
**Version**: 0.1.1 (app latest)
|
||||||
|
**Namespace**: `chibisafe`
|
||||||
|
|
||||||
|
**Purpose**: Self-hosted file upload and sharing service.
|
||||||
|
|
||||||
|
**Configuration**:
|
||||||
|
```yaml
|
||||||
|
# infra/overlays/upc-dev/chibisafe/ + infra/values/
|
||||||
|
ingress:
|
||||||
|
enabled: true
|
||||||
|
className: "traefik"
|
||||||
|
hosts:
|
||||||
|
- host: chibisafe.forteapps.net
|
||||||
|
paths:
|
||||||
|
- path: /
|
||||||
|
pathType: Prefix
|
||||||
|
tls:
|
||||||
|
- secretName: chibisafe-tls
|
||||||
|
hosts:
|
||||||
|
- chibisafe.forteapps.net
|
||||||
|
|
||||||
|
persistence:
|
||||||
|
database:
|
||||||
|
enabled: true # SQLite, 1Gi
|
||||||
|
uploads:
|
||||||
|
enabled: true # User files, 10Gi
|
||||||
|
```
|
||||||
|
|
||||||
|
**Architecture**: Three-container pod — frontend (Next.js :8001), backend (API :8000), Caddy (reverse proxy :80). Auth sidecar injected via Kyverno policy (OIDC mode, port 9001).
|
||||||
|
|
||||||
|
**Ingress**: IngressRoute (not chart's built-in Ingress) targeting sidecar port 9001 directly. Chart's `ingress.enabled: false`. Separate cert-manager Certificate resource for TLS.
|
||||||
|
|
||||||
|
**Why IngressRoute**: Chart hardcodes Service `targetPort: http` → Caddy port 80. Cannot override via values. IngressRoute bypasses Service, routes directly to sidecar pod port.
|
||||||
|
|
||||||
|
**TLS**: cert-manager Certificate resource with `letsencrypt-prod` ClusterIssuer.
|
||||||
|
|
||||||
|
**Storage**: SQLite database (1Gi PVC) + uploads (10Gi PVC), both ReadWriteOnce — single replica only.
|
||||||
|
|
||||||
|
**SSO**: Keycloak OIDC via `forte` realm (client ID: `chibisafe`). Self-service client config Secret (`keycloak-client-chibisafe`) triggers registrar to create KC client and sync credentials to `chibisafe-oidc-credentials`.
|
||||||
|
|
||||||
|
**Endpoints**:
|
||||||
|
- Web UI: `https://chibisafe.forteapps.net`
|
||||||
|
|
||||||
|
**Secrets**:
|
||||||
|
- `chibisafe-tls` — auto-managed by cert-manager
|
||||||
|
- `chibisafe-oidc-credentials` (registrar-managed) — OIDC client ID + secret
|
||||||
|
|
||||||
### AI Code Review (ai-review)
|
### AI Code Review (ai-review)
|
||||||
|
|
||||||
**Type**: Gitea Actions workflow (`.gitea/workflows/ai-review.yaml`)
|
**Type**: Gitea Actions workflow (`.gitea/workflows/ai-review.yaml`)
|
||||||
@@ -1101,6 +1237,30 @@ ignore:
|
|||||||
- Check Gitea Actions tab for workflow run status and logs
|
- Check Gitea Actions tab for workflow run status and logs
|
||||||
- Monitor Anthropic usage dashboard for token consumption
|
- Monitor Anthropic usage dashboard for token consumption
|
||||||
|
|
||||||
|
### Keycloak Browser Flow (IdP Auto-Redirect)
|
||||||
|
|
||||||
|
**File**: `infra/values/base/keycloak-values.yaml` (inside `forte-realm.json`)
|
||||||
|
|
||||||
|
The realm uses a custom browser authentication flow (`browser-auto-idp`) that skips the Keycloak login page and redirects directly to the Entra ID identity provider.
|
||||||
|
|
||||||
|
**Flow executions**:
|
||||||
|
|
||||||
|
| Priority | Authenticator | Requirement | Purpose |
|
||||||
|
|----------|--------------|-------------|---------|
|
||||||
|
| 10 | `auth-cookie` | ALTERNATIVE | Reuse existing session (no redirect) |
|
||||||
|
| 20 | `identity-provider-redirector` | ALTERNATIVE | Auto-redirect to `forte-entra` IdP |
|
||||||
|
|
||||||
|
**Key fields in realm JSON**:
|
||||||
|
- `"browserFlow": "browser-auto-idp"` — overrides the default `browser` flow at realm level
|
||||||
|
- `"authenticationFlows"` — defines the custom flow with its executions
|
||||||
|
- `"authenticatorConfig"` — sets `defaultProvider: "forte-entra"` on the redirector
|
||||||
|
|
||||||
|
**Why custom flow**: The default KC browser flow shows a username/password form with an IdP button. Since all authentication is via Entra ID, the custom flow eliminates this step. The `auth-cookie` execution preserves session reuse so returning users aren't redirected again.
|
||||||
|
|
||||||
|
**Important**: The `forte-entra` identity provider must exist in Keycloak (currently configured manually in the KC admin console). If the IdP alias changes, update the `defaultProvider` value in the realm JSON.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
### Keycloak Client Registrar
|
### Keycloak Client Registrar
|
||||||
|
|
||||||
**Type**: CronJob (deployed via Keycloak Helm chart `extraDeploy`)
|
**Type**: CronJob (deployed via Keycloak Helm chart `extraDeploy`)
|
||||||
|
|||||||
21
infra/base/homepage/homepage-extra-rbac.yaml
Normal file
21
infra/base/homepage/homepage-extra-rbac.yaml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: ClusterRole
|
||||||
|
metadata:
|
||||||
|
name: homepage-services-reader
|
||||||
|
rules:
|
||||||
|
- apiGroups: [""]
|
||||||
|
resources: ["services"]
|
||||||
|
verbs: ["get", "list", "watch"]
|
||||||
|
---
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: ClusterRoleBinding
|
||||||
|
metadata:
|
||||||
|
name: homepage-services-reader
|
||||||
|
roleRef:
|
||||||
|
apiGroup: rbac.authorization.k8s.io
|
||||||
|
kind: ClusterRole
|
||||||
|
name: homepage-services-reader
|
||||||
|
subjects:
|
||||||
|
- kind: ServiceAccount
|
||||||
|
name: homepage
|
||||||
|
namespace: homepage
|
||||||
16
infra/base/homepage/homepage-widget-credentials-sealed.yaml
Normal file
16
infra/base/homepage/homepage-widget-credentials-sealed.yaml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
---
|
||||||
|
apiVersion: bitnami.com/v1alpha1
|
||||||
|
kind: SealedSecret
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: null
|
||||||
|
name: homepage-widget-credentials
|
||||||
|
namespace: homepage
|
||||||
|
spec:
|
||||||
|
encryptedData:
|
||||||
|
HOMEPAGE_VAR_GITEA_TOKEN: AgAVN1C931EQpn+sodr3CpjlhORfJVTW8aUr+pGZQb+65Pb8QLGeVGVa7Jv60gDJUX3r+93/jMrEbCOeDL6I4qCz/V35wMCxFZLnXIdkmto0W4MKt6cK8To1/OP7EhQJOGBlSuOFsrwoy+HDtvLIqmyF0nrxhTusm9/NHrw+gCVwSTPhiAX1MCuSOSRWpbXvyNphW8j7aqUaV6ixDt424Fe4alEIShYELcS3EX/VPgsf2p2bhvBRCQOh3LEprkuxSFMuPfCBk06TPTbIN4saNVm0Ke0zW/pxkVNSiIxEnKjOmpPJtacsfWN7du+nQbx276G2qvWrf+iawJVq0Z/SLikA/NUFBL6EjSRfgE3cSOri8sbxsd0AycsFGyp98EM29wE+WOQl52M/lwl02EmCivqkICSO7Jp9pM1ScbmRMa5vcnupsGbVDxhRKLqxhAskt/BXDkRzvHN31gH3YmelES3JuqNMHV0urFxmX2oOX9Pxbtv63csc+zhy1Ui5aoex7TPnLdk7kYLSAE2MSrzT6wHvVhBC5kNnDYVrLehvJrT+eNh0MOLx2wkuJmIOxRAGUyNi5DfDnP6qnvj2aefEymLuOXAIUXH8DbeBtrjsd74HX2hhIfBlPkXvhJR3ks7i5RXjK2/YYHkgJ+nJoW80S9N7ciaRy103g74TNJZt6QzzL5Vb80qZ6yQOD4G081KmTLDmhHjJVIIv9M3nLh2s0IeBV3/Z5qHZmtjN7sSaKAn4MIr5FaH9quhx
|
||||||
|
HOMEPAGE_VAR_GRAFANA_TOKEN: AgBloBlOlP+R/4VizE1CGpj0wyiwU14BemAnuUpld7OvOGc67dwfDPyponkQXjAZg3UU2cZ70A51WUAuVlAr+25Ktlf/FW2OBqj+1BJOCqMMyu+kv026yjX2aB8dKGzlTxgF8aji+j1mC8vP3vvmgI4Zf2HQAH7uFwLfeo8+QnV5EyhcExSS0xDne+VtOP9jNXbPRayry0DdyRVtaeKAiZacO+45oAJWszWOwmoMTg9FZQkLjER6Q0tyI6NnoNObsFCnh56chZTdzBOYtmPnwld1bP2FjoJDqn8AfRwbPTIj7t0eFP7WLUO7GQKpxVl+pFwJLb5xCOw2+HNtp1BhNCu7icuc0P88IlvwzkbN0lXJbYigVOzyjEo8f/al1DXPM4WaB/Nqmr7Mtt8KTRh2WMVTgiX5jsu25D0rGDvY9gqfBBqswkRhCLsG0v0EN32zXj1/52KYdmB7pk/+2lMwSaGMS11MOenHeU1Z95fGxm9f3EGF0E8xlFr4FowgsNwr+tJQqpM0bT/4mZnaQbGWtKPFizMtsfQFm+rHFcNCrGaOuecslmiIJs8lTm18KlrncsGfxNS64tVXk+LvydU0rwybvpg2rQjEWtAl1IQsaaiz96OAlYxxK1MGxN7KE6F8R4kfnWTZ5Fs1KMmd/DOIVBXyCbqXxk8pbekmaIeNSfv92JNZ0QNJWsBa2vgQ24WI2pb4XiR0BvtLpt3BVlZUcSK92SzUblWmYWVMwHYCJkEeEUV1PhYEmyiN+V/Kq5Qb
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: null
|
||||||
|
name: homepage-widget-credentials
|
||||||
|
namespace: homepage
|
||||||
43
infra/base/homepage/homepage.yaml
Normal file
43
infra/base/homepage/homepage.yaml
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
apiVersion: argoproj.io/v1alpha1
|
||||||
|
kind: Application
|
||||||
|
metadata:
|
||||||
|
name: homepage
|
||||||
|
namespace: argocd
|
||||||
|
annotations:
|
||||||
|
argocd.argoproj.io/sync-wave: "3"
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: homepage
|
||||||
|
app.kubernetes.io/part-of: platform
|
||||||
|
app.kubernetes.io/managed-by: argocd
|
||||||
|
finalizers:
|
||||||
|
- resources-finalizer.argocd.argoproj.io
|
||||||
|
spec:
|
||||||
|
project: default
|
||||||
|
|
||||||
|
sources:
|
||||||
|
- repoURL: https://jameswynn.github.io/helm-charts
|
||||||
|
chart: homepage
|
||||||
|
targetRevision: "2.1.0"
|
||||||
|
helm:
|
||||||
|
releaseName: homepage
|
||||||
|
valueFiles:
|
||||||
|
- $values/infra/values/base/homepage-values.yaml
|
||||||
|
- $values/infra/values/upc-dev/homepage-values.yaml
|
||||||
|
|
||||||
|
- repoURL: ssh://git@git.forteapps.net:2222/Forte/launchpad.git
|
||||||
|
targetRevision: HEAD
|
||||||
|
ref: values
|
||||||
|
|
||||||
|
destination:
|
||||||
|
server: https://kubernetes.default.svc
|
||||||
|
namespace: homepage
|
||||||
|
|
||||||
|
syncPolicy:
|
||||||
|
automated:
|
||||||
|
prune: true
|
||||||
|
selfHeal: true
|
||||||
|
allowEmpty: false
|
||||||
|
syncOptions:
|
||||||
|
- CreateNamespace=true
|
||||||
|
- Validate=true
|
||||||
|
- ServerSideApply=true
|
||||||
6
infra/base/homepage/kustomization.yaml
Normal file
6
infra/base/homepage/kustomization.yaml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- homepage.yaml
|
||||||
|
- homepage-widget-credentials-sealed.yaml
|
||||||
|
- homepage-extra-rbac.yaml
|
||||||
@@ -43,10 +43,6 @@ spec:
|
|||||||
- ServerSideApply=true
|
- ServerSideApply=true
|
||||||
|
|
||||||
ignoreDifferences:
|
ignoreDifferences:
|
||||||
- group: batch
|
|
||||||
kind: CronJob
|
|
||||||
jsonPointers:
|
|
||||||
- /spec/jobTemplate/spec/template/spec/containers/0/args
|
|
||||||
- group: apps
|
- group: apps
|
||||||
kind: StatefulSet
|
kind: StatefulSet
|
||||||
jsonPointers:
|
jsonPointers:
|
||||||
|
|||||||
@@ -21,3 +21,5 @@ resources:
|
|||||||
- grafana-dashboards
|
- grafana-dashboards
|
||||||
- karpor
|
- karpor
|
||||||
- databunker
|
- databunker
|
||||||
|
- homepage
|
||||||
|
- vault
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ spec:
|
|||||||
automated:
|
automated:
|
||||||
prune: true
|
prune: true
|
||||||
selfHeal: true
|
selfHeal: true
|
||||||
allowEmpty: false
|
|
||||||
syncOptions:
|
syncOptions:
|
||||||
- CreateNamespace=true
|
- CreateNamespace=true
|
||||||
- Validate=true
|
- Validate=true
|
||||||
|
|||||||
4
infra/base/vault/kustomization.yaml
Normal file
4
infra/base/vault/kustomization.yaml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- vault.yaml
|
||||||
49
infra/base/vault/vault.yaml
Normal file
49
infra/base/vault/vault.yaml
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
apiVersion: argoproj.io/v1alpha1
|
||||||
|
kind: Application
|
||||||
|
metadata:
|
||||||
|
name: vault
|
||||||
|
namespace: argocd
|
||||||
|
annotations:
|
||||||
|
argocd.argoproj.io/sync-wave: "1"
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: vault
|
||||||
|
app.kubernetes.io/part-of: security
|
||||||
|
app.kubernetes.io/managed-by: argocd
|
||||||
|
finalizers:
|
||||||
|
- resources-finalizer.argocd.argoproj.io
|
||||||
|
spec:
|
||||||
|
project: default
|
||||||
|
|
||||||
|
sources:
|
||||||
|
- repoURL: https://helm.releases.hashicorp.com
|
||||||
|
chart: vault
|
||||||
|
targetRevision: "0.32.0"
|
||||||
|
helm:
|
||||||
|
releaseName: vault
|
||||||
|
valueFiles:
|
||||||
|
- $values/infra/values/base/vault-values.yaml
|
||||||
|
- $values/infra/values/upc-dev/vault-values.yaml
|
||||||
|
|
||||||
|
- repoURL: ssh://git@git.forteapps.net:2222/Forte/launchpad.git
|
||||||
|
targetRevision: HEAD
|
||||||
|
ref: values
|
||||||
|
|
||||||
|
destination:
|
||||||
|
server: https://kubernetes.default.svc
|
||||||
|
namespace: vault
|
||||||
|
|
||||||
|
syncPolicy:
|
||||||
|
automated:
|
||||||
|
prune: true
|
||||||
|
selfHeal: true
|
||||||
|
allowEmpty: false
|
||||||
|
syncOptions:
|
||||||
|
- CreateNamespace=true
|
||||||
|
- Validate=true
|
||||||
|
- ServerSideApply=true
|
||||||
|
|
||||||
|
ignoreDifferences:
|
||||||
|
- group: apps
|
||||||
|
kind: StatefulSet
|
||||||
|
jsonPointers:
|
||||||
|
- /spec/volumeClaimTemplates
|
||||||
@@ -13,9 +13,19 @@ resources:
|
|||||||
- ../../base/prometheus
|
- ../../base/prometheus
|
||||||
- ../../base/sealedsecrets
|
- ../../base/sealedsecrets
|
||||||
- ../../base/tempo
|
- ../../base/tempo
|
||||||
|
- ../../base/homepage
|
||||||
- ../../base/traefik-application
|
- ../../base/traefik-application
|
||||||
|
|
||||||
patches:
|
patches:
|
||||||
|
# Homepage: swap upc-dev → aks-dev
|
||||||
|
- target:
|
||||||
|
kind: Application
|
||||||
|
name: homepage
|
||||||
|
patch: |
|
||||||
|
- op: replace
|
||||||
|
path: /spec/sources/0/helm/valueFiles/1
|
||||||
|
value: $values/infra/values/aks-dev/homepage-values.yaml
|
||||||
|
|
||||||
# Traefik: swap upc-dev → aks-dev
|
# Traefik: swap upc-dev → aks-dev
|
||||||
- target:
|
- target:
|
||||||
kind: Application
|
kind: Application
|
||||||
|
|||||||
8
infra/overlays/upc-dev/chibisafe/auth-oidc-secret.yaml
Normal file
8
infra/overlays/upc-dev/chibisafe/auth-oidc-secret.yaml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
name: auth-oidc
|
||||||
|
namespace: chibisafe
|
||||||
|
type: Opaque
|
||||||
|
stringData:
|
||||||
|
cookie-secret: "gtwkoUMSp1wJa2o5Fo5CNByR8+kTocJOOuywuLexRO4="
|
||||||
43
infra/overlays/upc-dev/chibisafe/chibisafe.yaml
Normal file
43
infra/overlays/upc-dev/chibisafe/chibisafe.yaml
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
apiVersion: argoproj.io/v1alpha1
|
||||||
|
kind: Application
|
||||||
|
metadata:
|
||||||
|
name: chibisafe
|
||||||
|
namespace: argocd
|
||||||
|
annotations:
|
||||||
|
argocd.argoproj.io/sync-wave: "1"
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: chibisafe
|
||||||
|
app.kubernetes.io/part-of: storage
|
||||||
|
app.kubernetes.io/managed-by: argocd
|
||||||
|
finalizers:
|
||||||
|
- resources-finalizer.argocd.argoproj.io
|
||||||
|
spec:
|
||||||
|
project: default
|
||||||
|
|
||||||
|
sources:
|
||||||
|
- repoURL: https://l4gdev.github.io/helm-charts
|
||||||
|
chart: chibisafe
|
||||||
|
targetRevision: "0.1.1"
|
||||||
|
helm:
|
||||||
|
releaseName: chibisafe
|
||||||
|
valueFiles:
|
||||||
|
- $values/infra/values/base/chibisafe-values.yaml
|
||||||
|
- $values/infra/values/upc-dev/chibisafe-values.yaml
|
||||||
|
|
||||||
|
- repoURL: ssh://git@git.forteapps.net:2222/Forte/launchpad.git
|
||||||
|
targetRevision: HEAD
|
||||||
|
ref: values
|
||||||
|
|
||||||
|
destination:
|
||||||
|
server: https://kubernetes.default.svc
|
||||||
|
namespace: chibisafe
|
||||||
|
|
||||||
|
syncPolicy:
|
||||||
|
automated:
|
||||||
|
prune: true
|
||||||
|
selfHeal: true
|
||||||
|
allowEmpty: false
|
||||||
|
syncOptions:
|
||||||
|
- CreateNamespace=true
|
||||||
|
- Validate=true
|
||||||
|
- ServerSideApply=true
|
||||||
36
infra/overlays/upc-dev/chibisafe/ingressroute.yaml
Normal file
36
infra/overlays/upc-dev/chibisafe/ingressroute.yaml
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
apiVersion: cert-manager.io/v1
|
||||||
|
kind: Certificate
|
||||||
|
metadata:
|
||||||
|
name: chibisafe-tls
|
||||||
|
namespace: chibisafe
|
||||||
|
spec:
|
||||||
|
secretName: chibisafe-tls
|
||||||
|
issuerRef:
|
||||||
|
name: letsencrypt-prod
|
||||||
|
kind: ClusterIssuer
|
||||||
|
dnsNames:
|
||||||
|
- chibisafe.forteapps.net
|
||||||
|
---
|
||||||
|
apiVersion: traefik.io/v1alpha1
|
||||||
|
kind: IngressRoute
|
||||||
|
metadata:
|
||||||
|
name: chibisafe
|
||||||
|
namespace: chibisafe
|
||||||
|
annotations:
|
||||||
|
gethomepage.dev/enabled: "false"
|
||||||
|
gethomepage.dev/name: "Chibisafe"
|
||||||
|
gethomepage.dev/description: "File upload & sharing"
|
||||||
|
gethomepage.dev/group: "Storage"
|
||||||
|
gethomepage.dev/icon: "chibisafe"
|
||||||
|
gethomepage.dev/href: "https://chibisafe.forteapps.net"
|
||||||
|
spec:
|
||||||
|
entryPoints:
|
||||||
|
- websecure
|
||||||
|
routes:
|
||||||
|
- match: Host(`chibisafe.forteapps.net`)
|
||||||
|
kind: Rule
|
||||||
|
services:
|
||||||
|
- name: chibisafe
|
||||||
|
port: 9001
|
||||||
|
tls:
|
||||||
|
secretName: chibisafe-tls
|
||||||
21
infra/overlays/upc-dev/chibisafe/keycloak-client-config.yaml
Normal file
21
infra/overlays/upc-dev/chibisafe/keycloak-client-config.yaml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
name: keycloak-client-chibisafe
|
||||||
|
namespace: chibisafe
|
||||||
|
labels:
|
||||||
|
keycloak.forteapps.net/client-config: "true"
|
||||||
|
stringData:
|
||||||
|
client.json: |
|
||||||
|
{
|
||||||
|
"clientId": "chibisafe",
|
||||||
|
"name": "Chibisafe",
|
||||||
|
"redirectUris": ["https://chibisafe.forteapps.net/*"],
|
||||||
|
"webOrigins": ["https://chibisafe.forteapps.net"],
|
||||||
|
"protocolMappers": [],
|
||||||
|
"secret": {
|
||||||
|
"namespace": "chibisafe",
|
||||||
|
"name": "chibisafe-oidc-credentials",
|
||||||
|
"keys": { "clientId": "client-id", "clientSecret": "client-secret" }
|
||||||
|
}
|
||||||
|
}
|
||||||
7
infra/overlays/upc-dev/chibisafe/kustomization.yaml
Normal file
7
infra/overlays/upc-dev/chibisafe/kustomization.yaml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- chibisafe.yaml
|
||||||
|
- keycloak-client-config.yaml
|
||||||
|
- ingressroute.yaml
|
||||||
|
- auth-oidc-secret.yaml
|
||||||
@@ -2,6 +2,9 @@ apiVersion: kustomize.config.k8s.io/v1beta1
|
|||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
resources:
|
resources:
|
||||||
- ../../base
|
- ../../base
|
||||||
|
- chibisafe
|
||||||
|
- vaultwarden-postgresql
|
||||||
|
- vaultwarden
|
||||||
|
|
||||||
# No patches needed — base already has "upc-dev" paths
|
# No patches needed — base already has "upc-dev" paths
|
||||||
# upc-dev is the default/base cluster
|
# upc-dev is the default/base cluster
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- vaultwarden-postgresql.yaml
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- postgresql.yaml
|
||||||
|
- vaultwarden-db-secret-sealed.yaml
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: vaultwarden-postgresql
|
||||||
|
namespace: vaultwarden
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: postgresql
|
||||||
|
app.kubernetes.io/instance: vaultwarden
|
||||||
|
app.kubernetes.io/component: database
|
||||||
|
spec:
|
||||||
|
type: ClusterIP
|
||||||
|
ports:
|
||||||
|
- name: tcp-postgresql
|
||||||
|
port: 5432
|
||||||
|
targetPort: tcp-postgresql
|
||||||
|
selector:
|
||||||
|
app.kubernetes.io/name: postgresql
|
||||||
|
app.kubernetes.io/instance: vaultwarden
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: StatefulSet
|
||||||
|
metadata:
|
||||||
|
name: vaultwarden-postgresql
|
||||||
|
namespace: vaultwarden
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: postgresql
|
||||||
|
app.kubernetes.io/instance: vaultwarden
|
||||||
|
app.kubernetes.io/component: database
|
||||||
|
spec:
|
||||||
|
serviceName: vaultwarden-postgresql
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app.kubernetes.io/name: postgresql
|
||||||
|
app.kubernetes.io/instance: vaultwarden
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: postgresql
|
||||||
|
app.kubernetes.io/instance: vaultwarden
|
||||||
|
app.kubernetes.io/component: database
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: postgresql
|
||||||
|
image: postgres:16-alpine
|
||||||
|
ports:
|
||||||
|
- name: tcp-postgresql
|
||||||
|
containerPort: 5432
|
||||||
|
env:
|
||||||
|
- name: POSTGRES_USER
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: prod-db-creds
|
||||||
|
key: pgusername
|
||||||
|
- name: POSTGRES_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: prod-db-creds
|
||||||
|
key: pgpassword
|
||||||
|
- name: POSTGRES_DB
|
||||||
|
value: vaultwarden
|
||||||
|
- name: PGDATA
|
||||||
|
value: /var/lib/postgresql/data/pgdata
|
||||||
|
volumeMounts:
|
||||||
|
- name: data
|
||||||
|
mountPath: /var/lib/postgresql/data
|
||||||
|
livenessProbe:
|
||||||
|
exec:
|
||||||
|
command:
|
||||||
|
- sh
|
||||||
|
- -c
|
||||||
|
- pg_isready -U "$POSTGRES_USER" -d vaultwarden
|
||||||
|
initialDelaySeconds: 30
|
||||||
|
periodSeconds: 10
|
||||||
|
readinessProbe:
|
||||||
|
exec:
|
||||||
|
command:
|
||||||
|
- sh
|
||||||
|
- -c
|
||||||
|
- pg_isready -U "$POSTGRES_USER" -d vaultwarden
|
||||||
|
initialDelaySeconds: 5
|
||||||
|
periodSeconds: 5
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 100m
|
||||||
|
memory: 256Mi
|
||||||
|
limits:
|
||||||
|
cpu: 500m
|
||||||
|
memory: 512Mi
|
||||||
|
volumeClaimTemplates:
|
||||||
|
- metadata:
|
||||||
|
name: data
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 2Gi
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
apiVersion: bitnami.com/v1alpha1
|
||||||
|
kind: SealedSecret
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: null
|
||||||
|
name: prod-db-creds
|
||||||
|
namespace: vaultwarden
|
||||||
|
spec:
|
||||||
|
encryptedData:
|
||||||
|
DATABASE_URL: AgAy1d//kBevUqZxB5KAXd+qxm8QykNxp5J1QP7Y30XCpE8hldPXF+NIx3w0B0PUyMAVsa+JrBmCMtzgibddIJqqF2upu/8EYxJZNusrJPOi47g3VcZIg1WyxoFfffH6jwhzv69TE/T8WGBXmWbD2vr+XWjE24Q+lgwLut0mocVfihUjpuYq0WDjgJx7pqLnY1VatTwgSkAv1uRRVqdi7e1M5isDNEpdItCbEoWwdvZhG5JIMAA/2vecY4/vEne3cg46lJAkv4ueZNATG6DOXGgQgz6h7zCKSGS1xTfGr+4A2V2/vSYpQ/r8Td37mlseoBvwN4H5O+FgHrVREm7N6aafDariYd+ZfqUIGObsZIXhxhDmAM96pjtP8ehYVwq1srWTU+SUewEmwLFWhVP1UFnTB5vgIuOWoKjHlS7dSUpStpw2u7/mQ6vhRhEaDqY6cNzJgM9hipQM/pt5an7z4ovWVeAeK8InGzKU+uxOpv/oxmi9N54B+5O4DVZC+BIbFXchxDvqivRcZrTK+CNjHjkk4We5MvN0qlhSuCYOGzEVaQ192yHciDoncw58D7fG4NicT2AcCJDVIwRGG05wqKal7g61g7Qg16oqdZIauKIU7ChSgBk7Xv33biZ4ZPe+JoSEmp9izJ8R7yyNO3KJgqH7iQ2UQzXDUqhfTr6w/oIdFST8sQtEIo7o1Z5JoXpzd4R1gVkcPWqtbbB22iRrDJsofeW+yvgGqyZLsWT2bKuDMLUn3GiqvaHaeQ9AbhNBnl6Qth3X8heBm2Zle1xxapFktisPwBQC7FDlukgvkiAOO7BywVI0+ITU4KLLOAftVqHmZ4fgDDqNFg8=
|
||||||
|
SMTP_PASSWORD: AgCbhM99+DbSTCcuxtcccOrZq99GjR51B5SkW6DNxz1jW2q4lgc6o21+gHEGGAamRDg/mWyu2UBBNgEzrW024558qP6SjVPwJclWhNZHyL4R4MCA0kv/kqNa43na2j3pq7kzT0MrqPAXD8IJrtYPxr+ngiuo7MCRef/TzEfwbwK+KgkeB1g+9ErwHWr5tU1B+3yAn5tfNeHmGFrLX230mra2ie+ntNx9kn80mb5TYoJ/mSaX7wv4bqZGEHkg7isXrMoMROXLBepCvP0zi3ta+SKJjHy73TvhKSzo7/ZHxapHw3oaazdpKJobeolWB7SziWsbXfT0gYYim3LrcieQeb7hhN3OAvSYx1Z/3UefEE1o3GFEzK1UV9ISwU/mBjMDZWyM7dK9lSbuPGvbpKU1jjP8qZWQP5v2SIT6Nb5TQgNeATdO3RkjoviqRzjJfpuu+oe5paXNeEIUSTskL7HuUjWj13DX1zDqQWTR1/Tb9ntxRtgIoAl2ymDsOednurnJeX71OJ3G++Oc8b5P2EkNQuEwaYb9raNHqZkCXeRpQVyEGIUh9sAGZUplUJSues/Jw25WuFoNBfMi/F022Mkvfnp/s0J+QrMIxSRvqiWS+7hODknvE3Zf2DI+DKClWxspfv084DAkOSV1Lq9fqNy/bKoJR/5MVHmxbW6teza6zXBnwn2nk+2DZ8IU20P15aVdtKR2zG9u8hnrqWrTQHTdvzb34WKjC0km4/MaIGKvboyw
|
||||||
|
SMTP_USERNAME: AgCijAuSvlGeMME1FyPXQdOTGKktyXfT8tjBK/ozt3X8O5hebFVvM61hNLDQTe9V/O/NLw6P1wbV4V+wtztqLs9TPDyq9L3D9JUEDjh97gWxVf7nFf8/d24F0PJoR8srKp3onb7+Rx02318RUp+gp7YsXbK6YBfkaOsoD08UgrFY3ARnP4eIirRICNCdouPgKkh038yAWcQDA20GBN2faJlQSejS4cr8WAa/ME1fRe40Q4tewgiX7hK5BWjt2eoovLrPzcHvbgTbfjwUWvmeiSicnF+VLrc3M56aKML2xuAggBk4vKtla/Af1pJfjv+Ut2z6VzECfIth12yQa6kIvKOE8aa3o/6oKLRJQRO8rQOOmLiInR+jQxrOmYw+OzkON07nBIeBon7nKYSIMiBt68kXKWJ9ZDexF7WGOHsFgUo4hA/z/c/Ccg6XHgxFt7uXZYLyziihQXy33zIsvu0rXOaczT5j3NJIhO60jz2Q8ig9JuWhd7+Dnd9EFMC0WJOM9kjpxeSjg4MYjH7VGnnEDF2GAQTlwDn5HwZJXRQFHfdCiHS5CCpfmak9MtIC9uoIsbPAnEhdTC20wDvIGlR5O4JGlQRyirKKmCdT1MJt8zi5d+EVQiicVZLGGD6nsqCNchvFYcx+glMYqWWsmyS6M+uVaYa/Fb/n+0QR6GNCF3Qi7voMJf2bFxFDk78fk76MG919XPQVAG/FPliNyWJJ7gEM+j/rDYuSrul14duV
|
||||||
|
adminToken: AgCVSgRK39WksTX6GogBvMZtPMd4XzMFkKSPhjTCm8pllzuc88pS2LXHxyGDWVLf+GZXRTCNrf5JLPst8/GTvOX17J9scRAjmhoyVVgzFNbcqGI/czLf9vH6JnhorMmUHxS+kWBm3oLZjhW3f/9vq0xzSbut87VDsyenaK4EcFLrYnfVRlMrwxL9oxPPTeB+Wah/uGoyLNfc7MMLK+/sUma4RO61VJ8YvmLUnwYNFosUcbF2B9hXMSzKKCJ+ihXYIdNIz2YWdMmj7a3D+Mor5x4jIjC+tunT4Zge5L1mx0i92KPgPkP48jKxayIZ/FxnYej+ggU6PmdYD1B6wgUbgLQV6ccwysjHce7ICvGWiM+PozFWI1qEVKqtNgp3kwInThD63Hyub9Euj0g/SE/nZcwy8DuIEhsLpLSdvxDT2lCps0VdXcb01kuta/3i4vgozSBvdIL1FrQKPLqF5+6ZEQ6BdZDkgxVqQ845WZoGbfqIyI03BMvsx/8HB5c+0Y0w0C6DRpEW55T9yRTZqzvqWUOpXy5/L2Nc9G4PCUK3lY0QPIFlPCBDl+cKgfP/XvKhMFcFpwp/Ssd0o+RhgOMBHJ5qk7RxAN1k2Y6Tkros39eUKWbM6UQ97LjrAdLcgJKX86ZkEChdeeKOnSxRmqHFXx5m4Wa6syixjipeQPwybCYQA9TgNBv0lToA7gi+lcVvXkoAgYIeB9Cp0j8UVEwdgvwWp8YgkpuWhPCAafhboH8qGhHhVfKADmlB05vUItZ0eoEVv7D9SqUTFueUmoZXwo67uyMLZhQo7eGr9+k8hiesCoEm11HCTa4DvF9zE54zgkyt0TMsKAEKmX47zJwnw76zidZC/K9e
|
||||||
|
pgpassword: AgCeQLwzajVBHW+o1ZSAcfbcJXny5K7UxxMfjud0j3hm9qx3TlLaFJrNoWd4XCuHAW1Ybl23ynWm+8kpXfZv95bXGkl0jZIm989MlAJQYKcaSTdhIM6Bkl3Cbr8kTVj2yrylGPJ96QISKNoiV7IetU82t8f21kxjyrNwt4lQEwWRFjW45jozb32qFXRkTioJ1WKaeJkyRSHWn7nLVitqZ4QjZzoN9AC7cUDOY/FffEiz7QRYSf6xaVPqQfCeH6QVtfmwtU5qNTcthOW0+/LQKpkg8i2nuoAsyOe7tsOYCENbDGkLckNTns2oPvDnH5eA8F5VDlnyJtROlwKjWfTC2zjazZynpA6cBH9XzX3Pg9P45G5HJ/4TVSUbTMCSVrbW8Ec+zdA2P4l3ytfVM2ER4N2/bQrUEVW2/ngDzhsKllmOPEN/M7b/VTed7U1xyJHsoT+AJEqVJO/vFBRxpI/ZacD+m5kWf3sp1SUWSgkUi+YWH8xuRurM2/kiUGwwUXu5ZMumjpMTkJBfX4NYRezq0DCsgaXdO2yI4xTfAysj78UikdU0PKyAXPcT8y55kJQ1jECszFauyeSYh0FpLu/XAmeB8dunlBqgISLszwnnman0/ThLeo96MFo6WPXoAeMTy8+GfTSH5tkmm8TVD7A+gRHprfFS66eY5Zi38OPU+VGRJS1J8yLSD2cNvCFR/sz1Br9VV7IySx1S+HvbEd7BwmdWrIoEcVUwIAD/U0Uxbw4sr7wLQ2wFQjDil4VItA==
|
||||||
|
pgusername: AgAcgel8GpdRVThE9i4EfFwcJYHEPnCyi4jHEaAltn4VMtub6hvhtH+ihxS97AhK6kgrTLEgtlfb07n1EZ3AK18A+ci9P5ulP0GgwMrMt1yxiHliqInvZPNb8vWC/2f2lZm7EFrBvYqMFRPV10YygtkW3Kku8h31l0xc2/DUKqZ2hMymIjx7hupabUOhnPJeF+IxVhTcsAa6SjhppX1ED0R/Im73pxTxbfLQETkHd5KcB4h6RLIPvuNiG5uftkPP8qjJqFIhNew+0IxMrsTzJbyLx90vqI6LHHtsrNDAsOHqWGnyZqIdkK+Bagm84VlpBfIdz8Fs0YqzBQaZts4+QXByzkcQZBDy11Hg9FCjdUVk3VgVLDQj+hL+aWTeJ0Iui4zW4LMSB0Dk0ZQeQa4BtwuDllky5GUA7sLmkbceAWymBNzNXSOeeAi1qfR6h6rNnh0x5yOnSN8soReNaCEYBSa8HjUamvuzu4yn+fKOJyI50QEJ7hKLXLaqyiNpa5bJw4FQvGM7qESkZW2BZLEvkq4mlKjzvSm891DozA44Zy1s/3CvytFsUtaWmquSvqqHWUxqEEemJ8zOCFXEYo1TjEfkYIUipM5KJ+PrpQGTgjdnL8FbAv3r3NG7DoucQtVeJJVeaBqOZcfEQw4Xz15grsdjggFunhmz+ZjWjgEwV4G/dCmeus3SBWJWLMOoPWCvBWrQZRQq9KVj
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: null
|
||||||
|
name: prod-db-creds
|
||||||
|
namespace: vaultwarden
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: vaultwarden
|
||||||
|
---
|
||||||
|
|
||||||
|
apiVersion: argoproj.io/v1alpha1
|
||||||
|
kind: Application
|
||||||
|
metadata:
|
||||||
|
name: vaultwarden-postgresql
|
||||||
|
namespace: argocd
|
||||||
|
annotations:
|
||||||
|
argocd.argoproj.io/sync-wave: "0"
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: vaultwarden-postgresql
|
||||||
|
app.kubernetes.io/part-of: security
|
||||||
|
app.kubernetes.io/managed-by: argocd
|
||||||
|
finalizers:
|
||||||
|
- resources-finalizer.argocd.argoproj.io
|
||||||
|
spec:
|
||||||
|
project: default
|
||||||
|
|
||||||
|
source:
|
||||||
|
repoURL: ssh://git@git.forteapps.net:2222/Forte/launchpad.git
|
||||||
|
targetRevision: HEAD
|
||||||
|
path: infra/overlays/upc-dev/vaultwarden-postgresql/resources
|
||||||
|
|
||||||
|
destination:
|
||||||
|
server: https://kubernetes.default.svc
|
||||||
|
namespace: vaultwarden
|
||||||
|
|
||||||
|
syncPolicy:
|
||||||
|
automated:
|
||||||
|
prune: true
|
||||||
|
selfHeal: true
|
||||||
|
allowEmpty: false
|
||||||
|
syncOptions:
|
||||||
|
- CreateNamespace=true
|
||||||
|
- Validate=true
|
||||||
|
- ServerSideApply=true
|
||||||
|
|
||||||
|
ignoreDifferences:
|
||||||
|
- group: apps
|
||||||
|
kind: StatefulSet
|
||||||
|
jsonPointers:
|
||||||
|
- /spec/volumeClaimTemplates
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
name: keycloak-client-vaultwarden
|
||||||
|
namespace: vaultwarden
|
||||||
|
labels:
|
||||||
|
keycloak.forteapps.net/client-config: "true"
|
||||||
|
stringData:
|
||||||
|
client.json: |
|
||||||
|
{
|
||||||
|
"clientId": "vaultwarden",
|
||||||
|
"name": "Vaultwarden",
|
||||||
|
"redirectUris": ["https://vaultwarden.forteapps.net/*"],
|
||||||
|
"webOrigins": ["https://vaultwarden.forteapps.net"],
|
||||||
|
"protocolMappers": [],
|
||||||
|
"secret": {
|
||||||
|
"namespace": "vaultwarden",
|
||||||
|
"name": "vaultwarden-oidc-credentials",
|
||||||
|
"keys": { "clientId": "client-id", "clientSecret": "client-secret" }
|
||||||
|
}
|
||||||
|
}
|
||||||
5
infra/overlays/upc-dev/vaultwarden/kustomization.yaml
Normal file
5
infra/overlays/upc-dev/vaultwarden/kustomization.yaml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- vaultwarden.yaml
|
||||||
|
- keycloak-client-config.yaml
|
||||||
43
infra/overlays/upc-dev/vaultwarden/vaultwarden.yaml
Normal file
43
infra/overlays/upc-dev/vaultwarden/vaultwarden.yaml
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
apiVersion: argoproj.io/v1alpha1
|
||||||
|
kind: Application
|
||||||
|
metadata:
|
||||||
|
name: vaultwarden
|
||||||
|
namespace: argocd
|
||||||
|
annotations:
|
||||||
|
argocd.argoproj.io/sync-wave: "1"
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: vaultwarden
|
||||||
|
app.kubernetes.io/part-of: security
|
||||||
|
app.kubernetes.io/managed-by: argocd
|
||||||
|
finalizers:
|
||||||
|
- resources-finalizer.argocd.argoproj.io
|
||||||
|
spec:
|
||||||
|
project: default
|
||||||
|
|
||||||
|
sources:
|
||||||
|
- repoURL: https://guerzon.github.io/vaultwarden
|
||||||
|
chart: vaultwarden
|
||||||
|
targetRevision: "0.36.4"
|
||||||
|
helm:
|
||||||
|
releaseName: vaultwarden
|
||||||
|
valueFiles:
|
||||||
|
- $values/infra/values/base/vaultwarden-values.yaml
|
||||||
|
- $values/infra/values/upc-dev/vaultwarden-values.yaml
|
||||||
|
|
||||||
|
- repoURL: ssh://git@git.forteapps.net:2222/Forte/launchpad.git
|
||||||
|
targetRevision: HEAD
|
||||||
|
ref: values
|
||||||
|
|
||||||
|
destination:
|
||||||
|
server: https://kubernetes.default.svc
|
||||||
|
namespace: vaultwarden
|
||||||
|
|
||||||
|
syncPolicy:
|
||||||
|
automated:
|
||||||
|
prune: true
|
||||||
|
selfHeal: true
|
||||||
|
allowEmpty: false
|
||||||
|
syncOptions:
|
||||||
|
- CreateNamespace=true
|
||||||
|
- Validate=true
|
||||||
|
- ServerSideApply=true
|
||||||
15
infra/values/aks-dev/homepage-values.yaml
Normal file
15
infra/values/aks-dev/homepage-values.yaml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
ingress:
|
||||||
|
main:
|
||||||
|
enabled: true
|
||||||
|
ingressClassName: traefik
|
||||||
|
annotations:
|
||||||
|
cert-manager.io/cluster-issuer: letsencrypt-prod
|
||||||
|
hosts:
|
||||||
|
- host: start.forteapps.net
|
||||||
|
paths:
|
||||||
|
- path: /
|
||||||
|
pathType: Prefix
|
||||||
|
tls:
|
||||||
|
- secretName: homepage-tls
|
||||||
|
hosts:
|
||||||
|
- start.forteapps.net
|
||||||
@@ -35,6 +35,12 @@ server:
|
|||||||
ingressClassName: traefik
|
ingressClassName: traefik
|
||||||
annotations:
|
annotations:
|
||||||
cert-manager.io/cluster-issuer: letsencrypt-prod
|
cert-manager.io/cluster-issuer: letsencrypt-prod
|
||||||
|
gethomepage.dev/enabled: "true"
|
||||||
|
gethomepage.dev/name: "ArgoCD"
|
||||||
|
gethomepage.dev/description: "GitOps continuous delivery"
|
||||||
|
gethomepage.dev/group: "DevOps"
|
||||||
|
gethomepage.dev/icon: "argo-cd"
|
||||||
|
gethomepage.dev/href: "https://argocd.forteapps.net"
|
||||||
tls: true
|
tls: true
|
||||||
extraArgs:
|
extraArgs:
|
||||||
- --insecure
|
- --insecure
|
||||||
|
|||||||
45
infra/values/base/chibisafe-values.yaml
Normal file
45
infra/values/base/chibisafe-values.yaml
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
replicaCount: 1
|
||||||
|
|
||||||
|
frontend:
|
||||||
|
image:
|
||||||
|
repository: chibisafe/chibisafe
|
||||||
|
tag: "latest"
|
||||||
|
pullPolicy: IfNotPresent
|
||||||
|
|
||||||
|
backend:
|
||||||
|
image:
|
||||||
|
repository: chibisafe/chibisafe-server
|
||||||
|
tag: "latest"
|
||||||
|
pullPolicy: IfNotPresent
|
||||||
|
|
||||||
|
caddy:
|
||||||
|
image:
|
||||||
|
repository: caddy
|
||||||
|
tag: "2-alpine"
|
||||||
|
pullPolicy: IfNotPresent
|
||||||
|
|
||||||
|
persistence:
|
||||||
|
database:
|
||||||
|
enabled: true
|
||||||
|
size: 1Gi
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
|
||||||
|
uploads:
|
||||||
|
enabled: true
|
||||||
|
size: 10Gi
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
|
||||||
|
logs:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
service:
|
||||||
|
type: ClusterIP
|
||||||
|
port: 80
|
||||||
|
|
||||||
|
networkPolicy:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
podDisruptionBudget:
|
||||||
|
enabled: false
|
||||||
@@ -41,6 +41,7 @@ gitea:
|
|||||||
oauth2:
|
oauth2:
|
||||||
ENABLED: true
|
ENABLED: true
|
||||||
ENABLE_AUTO_REGISTRATION: true
|
ENABLE_AUTO_REGISTRATION: true
|
||||||
|
ACCOUNT_LINKING: auto
|
||||||
USERNAME: email
|
USERNAME: email
|
||||||
|
|
||||||
session:
|
session:
|
||||||
@@ -114,6 +115,15 @@ ingress:
|
|||||||
className: traefik
|
className: traefik
|
||||||
annotations:
|
annotations:
|
||||||
cert-manager.io/cluster-issuer: letsencrypt-prod
|
cert-manager.io/cluster-issuer: letsencrypt-prod
|
||||||
|
gethomepage.dev/enabled: "true"
|
||||||
|
gethomepage.dev/name: "Gitea"
|
||||||
|
gethomepage.dev/description: "Git hosting & CI/CD"
|
||||||
|
gethomepage.dev/group: "DevOps"
|
||||||
|
gethomepage.dev/icon: "gitea"
|
||||||
|
gethomepage.dev/href: "https://git.forteapps.net"
|
||||||
|
gethomepage.dev/widget.type: "gitea"
|
||||||
|
gethomepage.dev/widget.url: "https://git.forteapps.net"
|
||||||
|
gethomepage.dev/widget.key: "{{HOMEPAGE_VAR_GITEA_TOKEN}}"
|
||||||
hosts:
|
hosts:
|
||||||
- host: git.forteapps.net
|
- host: git.forteapps.net
|
||||||
paths:
|
paths:
|
||||||
|
|||||||
@@ -3,11 +3,21 @@ ingress:
|
|||||||
ingressClassName: traefik
|
ingressClassName: traefik
|
||||||
annotations:
|
annotations:
|
||||||
cert-manager.io/cluster-issuer: letsencrypt-prod
|
cert-manager.io/cluster-issuer: letsencrypt-prod
|
||||||
|
gethomepage.dev/enabled: "true"
|
||||||
|
gethomepage.dev/name: "Grafana"
|
||||||
|
gethomepage.dev/description: "Metrics & observability dashboards"
|
||||||
|
gethomepage.dev/group: "Monitoring"
|
||||||
|
gethomepage.dev/icon: "grafana"
|
||||||
|
gethomepage.dev/href: "https://grafana.forteapps.net"
|
||||||
tls:
|
tls:
|
||||||
- secretName: grafana-tls
|
- secretName: grafana-tls
|
||||||
hosts:
|
hosts:
|
||||||
- grafana.forteapps.net
|
- grafana.forteapps.net
|
||||||
|
|
||||||
|
persistence:
|
||||||
|
enabled: true
|
||||||
|
size: 1Gi
|
||||||
|
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
cpu: 50m
|
cpu: 50m
|
||||||
|
|||||||
72
infra/values/base/homepage-values.yaml
Normal file
72
infra/values/base/homepage-values.yaml
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
# Homepage Helm Values
|
||||||
|
# Chart: jameswynn/homepage — https://gethomepage.dev
|
||||||
|
# Discovery: K8s service annotations (gethomepage.dev/*)
|
||||||
|
# Each deployed app annotates its own Service — apps not deployed = not visible.
|
||||||
|
|
||||||
|
# RBAC ClusterRole — required for cluster-wide service annotation scanning
|
||||||
|
enableRbac: true
|
||||||
|
|
||||||
|
serviceAccount:
|
||||||
|
create: true
|
||||||
|
name: homepage
|
||||||
|
|
||||||
|
config:
|
||||||
|
# Scan all namespaces for services with gethomepage.dev/enabled: "true"
|
||||||
|
kubernetes:
|
||||||
|
mode: cluster
|
||||||
|
traefik: true
|
||||||
|
|
||||||
|
settings:
|
||||||
|
title: "Platform"
|
||||||
|
headerStyle: clean
|
||||||
|
layout:
|
||||||
|
Apps:
|
||||||
|
style: row
|
||||||
|
columns: 3
|
||||||
|
Security:
|
||||||
|
style: row
|
||||||
|
columns: 3
|
||||||
|
Tools:
|
||||||
|
style: row
|
||||||
|
header: false
|
||||||
|
columns: 2
|
||||||
|
DevOps:
|
||||||
|
style: column
|
||||||
|
rows: 2
|
||||||
|
Monitoring:
|
||||||
|
style: column
|
||||||
|
rows: 1
|
||||||
|
|
||||||
|
# Top-of-page cluster overview widget
|
||||||
|
widgets:
|
||||||
|
- kubernetes:
|
||||||
|
cluster:
|
||||||
|
show: true
|
||||||
|
cpu: true
|
||||||
|
memory: true
|
||||||
|
showLabel: true
|
||||||
|
label: "Cluster"
|
||||||
|
nodes:
|
||||||
|
show: true
|
||||||
|
cpu: true
|
||||||
|
memory: true
|
||||||
|
showLabel: true
|
||||||
|
# In-cluster entries come from K8s service annotations.
|
||||||
|
# External (out-of-cluster) services are listed here statically.
|
||||||
|
bookmarks: []
|
||||||
|
services: []
|
||||||
|
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 10m
|
||||||
|
memory: 128Mi
|
||||||
|
limits:
|
||||||
|
cpu: 100m
|
||||||
|
memory: 256Mi
|
||||||
|
|
||||||
|
env:
|
||||||
|
- name: HOMEPAGE_ALLOWED_HOSTS
|
||||||
|
value: start.forteapps.net
|
||||||
|
envFrom:
|
||||||
|
- secretRef:
|
||||||
|
name: homepage-widget-credentials
|
||||||
@@ -18,6 +18,12 @@ ingress:
|
|||||||
ingressClassName: traefik
|
ingressClassName: traefik
|
||||||
annotations:
|
annotations:
|
||||||
cert-manager.io/cluster-issuer: letsencrypt-prod
|
cert-manager.io/cluster-issuer: letsencrypt-prod
|
||||||
|
gethomepage.dev/enabled: "true"
|
||||||
|
gethomepage.dev/name: "Keycloak"
|
||||||
|
gethomepage.dev/description: "Identity & access management"
|
||||||
|
gethomepage.dev/group: "Security"
|
||||||
|
gethomepage.dev/icon: "keycloak"
|
||||||
|
gethomepage.dev/href: "https://id.forteapps.net/admin/forte-test/console/"
|
||||||
|
|
||||||
metrics:
|
metrics:
|
||||||
enabled: true
|
enabled: true
|
||||||
@@ -52,6 +58,9 @@ keycloakConfigCli:
|
|||||||
enabled: true
|
enabled: true
|
||||||
image:
|
image:
|
||||||
repository: bitnamilegacy/keycloak-config-cli
|
repository: bitnamilegacy/keycloak-config-cli
|
||||||
|
extraEnvVars:
|
||||||
|
- name: IMPORT_MANAGED_PROTOCOL_MAPPER
|
||||||
|
value: "no-delete"
|
||||||
configuration:
|
configuration:
|
||||||
forte-realm.json: |
|
forte-realm.json: |
|
||||||
{
|
{
|
||||||
@@ -95,6 +104,18 @@ keycloakConfigCli:
|
|||||||
"access.token.claim": "true",
|
"access.token.claim": "true",
|
||||||
"userinfo.token.claim": "true"
|
"userinfo.token.claim": "true"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "groups",
|
||||||
|
"protocol": "openid-connect",
|
||||||
|
"protocolMapper": "oidc-group-membership-mapper",
|
||||||
|
"config": {
|
||||||
|
"claim.name": "groups",
|
||||||
|
"full.path": "false",
|
||||||
|
"id.token.claim": "true",
|
||||||
|
"access.token.claim": "true",
|
||||||
|
"userinfo.token.claim": "true"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -167,7 +188,54 @@ keycloakConfigCli:
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"browserFlow": "browser-auto-idp",
|
||||||
|
"authenticationFlows": [
|
||||||
|
{
|
||||||
|
"alias": "browser-auto-idp",
|
||||||
|
"description": "Browser flow with auto-redirect to Forte Entra IdP",
|
||||||
|
"providerId": "basic-flow",
|
||||||
|
"topLevel": true,
|
||||||
|
"builtIn": false,
|
||||||
|
"authenticationExecutions": [
|
||||||
|
{
|
||||||
|
"authenticator": "auth-cookie",
|
||||||
|
"authenticatorFlow": false,
|
||||||
|
"requirement": "ALTERNATIVE",
|
||||||
|
"priority": 10
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"authenticator": "identity-provider-redirector",
|
||||||
|
"authenticatorFlow": false,
|
||||||
|
"requirement": "ALTERNATIVE",
|
||||||
|
"priority": 20,
|
||||||
|
"authenticatorConfig": "forte-entra-redirector"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"authenticatorConfig": [
|
||||||
|
{
|
||||||
|
"alias": "forte-entra-redirector",
|
||||||
|
"config": {
|
||||||
|
"defaultProvider": "forte-entra"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
"groups": [
|
"groups": [
|
||||||
|
{
|
||||||
|
"name": "k8s",
|
||||||
|
"path": "/k8s",
|
||||||
|
"clientRoles": {
|
||||||
|
"grafana": ["Editor"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "dev",
|
||||||
|
"path": "/dev",
|
||||||
|
"clientRoles": {
|
||||||
|
"grafana": ["Viewer"]
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "ArgoCD Admins",
|
"name": "ArgoCD Admins",
|
||||||
"path": "/ArgoCD Admins"
|
"path": "/ArgoCD Admins"
|
||||||
@@ -437,10 +505,10 @@ extraDeploy:
|
|||||||
CRED_SECRET_KEY=$(echo "$CLIENT_JSON" | jq -r '.secret.keys.clientSecret // "client-secret"')
|
CRED_SECRET_KEY=$(echo "$CLIENT_JSON" | jq -r '.secret.keys.clientSecret // "client-secret"')
|
||||||
|
|
||||||
# Check if credential Secret already exists in target namespace
|
# Check if credential Secret already exists in target namespace
|
||||||
CRED_EXISTS=$(curl -sf -o /dev/null -w "%{http_code}" \
|
CRED_EXISTS=$(curl -s -o /dev/null -w "%{http_code}" \
|
||||||
--cacert "$CA_CERT" \
|
--cacert "$CA_CERT" \
|
||||||
-H "Authorization: Bearer ${SA_TOKEN}" \
|
-H "Authorization: Bearer ${SA_TOKEN}" \
|
||||||
"${K8S_API}/api/v1/namespaces/${CRED_NS}/secrets/${CRED_NAME}")
|
"${K8S_API}/api/v1/namespaces/${CRED_NS}/secrets/${CRED_NAME}" || echo "000")
|
||||||
|
|
||||||
# Skip if hash matches and credential Secret exists
|
# Skip if hash matches and credential Secret exists
|
||||||
if [ "$CONFIG_HASH" = "$EXISTING_HASH" ] && [ "$CRED_EXISTS" = "200" ]; then
|
if [ "$CONFIG_HASH" = "$EXISTING_HASH" ] && [ "$CRED_EXISTS" = "200" ]; then
|
||||||
@@ -460,44 +528,47 @@ extraDeploy:
|
|||||||
publicClient: false,
|
publicClient: false,
|
||||||
redirectUris: .redirectUris,
|
redirectUris: .redirectUris,
|
||||||
webOrigins: .webOrigins,
|
webOrigins: .webOrigins,
|
||||||
defaultClientScopes: .defaultClientScopes,
|
|
||||||
protocolMappers: (.protocolMappers // [])
|
protocolMappers: (.protocolMappers // [])
|
||||||
}')
|
} | with_entries(select(.value != null))')
|
||||||
|
|
||||||
# Check if client already exists
|
# Check if client already exists
|
||||||
EXISTING=$(curl -sf -H "Authorization: Bearer ${TOKEN}" \
|
EXISTING_RESPONSE=$(curl -s -H "Authorization: Bearer ${TOKEN}" \
|
||||||
"${KEYCLOAK_URL}/admin/realms/${REALM}/clients?clientId=${CLIENT_ID}" \
|
"${KEYCLOAK_URL}/admin/realms/${REALM}/clients?clientId=${CLIENT_ID}" || true)
|
||||||
| jq -r '.[0].id // empty')
|
EXISTING=$(echo "$EXISTING_RESPONSE" | jq -r '.[0].id // empty' 2>/dev/null || true)
|
||||||
|
|
||||||
if [ -n "$EXISTING" ]; then
|
if [ -n "$EXISTING" ]; then
|
||||||
echo " Updating existing Keycloak client (uuid: ${EXISTING})"
|
echo " Updating existing Keycloak client (uuid: ${EXISTING})"
|
||||||
HTTP_CODE=$(curl -sf -o /dev/null -w "%{http_code}" \
|
RESPONSE=$(curl -s -w "\n%{http_code}" \
|
||||||
-H "Authorization: Bearer ${TOKEN}" \
|
-H "Authorization: Bearer ${TOKEN}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-X PUT -d "$KC_CLIENT" \
|
-X PUT -d "$KC_CLIENT" \
|
||||||
"${KEYCLOAK_URL}/admin/realms/${REALM}/clients/${EXISTING}")
|
"${KEYCLOAK_URL}/admin/realms/${REALM}/clients/${EXISTING}" || true)
|
||||||
|
HTTP_CODE=$(echo "$RESPONSE" | tail -1)
|
||||||
|
RESPONSE_BODY=$(echo "$RESPONSE" | sed '$d')
|
||||||
if [ "$HTTP_CODE" != "204" ] && [ "$HTTP_CODE" != "200" ]; then
|
if [ "$HTTP_CODE" != "204" ] && [ "$HTTP_CODE" != "200" ]; then
|
||||||
echo " ERROR: Failed to update client '${CLIENT_ID}' (HTTP ${HTTP_CODE})"
|
echo " ERROR: Failed to update client '${CLIENT_ID}' (HTTP ${HTTP_CODE}): ${RESPONSE_BODY}"
|
||||||
annotate_secret "keycloak" "$CONFIG_NAME" "keycloak.forteapps.net/sync-status" "error"
|
annotate_secret "keycloak" "$CONFIG_NAME" "keycloak.forteapps.net/sync-status" "error"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
CLIENT_UUID="$EXISTING"
|
CLIENT_UUID="$EXISTING"
|
||||||
else
|
else
|
||||||
echo " Creating new Keycloak client '${CLIENT_ID}'"
|
echo " Creating new Keycloak client '${CLIENT_ID}'"
|
||||||
HTTP_CODE=$(curl -sf -o /dev/null -w "%{http_code}" \
|
RESPONSE=$(curl -s -w "\n%{http_code}" \
|
||||||
-H "Authorization: Bearer ${TOKEN}" \
|
-H "Authorization: Bearer ${TOKEN}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-X POST -d "$KC_CLIENT" \
|
-X POST -d "$KC_CLIENT" \
|
||||||
"${KEYCLOAK_URL}/admin/realms/${REALM}/clients")
|
"${KEYCLOAK_URL}/admin/realms/${REALM}/clients" || true)
|
||||||
|
HTTP_CODE=$(echo "$RESPONSE" | tail -1)
|
||||||
|
RESPONSE_BODY=$(echo "$RESPONSE" | sed '$d')
|
||||||
if [ "$HTTP_CODE" != "201" ]; then
|
if [ "$HTTP_CODE" != "201" ]; then
|
||||||
echo " ERROR: Failed to create client '${CLIENT_ID}' (HTTP ${HTTP_CODE})"
|
echo " ERROR: Failed to create client '${CLIENT_ID}' (HTTP ${HTTP_CODE}): ${RESPONSE_BODY}"
|
||||||
annotate_secret "keycloak" "$CONFIG_NAME" "keycloak.forteapps.net/sync-status" "error"
|
annotate_secret "keycloak" "$CONFIG_NAME" "keycloak.forteapps.net/sync-status" "error"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
# Fetch the newly created client's UUID
|
# Fetch the newly created client's UUID
|
||||||
CLIENT_UUID=$(curl -sf -H "Authorization: Bearer ${TOKEN}" \
|
CLIENT_UUID=$(curl -s -H "Authorization: Bearer ${TOKEN}" \
|
||||||
"${KEYCLOAK_URL}/admin/realms/${REALM}/clients?clientId=${CLIENT_ID}" \
|
"${KEYCLOAK_URL}/admin/realms/${REALM}/clients?clientId=${CLIENT_ID}" \
|
||||||
| jq -r '.[0].id')
|
| jq -r '.[0].id' || true)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Sync credentials to target namespace
|
# Sync credentials to target namespace
|
||||||
|
|||||||
36
infra/values/base/vault-values.yaml
Normal file
36
infra/values/base/vault-values.yaml
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
# HashiCorp Vault Helm Chart Values
|
||||||
|
# Chart: hashicorp/vault v0.32.0
|
||||||
|
|
||||||
|
server:
|
||||||
|
standalone:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
dataStorage:
|
||||||
|
enabled: true
|
||||||
|
size: 5Gi
|
||||||
|
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 100m
|
||||||
|
memory: 128Mi
|
||||||
|
limits:
|
||||||
|
cpu: 250m
|
||||||
|
memory: 256Mi
|
||||||
|
|
||||||
|
ingress:
|
||||||
|
enabled: true
|
||||||
|
ingressClassName: traefik
|
||||||
|
pathType: Prefix
|
||||||
|
activeService: true
|
||||||
|
annotations:
|
||||||
|
cert-manager.io/cluster-issuer: letsencrypt-prod
|
||||||
|
gethomepage.dev/enabled: "true"
|
||||||
|
gethomepage.dev/name: "Vault"
|
||||||
|
gethomepage.dev/description: "Secrets management"
|
||||||
|
gethomepage.dev/group: "Security"
|
||||||
|
gethomepage.dev/icon: "vault"
|
||||||
|
gethomepage.dev/href: "https://vault.forteapps.net"
|
||||||
|
|
||||||
|
ui:
|
||||||
|
enabled: true
|
||||||
|
serviceType: ClusterIP
|
||||||
3
infra/values/base/vaultwarden-values.yaml
Normal file
3
infra/values/base/vaultwarden-values.yaml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
image:
|
||||||
|
tag: "1.36.0-alpine"
|
||||||
|
domain: "https://vaultwarden.forteapps.net"
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user