thanos-io / kube-thanos

Kubernetes specific configuration for deploying Thanos.
Apache License 2.0
521 stars 176 forks source link

Multiple external labels for ruler in jsonnet #323

Open jobinjosem1 opened 4 months ago

jobinjosem1 commented 4 months ago

I am trying to build manifests using the JSONnet file below. I have added two labels to the ruler, "cluster_name" and "rule_replica", but in the compiled manifests, only one label is being added. Can someone help me add an additional label to thanos-rule?

local t = import 'kube-thanos/thanos.libsonnet';

// For an example with every option and component, please check all.jsonnet

local commonConfig = { local cfg = self, logFormat: 'json', namespace: 'monitoring', version: 'v0.29.0', image: 'myregistry.azurecr.io/thanos/thanos:' + cfg.version + '@sha256:abcd', replicaLabels: ['prometheus_replica', 'rule_replica'], objectStorageConfig: { name: 'thanos-objectstorage', key: 'thanos.yaml', }, };

local ru = t.rule(commonConfig { replicas: 1, rulesConfig: [{ name: 'thanos-rule', key: 'thanos-rule.yaml' }], replicaLabels: ['cluster_name', 'rule_replica'], serviceMonitor: true, volumeClaimTemplate: { spec: { accessModes: ['ReadWriteOnce'], resources: { requests: { storage: '100Gi' } }, storageClassName: 'managed-csi-premium-zrs' } }, reloaderImage: 'myregistry.azurecr.io/configmapreloader/configmap-reload:v0.12.0' });

local q = t.query(commonConfig { replicas: 1, replicaLabels: ['prometheus_replica', 'rule_replica'], serviceMonitor: true, queryTimeout: '60s' });

local finalRu = t.rule(ru.config { queriers: ['dnssrv+_http._tcp.%s.%s.svc.cluster.local' % [q.service.metadata.name, q.service.metadata.namespace]], });

{ ['thanos-ruler-' + name]: finalRu[name] for name in std.objectFields(finalRu) }

michael-burt commented 2 weeks ago

replicaLabels isn't a valid arg for the ruler, the label you see is being added here: https://github.com/thanos-io/kube-thanos/blob/main/jsonnet/kube-thanos/kube-thanos-rule.libsonnet#L139

You want to add an additional --label arg to the ruler, and that is not currently supported.