Commit 471b08f1 by chenxx

port update

1 parent a8b02f1f
Showing 1 changed file with 20 additions and 20 deletions
......@@ -6,7 +6,9 @@ terraform {
}
}
}
#provider "kubernetes" {
# config_path = "~/.kube/config"
#}
resource "kubernetes_namespace" "CUS" {
metadata {
name = var.namespace
......@@ -21,21 +23,24 @@ resource "kubernetes_deployment" "CUS" {
replicas = 1
selector {
match_labels = {
app = "ng6"
app = var.name
}
}
template {
metadata {
labels = {
app = "ng6"
app = var.name
}
}
spec {
container {
image = var.image
name = var.name
port {
container_port = 80
dynamic "port" {
for_each = var.ports
content {
container_port = port.value
}
}
}
}
......@@ -45,28 +50,23 @@ resource "kubernetes_deployment" "CUS" {
resource "kubernetes_service" "CUS" {
metadata {
name = "${var.name}-svc"
#namespace = kubernetes_namespace.test.metadata.0.name
namespace = var.namespace
}
spec {
selector = {
app = kubernetes_deployment.CUS.spec.0.template.0.metadata.0.labels.app
app = var.name
}
type = "NodePort"
port {
port = "80"
name = "port-80"
protocol = "TCP"
target_port = "80"
node_port = "30088"
}
port {
port = "443"
name = "port-443"
protocol = "TCP"
target_port = "443"
node_port = "30089"
dynamic "port" {
for_each = var.ports
content {
port = port.value
name = "port-${port.value}"
protocol = "TCP"
target_port = port.value
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!