gcp-quota-exporter

by Helm

Helm chartv2.0.2App v0.3.2

Obtains the resource quotas from a GCP project and allows to export them to Prometheus

About this chart

gcp-quota-exporter

Google Cloud Platform Quota Exporter - Obtains the resource quotas from a GCP project and allows to export them to Prometheus

As we want to get the resource quotas of our GCP projects and check when we are exhausting the limits we need to get the data from GCP and export them somewhere, in this case this exports the data to Prometheus.

It's installed as a dependency in the main chart, but if you want to do all the steps manually, which helps to understand how it works, you can follow the next steps:

TL;DR;

$ helm repo add gcp-quota-exporter https://hub.helm.sh/charts/softonic/gcp-quota-exporter
$ helm repo update
$ helm install gcp-quota-exporter/gcp-quota-exporter -n --version=2.0.1

Introduction

This chart deploys gcp-quota-exporter on a Kubernetes cluster using the Helm package manager.

Prerequisites

  • You need a service account with roles/compute.instanceAdmin permissions

Example of how to create a Service Account file

gcloud iam service-accounts create gcp-quota-exporter --project ${GCP_PROJECT}
gcloud projects add-iam-policy-binding ${GCP_PROJECT} \
--member "serviceAccount:gcp-quota-exporter@${GCP_PROJECT}.iam.gserviceaccount.com" \
--role "roles/compute.instanceAdmin"
gcloud iam service-accounts keys create service-account-gcp-quota-exporter.json \
--iam-account "gcp-quota-exporter@${GCP_PROJECT}.iam.gserviceaccount.com"

Launch exporter as a test

docker run -it --rm \
-p 9592:9592 \
-v $(pwd)/service-account-gcp-quota-exporter.json:/app/credentials.json \
-e GOOGLE_APPLICATION_CREDENTIALS=/app/credentials.json \
-e GOOGLE_PROJECT_ID=${GCP_PROJECT} mintel/gcp-quota-exporter

Check exporter output

curl localhost:9592/metrics
# HELP gcp_quota_exporter_build_info A metric with a constant '1' value labeled by version, revision, branch, and goversion from which gcp_quota_exporter was built.
# TYPE gcp_quota_exporter_build_info gauge
gcp_quota_exporter_build_info{branch="",goversion="go1.12.5",revision="",version=""} 1
# HELP gcp_quota_limit quota limits for GCP components
# TYPE gcp_quota_limit gauge
gcp_quota_limit{metric="AUTOSCALERS",project="PROJECT_NAME",region="asia-east1"} 500
gcp_quota_limit{metric="AUTOSCALERS",project="PROJECT_NAME",region="asia-east2"} 500
gcp_quota_limit{metric="AUTOSCALERS",project="PROJECT_NAME",region="asia-northeast1"} 500
gcp_quota_limit{metric="AUTOSCALERS",project="PROJECT_NAME",region="asia-northeast2"} 50
gcp_quota_limit{metric="AUTOSCALERS",project="PROJECT_NAME",region="asia-northeast3"} 50
gcp_quota_limit{metric="AUTOSCALERS",project="PROJECT_NAME",region="asia-south1"} 500
gcp_quota_limit{metric="AUTOSCALERS",project="PROJECT_NAME",region="asia-southeast1"} 500
...

Installing the Chart

This uses helm, the idea is to add this as a subchart of your preferred monitoring chart, but it can be launched independently as well:

To install the chart with the release name ``:

$ helm install  gcp-quota-exporter/gcp-quota-exporter -n  --version=2.0.0

The command deploys gcp-quota-exporter on the Kubernetes cluster in the default configuration. The configuration section lists the parameters that can be configured during installation.

NOTE: The deployment expects you to provide a secret with the service account to mount in the pod.

Tip: List all releases using helm list

Uninstalling the Chart

To uninstall/delete the ``:

$ helm delete  -n 

The command removes all the Kubernetes components associated with the chart and deletes the release.

Configuration

The following table lists the configurable parameters of the gcp-quota-exporter chart and their default values.

ParameterDescriptionDefault
replicaCountdesired number of pods1
image.repositorycontainer image repositorymintel/gcp-quota-exporter
image.pullPolicycontainer image pull policyIfNotPresent
image.tagcontainer image tag""
imagePullSecretscontainer image pull secrets[]
nameOverride""
fullnameOverride""
gcpProjectGoogle Cloud Platform project name to scrape data from""
serviceAccount.createSpecifies whether a service account should be createdtrue
serviceAccount.annotationsAnnotations to add to the service account{}
serviceAccount.nameThe name of the service account to use. If not set and create is true, a name is generated using the fullname template``
podSecurityContext{}
securityContext{}
service.typetype of service to createClusterIP
service.portport for the http service80
ingress.enabledenable or disable ingressfalse
ingress.annotationsingress annotations{}
ingress.tlsTLS certificate info defined here[]
serviceAccountSecretname of the secret that contains the service account needed to get the data from GCPgcp-quota-sa
livenessProbe.failureThreshold3
livenessProbe.httpGet.path/metrics
livenessProbe.httpGet.porthttp
livenessProbe.httpGet.schemeHTTP
livenessProbe.initialDelaySeconds10
livenessProbe.periodSeconds10
livenessProbe.successThreshold1
livenessProbe.timeoutSeconds5
readinessProbe.failureThreshold3
readinessProbe.httpGet.path/metrics
readinessProbe.httpGet.porthttp
readinessProbe.httpGet.schemeHTTP
readinessProbe.periodSeconds10
readinessProbe.successThreshold1
readinessProbe.timeoutSeconds5
resources{}
nodeSelector{}
tolerations[]
affinity{}
annotationsIf you don't use prometheus operator you could use some annotations to use the Prometheus SD{}
podLabels{}
serviceMonitor.enabledWhen set true then use a ServiceMonitor to configure scrapingfalse
serviceMonitor.namespaceSet the namespace the ServiceMonitor should be deployednull
serviceMonitor.additionalLabelsadditionalLabels is the set of additional labels to add to the ServiceMonitor

Deploy gcp-quota-exporter with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has gcp-quota-exporter on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartgcp-quota-exporter is pinned at v2.0.2 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply