-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Open
Labels
kind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.Indicates an issue or PR lacks a `triage/foo` label and requires one.
Description
What happened:
Updating to kube-state-metrics version 2.17.0 broke the custom_resource_config_file configuration option in config.yaml
What you expected to happen:
custom_resource_config_file: "/etc/kube-state-metrics/custom-resource-config.yaml"
to be equivalent to
--custom-resource-state-config-file=/etc/kube-state-metrics/custom-resource-config.yaml
like in prior versions.
How to reproduce it (as minimally and precisely as possible):
minikube start
...
helm install \
cert-manager oci://quay.io/jetstack/charts/cert-manager \
--version v1.19.1 \
--namespace cert-manager \
--create-namespace \
--set crds.enabled=true
kubectl apply -f - <<'__END__'
apiVersion: cert-manager.io/v1
kind: CertificateRequest
metadata:
name: my-ca-cr
spec:
request: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURSBSRVFVRVNULS0tLS0KTUlJQzNqQ0NBY1lDQVFBd2daZ3hDekFKQmdOVkJBWVRBbHBhTVE4d0RRWURWUVFJREFaQmNHOXNiRzh4RFRBTApCZ05WQkFjTUJFMXZiMjR4RVRBUEJnTlZCQW9NQ0VwbGRITjBZV05yTVJVd0V3WURWUVFMREF4alpYSjBMVzFoCmJtRm5aWEl4RVRBUEJnTlZCQU1NQ0dwdmMyaDJZVzVzTVN3d0tnWUpLb1pJaHZjTkFRa0JGaDFxYjNOb2RXRXUKZG1GdWJHVmxkWGRsYmtCcVpYUnpkR0ZqYXk1cGJ6Q0NBU0l3RFFZSktvWklodmNOQVFFQkJRQURnZ0VQQURDQwpBUW9DZ2dFQkFLd01tTFhuQkNiRStZdTIvMlFtRGsxalRWQ3BvbHU3TlZmQlVFUWl1bDhFMHI2NFBLcDRZQ0c5Cmx2N2kwOHdFMEdJQUgydnJRQmxVd3p6ZW1SUWZ4YmQvYVNybzRHNUFBYTJsY2NMaFpqUlh2NEVMaER0aVg4N3IKaTQ0MWJ2Y01OM0ZPTlRuczJhRkJYcllLWGxpNG4rc0RzTEVuZmpWdXRiV01Zeis3M3ptaGZzclRJUjRzTXo3cQpmSzM2WFM4UkRjNW5oVVcyYU9BZ3lnbFZSOVVXRkxXNjNXYXVhcHg2QUpBR1RoZnJYdVVHZXlZUUVBSENxZmZmCjhyOEt3YTFYK1NwYm9YK1ppSVE0Nk5jQ043OFZnL2dQVHNLZmphZURoNWcyNlk1dEVidHd3MWdRbWlhK0MyRHIKWHpYNU13RzJGNHN0cG5kUnRQckZrU1VnMW1zd0xuc0NBd0VBQWFBQU1BMEdDU3FHU0liM0RRRUJDd1VBQTRJQgpBUUFXR0JuRnhaZ0gzd0N3TG5IQ0xjb0l5RHJrMUVvYkRjN3BJK1VVWEJIS2JBWk9IWEFhaGJ5RFFLL2RuTHN3CjJkZ0J3bmlJR3kxNElwQlNxaDBJUE03eHk5WjI4VW9oR3piN0FVakRJWHlNdmkvYTJyTVhjWjI1d1NVQmxGc28Kd005dE1QU2JwcEVvRERsa3NsOUIwT1BPdkFyQ0NKNnZGaU1UbS9wMUJIUWJSOExNQW53U0lUYVVNSFByRzJVMgpjTjEvRGNMWjZ2enEyeENjYVoxemh2bzBpY1VIUm9UWmV1ZEp6MkxmR0VHM1VOb2ppbXpBNUZHd0RhS3BySWp3ClVkd1JmZWZ1T29MT1dNVnFNbGRBcTlyT24wNHJaT3Jnak1HSE9tTWxleVdPS1AySllhaDNrVDdKU01zTHhYcFYKV0ExQjRsLzFFQkhWeGlKQi9Zby9JQWVsCi0tLS0tRU5EIENFUlRJRklDQVRFIFJFUVVFU1QtLS0tLQo=
isCA: false
usages:
- signing
- digital signature
- server auth
# 90 days
duration: 2160h
issuerRef:
name: ca-issuer
# We can reference ClusterIssuers by changing the kind here.
# The default value is Issuer (i.e. a locally namespaced Issuer)
kind: Issuer
group: cert-manager.io
__END__
cat > config.yaml <<'__END__'
custom_resource_config_file: custom-resource-config.yaml
__END__
cat > custom-resource-config.yaml <<'__END__'
kind: CustomResourceStateMetrics
spec:
resources:
- groupVersionKind:
group: cert-manager.io
kind: "CertificateRequest"
version: "v1"
metricNamePrefix: certmanager_certificaterequest
labelsFromPath:
certificaterequest: [metadata, name]
namespace: [metadata, namespace]
metrics:
- name: creation_time
help: "created timestamp seconds"
each:
type: Gauge
gauge:
path: [metadata, creationTimestamp]
__END__
go run main.go --config config.yaml --kubeconfig ~/.kube/config
curl -sSLf1 http://localhost:8080/metrics | grep '^kube_customresource_creation_time'If you git checkout v2.16.0 and follow these steps you will see a log line like:
I1029 16:54:39.268274 516434 config.go:85] "Using custom resource plural" resource="cert-manager.io_v1_CertificateRequest" plural="certificaterequests"
I1029 16:54:39.268824 516434 custom_resource_metrics.go:79] "Custom resource state added metrics" familyNames=["certmanager_certificaterequest_creation_time"]
I1029 16:54:39.269603 516434 builder.go:294] "Active resources" activeStoreNames="cert-manager.io/v1, Resource=certificaterequests,[...]"
and will see metrics like
$ curl -sSLf1 http://localhost:8080/metrics | grep '^certmanager_certificaterequest_creation_time'
...
certmanager_certificaterequest_creation_time{certificaterequest="my-ca-cr",customresource_group="cert-manager.io",customresource_kind="CertificateRequest",customresource_version="v1",namespace="default"} 1.76170942e+09
...
If you check out main or v2.17.0 you will not see such output.
$ curl -sSLf1 http://localhost:8080/metrics | grep 'my-ca-cr'
$
If you append --custom-resource-state-config-file=./custom-resource-config.yaml to the CLI in v2.17.0, the CRs will be detected again.
Anything else we need to know?:
Works on v2.16.0 breaks on v2.17.0
Strongly suspect regression in one of
- fix: Config file overrides apply to some fields but not other #2705
- feat: Continue running kube-state-metrics when config file doesnt exist at startup #2703
Environment:
- kube-state-metrics version: v2.17.0
- Kubernetes version (use
kubectl version):
$ kubectl version
Client Version: v1.32.1
Kustomize Version: v5.5.0
Server Version: v1.32.9-eks-ba24e9c - Cloud provider or hardware configuration: N/A
- Other info: N/A
Metadata
Metadata
Assignees
Labels
kind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.Indicates an issue or PR lacks a `triage/foo` label and requires one.
Type
Projects
Status
Needs Triage