Skip to content

Instantly share code, notes, and snippets.

@acondrat
Created February 3, 2021 09:49
Show Gist options
  • Save acondrat/d552309460b47eb9e1175b8625df4d1f to your computer and use it in GitHub Desktop.
Save acondrat/d552309460b47eb9e1175b8625df4d1f to your computer and use it in GitHub Desktop.
victoriametrics security policy
resource "google_compute_security_policy" "victoriametrics" {
name = "victoriametrics"
rule {
action = "allow"
priority = "1000"
match {
expr {
# Querying from nat IP of the k8s cluster
# https://github.com/VictoriaMetrics/VictoriaMetrics/tree/cluster#url-format
expression = "request.path.matches('^/api/v1/query|^/api/v1/series|^/api/v1/label') && (inIpRange(origin.ip, 'x.x.x.x/32'))"
}
}
description = "Allow querying api from nat IP of the k8s cluster"
}
rule {
action = "deny(404)"
priority = "2147483647"
match {
versioned_expr = "SRC_IPS_V1"
config {
src_ip_ranges = ["*"]
}
}
description = "default rule"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment