Skip to content
Snippets Groups Projects
Commit d113a001 authored by Matthias Loibl's avatar Matthias Loibl Committed by GitHub
Browse files

Merge pull request #2275 from metalmatze/thanos-v0.2

contrib/kube-prometheus: Update kube-prometheus-thanos for Thanos v0.2
parents 73bd58f8 07813fdc
No related branches found
No related tags found
No related merge requests found
...@@ -2,15 +2,20 @@ local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet'; ...@@ -2,15 +2,20 @@ local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet';
local service = k.core.v1.service; local service = k.core.v1.service;
local servicePort = k.core.v1.service.mixin.spec.portsType; local servicePort = k.core.v1.service.mixin.spec.portsType;
{ {
_config+:: { _config+:: {
versions+:: { versions+:: {
thanos: 'v0.1.0', thanos: 'v0.2.1',
}, },
imageRepos+:: { imageRepos+:: {
thanos: 'improbable/thanos', thanos: 'improbable/thanos',
}, },
thanos+:: {
objectStorageConfig: {
key: 'thanos.yaml', // How the file inside the secret is called
name: 'thanos-objstore-config', // This is the name of your Kubernetes secret with the config
},
},
}, },
prometheus+:: { prometheus+:: {
prometheus+: { prometheus+: {
...@@ -22,9 +27,16 @@ local servicePort = k.core.v1.service.mixin.spec.portsType; ...@@ -22,9 +27,16 @@ local servicePort = k.core.v1.service.mixin.spec.portsType;
peers: 'thanos-peers.' + $._config.namespace + '.svc:10900', peers: 'thanos-peers.' + $._config.namespace + '.svc:10900',
version: $._config.versions.thanos, version: $._config.versions.thanos,
baseImage: $._config.imageRepos.thanos, baseImage: $._config.imageRepos.thanos,
objectStorageConfig: $._config.thanos.objectStorageConfig,
}, },
}, },
}, },
thanosPeerService:
local thanosPeerPort = servicePort.newNamed('cluster', 10900, 'cluster');
service.new('thanos-peers', { 'thanos-peer': 'true' }, thanosPeerPort) +
service.mixin.metadata.withNamespace($._config.namespace) +
service.mixin.spec.withType('ClusterIP') +
service.mixin.spec.withClusterIp('None'),
thanosQueryDeployment: thanosQueryDeployment:
local deployment = k.apps.v1beta2.deployment; local deployment = k.apps.v1beta2.deployment;
local container = k.apps.v1beta2.deployment.mixin.spec.template.spec.containersType; local container = k.apps.v1beta2.deployment.mixin.spec.template.spec.containersType;
...@@ -54,11 +66,47 @@ local servicePort = k.core.v1.service.mixin.spec.portsType; ...@@ -54,11 +66,47 @@ local servicePort = k.core.v1.service.mixin.spec.portsType;
service.new('thanos-query', { app: 'thanos-query' }, thanosQueryPort) + service.new('thanos-query', { app: 'thanos-query' }, thanosQueryPort) +
service.mixin.metadata.withNamespace($._config.namespace) + service.mixin.metadata.withNamespace($._config.namespace) +
service.mixin.metadata.withLabels({ app: 'thanos-query' }), service.mixin.metadata.withLabels({ app: 'thanos-query' }),
thanosPeerService:
local thanosPeerPort = servicePort.newNamed('cluster', 10900, 'cluster'); thanosStoreStatefulset:
service.new('thanos-peers', { 'thanos-peer': 'true' }, thanosPeerPort) + local statefulSet = k.apps.v1beta2.statefulSet;
service.mixin.metadata.withNamespace($._config.namespace) + local volume = statefulSet.mixin.spec.template.spec.volumesType;
service.mixin.spec.withType('ClusterIP') + local container = statefulSet.mixin.spec.template.spec.containersType;
service.mixin.spec.withClusterIp('None'), local containerEnv = container.envType;
local containerVolumeMount = container.volumeMountsType;
local labels = { app: 'thanos', 'thanos-peer': 'true' };
local c =
container.new('thanos-store', $._config.imageRepos.thanos + ':' + $._config.versions.thanos) +
container.withArgs([
'store',
'--log.level=debug',
'--data-dir=/var/thanos/store',
'--cluster.peers=thanos-peers.' + $._config.namespace + '.svc:10900',
'--objstore.config=$(OBJSTORE_CONFIG)',
]) +
container.withEnv([
containerEnv.fromSecretRef(
'OBJSTORE_CONFIG',
$._config.thanos.objectStorageConfig.name,
$._config.thanos.objectStorageConfig.key,
),
]) +
container.withPorts([
{ name: 'cluster', containerPort: 10900 },
{ name: 'grpc', containerPort: 10901 },
{ name: 'http', containerPort: 10902 },
]) +
container.withVolumeMounts([
containerVolumeMount.new('data', '/var/thanos/store', false),
]);
statefulSet.new('thanos-store', 1, c, [], labels) +
statefulSet.mixin.metadata.withNamespace($._config.namespace) +
statefulSet.mixin.spec.selector.withMatchLabels(labels) +
statefulSet.mixin.spec.withServiceName('thanos-store') +
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.
Please register or to comment