Skip to content

Commit

Permalink
Add thanos store memcached mixin
Browse files Browse the repository at this point in the history
Signed-off-by: Kemal Akkoyun <[email protected]>
  • Loading branch information
kakkoyun committed Apr 6, 2020
1 parent 00fe1af commit 7b4eee9
Show file tree
Hide file tree
Showing 3 changed files with 156 additions and 1 deletion.
13 changes: 12 additions & 1 deletion all.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ local s = t.store + t.store.withVolumeClaimTemplate + t.store.withServiceMonitor
},
};

local swm = t.store + t.store.withVolumeClaimTemplate + t.store.withServiceMonitor + t.store.withMemcachedIndexCache + commonConfig + {
config+:: {
name: 'thanos-store',
replicas: 1,
memcached+: {
addresses: [],
},
},
};

local q = t.query + t.query.withServiceMonitor + commonConfig + {
config+:: {
name: 'thanos-query',
Expand All @@ -85,4 +95,5 @@ local finalRu = ru {
{ ['thanos-receive-' + name]: re[name] for name in std.objectFields(re) } +
{ ['thanos-rule-' + name]: finalRu[name] for name in std.objectFields(finalRu) } +
{ ['thanos-store-' + name]: s[name] for name in std.objectFields(s) } +
{ ['thanos-query-' + name]: q[name] for name in std.objectFields(q) }
{ ['thanos-query-' + name]: q[name] for name in std.objectFields(q) } +
{ 'thanos-store-statefulSet-with-memcached': swm.statefulSet }
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
labels:
app.kubernetes.io/component: object-store-gateway
app.kubernetes.io/instance: thanos-store
app.kubernetes.io/name: thanos-store
app.kubernetes.io/version: v0.10.1
name: thanos-store
namespace: thanos
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/component: object-store-gateway
app.kubernetes.io/instance: thanos-store
app.kubernetes.io/name: thanos-store
serviceName: thanos-store
template:
metadata:
labels:
app.kubernetes.io/component: object-store-gateway
app.kubernetes.io/instance: thanos-store
app.kubernetes.io/name: thanos-store
app.kubernetes.io/version: v0.10.1
spec:
containers:
- args:
- store
- --data-dir=/var/thanos/store
- --grpc-address=0.0.0.0:10901
- --http-address=0.0.0.0:10902
- --objstore.config=$(OBJSTORE_CONFIG)
- --experimental.enable-index-header
- --experimental.enable-index-cache-postings-compression
- |-
--index-cache.config="config":
"addresses": []
"dns_provider_update_interval": "0s"
"max_async_buffer_size": 0
"max_async_concurrency": 0
"max_get_multi_batch_size": 0
"max_get_multi_concurrency": 0
"max_idle_connections": 0
"max_item_size": "1MiB"
"timeout": "0s"
"type": "MEMCACHED"
env:
- name: OBJSTORE_CONFIG
valueFrom:
secretKeyRef:
key: thanos.yaml
name: thanos-objectstorage
image: quay.io/thanos/thanos:v0.10.1
livenessProbe:
failureThreshold: 8
httpGet:
path: /-/healthy
port: 10902
scheme: HTTP
periodSeconds: 30
name: thanos-store
ports:
- containerPort: 10901
name: grpc
- containerPort: 10902
name: http
readinessProbe:
failureThreshold: 20
httpGet:
path: /-/ready
port: 10902
scheme: HTTP
periodSeconds: 5
terminationMessagePolicy: FallbackToLogsOnError
volumeMounts:
- mountPath: /var/thanos/store
name: data
readOnly: false
terminationGracePeriodSeconds: 120
volumes: []
volumeClaimTemplates:
- metadata:
labels:
app.kubernetes.io/component: object-store-gateway
app.kubernetes.io/instance: thanos-store
app.kubernetes.io/name: thanos-store
name: data
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
50 changes: 50 additions & 0 deletions jsonnet/kube-thanos/kube-thanos-store.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,56 @@ local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet';
},
},

withMemcachedIndexCache:: {
local ts = self,
config+:: {
memcached+: {
addresses: error 'must provide memcached addresses',
timeout: '0s',
maxIdleConnections: 0,
maxAsyncConcurrency: 0,
maxAsyncBufferSize: 0,
maxItemSize: '1MiB',
maxGetMultiConcurrency: 0,
maxGetMultiBatchSize: 0,
dnsProviderUpdateInterval: '0s',
},
},
local m = ts.config.memcached,
local cfg =
{
type: 'MEMCACHED',
config: {
addresses: m.addresses,
timeout: m.timeout,
max_idle_connections: m.maxIdleConnections,
max_async_concurrency: m.maxAsyncConcurrency,
max_async_buffer_size: m.maxGetMultiBatchSize,
max_item_size: m.maxItemSize,
max_get_multi_concurrency: m.maxGetMultiConcurrency,
max_get_multi_batch_size: m.maxGetMultiBatchSize,
dns_provider_update_interval: m.dnsProviderUpdateInterval,
},
},
statefulSet+: {
spec+: {
template+: {
spec+: {
containers: [
if c.name == 'thanos-store' then c {
args+: [
'--experimental.enable-index-cache-postings-compression',
'--index-cache.config=' + std.manifestYamlDoc(cfg),
],
} else c
for c in super.containers
],
},
},
},
},
},

withServiceMonitor:: {
local ts = self,
serviceMonitor: {
Expand Down

0 comments on commit 7b4eee9

Please sign in to comment.