orchestration-tests/k8s-test/main.tf

84 lines
1.5 KiB
HCL

variable "kube_config_path" {
type = string
default = "~/.kube/config"
}
variable "kube_config_context" {
type = string
default = "colima"
}
provider "kubernetes" {
config_path = var.kube_config_path
config_context = var.kube_config_context
}
provider "helm" {
kubernetes {
config_path = var.kube_config_path
config_context = var.kube_config_context
}
}
resource "helm_release" "traefik" {
name = "traefik"
repository = "https://helm.traefik.io/traefik"
chart = "traefik"
}
resource "kubernetes_manifest" "traefik_dashboard" {
manifest = {
apiVersion = "traefik.containo.us/v1alpha1"
kind = "IngressRoute"
metadata = {
name = "public-traefik-dashboard"
namespace = "default"
}
spec = {
entryPoints = [ "web" ]
routes = [
{
match = "PathPrefix(`/dashboard`) || PathPrefix(`/api`)"
kind = "Rule"
services = [
{
name = "api@internal"
kind = "TraefikService"
},
]
},
]
}
}
}
module "whoami" {
source = "./simple_service"
name = "whoami"
image = "containous/whoami:latest"
expose_ports = [80]
}
module "whoami-ingress" {
source = "./traefik_ingress"
app_name = "whoami"
match_route = "PathPrefix(`/whoami`)"
}
module "whoami2" {
source = "./simple_service"
name = "whoami2"
image = "containous/whoami:latest"
expose_ports = [80]
}
module "whoami2-ingress" {
source = "./traefik_ingress"
app_name = "whoami2"
match_route = "PathPrefix(`/whoami2`)"
}