diff --git a/all.jsonnet b/all.jsonnet index aae9beb9..ad72a7a2 100644 --- a/all.jsonnet +++ b/all.jsonnet @@ -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', @@ -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 } diff --git a/examples/all/manifests/thanos-store-statefulSet-with-memcached.yaml b/examples/all/manifests/thanos-store-statefulSet-with-memcached.yaml new file mode 100644 index 00000000..abfcfa7d --- /dev/null +++ b/examples/all/manifests/thanos-store-statefulSet-with-memcached.yaml @@ -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 diff --git a/jsonnet/kube-thanos/kube-thanos-store.libsonnet b/jsonnet/kube-thanos/kube-thanos-store.libsonnet index 89192b29..a2838e96 100644 --- a/jsonnet/kube-thanos/kube-thanos-store.libsonnet +++ b/jsonnet/kube-thanos/kube-thanos-store.libsonnet @@ -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: {