From 8c1c2887ad717c3eadfa95f522286421c688199b Mon Sep 17 00:00:00 2001 From: Dinesh Majrekar Date: Fri, 5 Aug 2022 12:55:57 +0100 Subject: [PATCH] Add example loadbalacner direct service --- cluster.tf => civo_cluster-cluster.tf | 3 +++ civo_firewall-cluster.tf | 2 +- kubernetes_deployment-nginx.tf | 25 +++++++------------- kubnernetes_service-nginx.tf | 34 +++++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 17 deletions(-) rename cluster.tf => civo_cluster-cluster.tf (93%) create mode 100644 kubnernetes_service-nginx.tf diff --git a/cluster.tf b/civo_cluster-cluster.tf similarity index 93% rename from cluster.tf rename to civo_cluster-cluster.tf index ef8ad30..18dbaf1 100644 --- a/cluster.tf +++ b/civo_cluster-cluster.tf @@ -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 { diff --git a/civo_firewall-cluster.tf b/civo_firewall-cluster.tf index d1b2862..ad45382 100644 --- a/civo_firewall-cluster.tf +++ b/civo_firewall-cluster.tf @@ -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 } diff --git a/kubernetes_deployment-nginx.tf b/kubernetes_deployment-nginx.tf index 01debe4..8f19d3f 100644 --- a/kubernetes_deployment-nginx.tf +++ b/kubernetes_deployment-nginx.tf @@ -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" @@ -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 - } } } } diff --git a/kubnernetes_service-nginx.tf b/kubnernetes_service-nginx.tf new file mode 100644 index 0000000..991bf42 --- /dev/null +++ b/kubnernetes_service-nginx.tf @@ -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" + } + +}