How to get the backend name created by kubernetes_ingress_v1?

Viewed 43

Recently I've been using Terraform to replicate my local infrastructure on Google Cloud Platform.
I've already created a Google Kubernetes Engine that runs containerized applications (pods), and all of these pods are connected to a Kubernetes Service. I've also created an External HTPP Load Balancing using kubernetes_ingress_v1, as in the following snippet:

resource "kubernetes_ingress_v1" "external" {
  wait_for_load_balancer = true

  metadata {
    name = "${var.mode}-quokka-ingress"
    namespace = "quokka"
    annotations = {
     "kubernetes.io/ingress.class" = "gce"
     "kubernetes.io/ingress.global-static-ip-name" = "${var.mode}-server"
    }
  }
  spec {
    rule {
      http {
        path {
          backend {
            service {
              name = "quokka-service"
              port {
                number = 8080
              }
            }
          }
            path = "/*"
        }
      }
    }
  }
}

This resource is able to create a GCP Load Balancer and other resources, such as:

Created Resources

I want to create an autoscaling resource to scale up/down machines based on the number of requests that are received by the Google Cloud HTTPS/Load Balancer. Google Cloud provides a metric called Backend Request Count, that stores the number of requests served by backends of external HTTP(S) load balancer.

The metric name is = loadbalancing.googleapis.com/https/backend_request_count

I want to filter this particular Load Balancer and to do this I need to add filters such as the proxy name, forwarding rule name, backend target name, or backend name (I'm only interested in filtering with one these metrics).

By the documentation kubernetes_ingress_v1, it seems that it's not possible to access these metrics through the resource.

Does anyone have any suggestions on how to access these metrics with terraform?

0 Answers
Related