Skip to content

Commit

Permalink
Add ingress example
Browse files Browse the repository at this point in the history
  • Loading branch information
sl1pm4t committed Oct 26, 2017
1 parent b8d07f1 commit 87d6d08
Showing 1 changed file with 133 additions and 0 deletions.
133 changes: 133 additions & 0 deletions examples/ingress/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
provider "kubernetes" {
config_context_auth_info = "minikube"
config_context_cluster = "minikube"
}

resource "kubernetes_ingress" "example" {
metadata {
name = "example"
annotations {
"ingress.kubernetes.io/rewrite-target" = "/"
}
}

spec {
backend {
service_name = "echoserver"
service_port = 8080
}

rule {
host = "myminikube.info"
http {
path {
path_regex = "/"
backend {
service_name = "echoserver"
service_port = 8080
}
}
}
}

rule {
host = "cheeses.all"
http {
path {
path_regex = "/stilton"
backend {
service_name = "stilton-cheese"
service_port = 80
}
}
path {
path_regex = "/cheddar"
backend {
service_name = "cheddar"
service_port = 80
}
}
}
}
}
}

resource "kubernetes_service" "echoserver" {
metadata {
name = "echoserver"
}

spec {
selector {
app = "echoserver"
}

port {
port = 8080
target_port = 8080
}

type = "NodePort"
}
}

resource "kubernetes_deployment" "echoserver" {
name = "echoserver"

spec {
selector {
app = "echoserver"
}
template {
container {
name = "echoserver"
image = "gcr.io/google_containers/echoserver:1.4"
port {
container_port = 8080
}
}
}
}
}

resource "kubernetes_deployment" "cheddar" {
name = "cheddar-cheese"

spec {
selector {
app = "cheddar"
}
template {
container {
name = "cheddar"
image = "errm/cheese:cheddar"
port {
container_port = 80
}
}
}
}
}

resource "kubernetes_service" "cheddar" {
metadata {
name = "cheddar"
}

spec {
selector {
app = "cheddar"
}

port {
port = 80
target_port = 80
}

type = "NodePort"
}
}

output "ingress_ip" {
value = "${kubernetes_ingress.example.load_balancer_ingress.0.ip}"
}

0 comments on commit 87d6d08

Please sign in to comment.