fix
This commit is contained in:
8
modules/service/providers.tf
Normal file
8
modules/service/providers.tf
Normal file
@@ -0,0 +1,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
kubectl = {
|
||||
source = "gavinbunney/kubectl"
|
||||
version = "~> 1.14.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
18
modules/service/svc.tf
Normal file
18
modules/service/svc.tf
Normal 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
|
||||
}
|
||||
20
modules/service/variables.tf
Normal file
20
modules/service/variables.tf
Normal 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"
|
||||
}
|
||||
Reference in New Issue
Block a user