-
Notifications
You must be signed in to change notification settings - Fork 959
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
Old labels remain in PrometheusRules rule specifications #2447
Comments
Hello, thanks for opening this issue @NBardelot. Can you include a simple TF config that can reproduce this error output. This could be related to #2436 since I see that labels is a map[string] type. Being able to have the config will confirm whether it's related or not. |
The terraform module would look like this: terraform {
required_version = ">= 1.6.0"
required_providers {
kubernetes = {
source = "hashicorp/kubernetes"
version = ">= 2.15.0"
}
}
}
variable "k8s_cluster" {
type = string
description = "kubernetes cluster"
}
variable "prometheus_rules_spec" {
type = object({
groups = list(object({
name = string
rules = list(object({
alert = string
annotations = map(string)
expr = string
labels = object({
severity = string
})
}))
}))
})
}
provider "kubernetes" {
config_context = var.k8s_cluster
config_path = "~/.kube/config"
}
resource "kubernetes_manifest" "prometheus_rules" {
manifest = {
apiVersion = "monitoring.coreos.com/v1"
kind = "PrometheusRule"
metadata = {
name = "example"
namespace = "somewhere"
}
spec = {
groups = [
for group in var.prometheus_rules_spec.groups : {
name = group.name
rules = [
for rule in group.rules : {
alert = rule.alert
annotations = rule.annotations
expr = rule.expr
labels = merge(
rule.labels,
{
namespace = "somewhere"
severity = rule.labels.severity
}
)
}
]
}
]
}
}
} And the tfvars file: prometheus_rules_spec = {
groups = [
{
name = "group1"
rules = [
{
alert = "alert1"
annotations = {
description = "example"
summary = "example"
}
expr = "1 != 1"
labels = {
severity = "warning"
}
}
]
}
]
} |
I've found a workaround with this - cleaner - implementation:
And the tfvars file:
|
Terraform Version, Provider Version and Kubernetes Version
Affected Resource(s)
Steps to Reproduce
Trying to delete/recreate the ressource would produce such logs in Terraform's output:
With the plan beforehand indicating:
Expected Behavior
The label should be removed from the tfstate, and from the ressource in Kubernetes.
Important Factoids
This might not be specific to PrometheusRule, but might happen for other manifests.
The text was updated successfully, but these errors were encountered: