Skip to content
Snippets Groups Projects
Commit 682809c0 authored by Frederic Branczyk's avatar Frederic Branczyk Committed by GitHub
Browse files

Merge pull request #2299 from metalmatze/thanos-compactor

contrib/kube-prometheus: Add Thanos compactor as StatefulSet
parents ac1eda0b e10cafcc
No related branches found
No related tags found
No related merge requests found
......@@ -138,5 +138,81 @@ local servicePort = k.core.v1.service.mixin.spec.portsType;
statefulSet.mixin.spec.template.spec.withVolumes([
volume.fromEmptyDir('data'),
]),
serviceMonitorThanosCompactor:
{
apiVersion: 'monitoring.coreos.com/v1',
kind: 'ServiceMonitor',
metadata: {
name: 'thanos-compactor',
namespace: $._config.namespace,
labels: {
'k8s-app': 'thanos-compactor',
},
},
spec: {
jobLabel: 'k8s-app',
endpoints: [
{
port: 'http',
interval: '30s',
},
],
selector: {
matchLabels: {
app: 'thanos-compactor',
},
},
},
},
thanosCompactorService:
service.new(
'thanos-compactor',
{ app: 'thanos-compactor' },
servicePort.newNamed('http', 9090, 'http'),
) +
service.mixin.metadata.withNamespace($._config.namespace) +
service.mixin.metadata.withLabels({ app: 'thanos-compactor' }),
thanosCompactorStatefulset:
local statefulSet = k.apps.v1beta2.statefulSet;
local volume = statefulSet.mixin.spec.template.spec.volumesType;
local container = statefulSet.mixin.spec.template.spec.containersType;
local containerEnv = container.envType;
local containerVolumeMount = container.volumeMountsType;
local labels = { app: 'thanos-compactor' };
local c =
container.new('thanos-compactor', $._config.imageRepos.thanos + ':' + $._config.versions.thanos) +
container.withArgs([
'compact',
'--log.level=debug',
'--data-dir=/var/thanos/store',
'--objstore.config=$(OBJSTORE_CONFIG)',
'--wait',
]) +
container.withEnv([
containerEnv.fromSecretRef(
'OBJSTORE_CONFIG',
$._config.thanos.objectStorageConfig.name,
$._config.thanos.objectStorageConfig.key,
),
]) +
container.withPorts([
{ name: 'http', containerPort: 10902 },
]) +
container.withVolumeMounts([
containerVolumeMount.new('data', '/var/thanos/store', false),
]);
statefulSet.new('thanos-compactor', 1, c, [], labels) +
statefulSet.mixin.metadata.withNamespace($._config.namespace) +
statefulSet.mixin.spec.selector.withMatchLabels(labels) +
statefulSet.mixin.spec.withServiceName('thanos-compactor') +
statefulSet.mixin.spec.template.spec.withVolumes([
volume.fromEmptyDir('data'),
]),
},
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment