7 Commits

Author SHA1 Message Date
140321f714 Migrate the middleware to the new CRD 2024-02-15 14:36:39 +01:00
a77bf1ec51 improve oauth2 ouput 2024-01-29 09:48:07 +01:00
4f306cdacf adding ingress output for secret_name 2024-01-29 09:33:11 +01:00
0a9700ab94 fix 2024-01-28 11:48:34 +01:00
0a92ad09d5 fix 2024-01-28 10:13:10 +01:00
c1aac2424b fix 2024-01-28 10:11:54 +01:00
ccfac82ad4 fix 2024-01-28 10:09:48 +01:00
9 changed files with 30 additions and 14 deletions

View File

@@ -74,7 +74,7 @@ resource "restapi_object" "forward_outpost_binding" {
resource "kubectl_manifest" "prj_middleware" { resource "kubectl_manifest" "prj_middleware" {
yaml_body = <<-EOF yaml_body = <<-EOF
apiVersion: traefik.containo.us/v1alpha1 apiVersion: traefik.io/v1alpha1
kind: Middleware kind: Middleware
metadata: metadata:
name: "${local.app_slug}-forward" name: "${local.app_slug}-forward"

View File

@@ -58,7 +58,7 @@ resource "kubectl_manifest" "prj_certificate" {
resource "kubectl_manifest" "prj_https_redirect" { resource "kubectl_manifest" "prj_https_redirect" {
count = var.create_redirect || var.component == "" ? 1 : 0 count = var.create_redirect || var.component == "" ? 1 : 0
yaml_body = <<-EOF yaml_body = <<-EOF
apiVersion: "traefik.containo.us/v1alpha1" apiVersion: "traefik.io/v1alpha1"
kind: "Middleware" kind: "Middleware"
metadata: metadata:
name: "${local.app_slug}-https" name: "${local.app_slug}-https"

3
ingress/outputs.tf Normal file
View File

@@ -0,0 +1,3 @@
output "secret_name" {
value = var.create_cert ? "${local.app_slug}-cert":""
}

View File

@@ -3,7 +3,7 @@ locals {
mongo-password = data.kubernetes_secret_v1.prj_mongo_secret.data["password"] mongo-password = data.kubernetes_secret_v1.prj_mongo_secret.data["password"]
username = var.username==""?var.component==""?var.instance:var.component:var.username username = var.username==""?var.component==""?var.instance:var.component:var.username
db_name = var.db_name==""?var.component==""?var.instance:var.component:var.db_name db_name = var.db_name==""?var.component==""?var.instance:var.component:var.db_name
mongo-labels = merge(local.labels, { mongo-labels = merge(var.labels, {
"app.kubernetes.io/component" = "mongo" "app.kubernetes.io/component" = "mongo"
}) })
} }
@@ -40,8 +40,8 @@ resource "kubectl_manifest" "prj_mongo" {
labels: ${jsonencode(local.mongo-labels)} labels: ${jsonencode(local.mongo-labels)}
spec: spec:
members: 1 members: 1
type: ReplicaSet type: ${var.mongo_type}
version: "7.0.2" version: "${var.mongo_version}"
statefulSet: statefulSet:
spec: spec:
template: template:

View File

@@ -18,11 +18,11 @@ variable "username" {
type = string type = string
default = "" default = ""
} }
variable "version" { variable "mongo_version" {
type = string type = string
default = "6.3.2" default = "6.0.13"
} }
variable "type" { variable "mongo_type" {
type = string type = string
default = "ReplicaSet" default = "ReplicaSet"
} }

View File

@@ -23,3 +23,16 @@ output "client_id" {
output "client_secret" { output "client_secret" {
value = data.kubernetes_secret_v1.oauth2-client-secret.data["client-secret"] value = data.kubernetes_secret_v1.oauth2-client-secret.data["client-secret"]
} }
output "secret_client_id_name" {
value = kubectl_manifest.oauth2-secret.name
}
output "secret_client_secret_name" {
value = kubernetes_secret_v1.oauth2-client-secret.metadata[0].name
}
output "secret_client_id_key" {
value = "client-id"
}
output "secret_client_secret_key" {
value = "client-secret"
}

View File

@@ -1,6 +1,6 @@
output "host" { output "host" {
value = "${var.app_slug}-redis.${var.namespace}.svc" value = "${local.app_slug}-redis.${var.namespace}.svc"
} }
output "url" { output "url" {
value = "redis://${var.app_slug}-redis.${var.namespace}.svc:6379" value = "redis://${local.app_slug}-redis.${var.namespace}.svc:6379"
} }

View File

@@ -1,6 +1,6 @@
locals { locals {
app_slug = (var.component == var.instance || var.component=="") ? var.instance : format("%s-%s", var.component, var.instance) app_slug = (var.component == var.instance || var.component=="") ? var.instance : format("%s-%s", var.component, var.instance)
redis-labels = merge(local.labels, { redis-labels = merge(var.labels, {
"app.kubernetes.io/component" = "redis" "app.kubernetes.io/component" = "redis"
}) })
cfg = merge({ cfg = merge({
@@ -23,7 +23,7 @@ resource "kubectl_manifest" "redis" {
namespace: "${var.namespace}" namespace: "${var.namespace}"
labels: ${jsonencode(local.redis-labels)} labels: ${jsonencode(local.redis-labels)}
spec: spec:
kubernetesConfig: ${jsonencode(cfg)} kubernetesConfig: ${jsonencode(local.cfg)}
storage: storage:
volumeClaimTemplate: volumeClaimTemplate:
spec: spec:

View File

@@ -1,9 +1,9 @@
output "name" { output "name" {
value = "${var.app_slug}" value = "${local.app_slug}"
} }
output "default_definition" { output "default_definition" {
value = { value = {
"name" = "${var.app_slug}" "name" = "${local.app_slug}"
"port" = { "port" = {
"number" = var.ports[0] "number" = var.ports[0]
} }