first commit
This commit is contained in:
22
service/svc.tf
Normal file
22
service/svc.tf
Normal file
@@ -0,0 +1,22 @@
|
||||
locals {
|
||||
ports = [ for idx, target in var.targets : {
|
||||
"name" = target
|
||||
"port"= var.ports[idx]
|
||||
"protocol"= var.protocols[idx]
|
||||
"targetPort" = target
|
||||
}]
|
||||
}
|
||||
resource "kubectl_manifest" "service" {
|
||||
yaml_body = <<-EOF
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: "${var.instance}-${var.component}"
|
||||
namespace: "${var.namespace}"
|
||||
labels: ${jsonencode(var.labels)}
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports: ${jsonencode(local.ports)}
|
||||
selector: ${jsonencode(var.labels)}
|
||||
EOF
|
||||
}
|
||||
Reference in New Issue
Block a user