Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example loadbalancer direct service #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cluster.tf → civo_cluster-cluster.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
resource "civo_kubernetes_cluster" "cluster" {
timeouts {
create = "10m"
}
name = "${var.cluster_name_prefix}cluster"
firewall_id = civo_firewall.firewall.id
pools {
Expand Down
2 changes: 1 addition & 1 deletion civo_firewall-cluster.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Create a firewall
resource "civo_firewall" "firewall" {
name = "${var.cluster_name_prefix}firewall"
name = "${var.cluster_name_prefix}firewall"
create_default_rules = false
}

Expand Down
25 changes: 9 additions & 16 deletions kubernetes_deployment-nginx.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,16 @@ resource "kubernetes_deployment" "nginx" {

spec {
container {
image = "nginx:1.21.6"
image = "dmajrekar/nginx-echo:latest"
name = "nginx"
port {
protocol = "TCP"
container_port = "8080"
}
port {
protocol = "TCP"
container_port = "8443"
}
resources {
limits = {
cpu = "0.5"
Expand All @@ -32,21 +40,6 @@ resource "kubernetes_deployment" "nginx" {
memory = "50Mi"
}
}

liveness_probe {
http_get {
path = "/"
port = 80

http_header {
name = "X-Custom-Header"
value = "Awesome"
}
}

initial_delay_seconds = 3
period_seconds = 3
}
}
}
}
Expand Down
34 changes: 34 additions & 0 deletions kubnernetes_service-nginx.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

resource "kubernetes_service" "nginx" {
metadata {
name = "nginx"
namespace = "default"
annotations = {
"kubernetes.civo.com/loadbalancer-enable-proxy-protocol" = "send-proxy"
}

}

spec {

selector = {
nginx = "nginx"
}
type = "LoadBalancer"
port {
protocol = "TCP"
port = 80
target_port = 8081
name = "web"
}
port {
protocol = "TCP"
port = 443
target_port = 8444
name = "websecure"
}

external_traffic_policy = "Cluster"
}

}