This commit is contained in:
2023-10-18 18:40:55 +02:00
parent 1fac3163f7
commit a7ff84415e
5 changed files with 112 additions and 73 deletions

View File

@@ -0,0 +1,8 @@
terraform {
required_providers {
kubectl = {
source = "gavinbunney/kubectl"
version = "~> 1.14.0"
}
}
}

18
modules/service/svc.tf Normal file
View File

@@ -0,0 +1,18 @@
resource "kubectl_manifest" "service" {
yaml_body = <<-EOF
apiVersion: v1
kind: Service
metadata:
name: "${var.component}-${var.instance}"
namespace: "${var.namespace}"
labels: ${jsonencode(var.labels)}
spec:
type: ClusterIP
ports:
- name: http
port: ${var.port}
protocol: TCP
targetPort: ${var.target}
selector: ${jsonencode(var.labels)}
EOF
}

View File

@@ -0,0 +1,20 @@
variable "component" {
type = string
}
variable "instance" {
type = string
}
variable "namespace" {
type = string
}
variable "labels" {
type = map(string)
}
variable "port" {
type = number
default = 80
}
variable "target" {
type = string
default = "http"
}