Skip to content

Instantly share code, notes, and snippets.

@metalmatze
Created February 5, 2020 15:54
Show Gist options
  • Save metalmatze/7280c8101024d0edbccd5fbedb82a2c1 to your computer and use it in GitHub Desktop.
Save metalmatze/7280c8101024d0edbccd5fbedb82a2c1 to your computer and use it in GitHub Desktop.
diff --git a/kubernetes/monitoring/thanos.yaml b/kubernetes/monitoring/thanos.yaml
index 0f8079b..fed4781 100644
--- a/kubernetes/monitoring/thanos.yaml
+++ b/kubernetes/monitoring/thanos.yaml
@@ -4,31 +4,53 @@ items:
kind: Deployment
metadata:
labels:
- app.kubernetes.io/name: thanos-querier
+ app.kubernetes.io/component: thanos-query
+ app.kubernetes.io/instance: thanos-querier
+ app.kubernetes.io/name: thanos
+ app.kubernetes.io/version: v0.10.1
name: thanos-querier
namespace: monitoring
spec:
replicas: 3
selector:
matchLabels:
- app.kubernetes.io/name: thanos-querier
+ app.kubernetes.io/component: thanos-query
+ app.kubernetes.io/instance: thanos-querier
+ app.kubernetes.io/name: thanos
template:
metadata:
labels:
- app.kubernetes.io/name: thanos-querier
+ app.kubernetes.io/component: thanos-query
+ app.kubernetes.io/instance: thanos-querier
+ app.kubernetes.io/name: thanos
+ app.kubernetes.io/version: v0.10.1
spec:
+ affinity:
+ podAntiAffinity:
+ preferredDuringSchedulingIgnoredDuringExecution:
+ - podAffinityTerm:
+ labelSelector:
+ matchExpressions:
+ - key: app.kubernetes.io/name
+ operator: In
+ values:
+ - thanos
+ namespaces:
+ - monitoring
+ topologyKey: kubernetes.io/hostname
+ weight: 100
containers:
- args:
- query
- - --query.replica-label=prometheus_replica
- --grpc-address=0.0.0.0:10901
- --http-address=0.0.0.0:9090
- - --web.route-prefix=/thanos
- - --web.external-prefix=/thanos
+ - --query.replica-label=prometheus_replica
+ - --query.replica-label=rule_replica
- --store=dnssrv+_grpc._tcp.thanos-store.monitoring.svc.cluster.local
- --store=dnssrv+_grpc._tcp.prometheus-operated.monitoring.svc.cluster.local
- --store=dnssrv+_grpc._tcp.thanos-ruler-metalmatze.monitoring.svc.cluster.local
- image: quay.io/thanos/thanos:v0.9.0
+ - --web.external-prefix=/thanos
+ image: quay.io/thanos/thanos:v0.10.1
livenessProbe:
failureThreshold: 4
httpGet:
@@ -36,32 +58,28 @@ items:
port: 9090
scheme: HTTP
periodSeconds: 30
- name: thanos-querier
+ name: thanos-query
ports:
- containerPort: 10901
name: grpc
- containerPort: 9090
name: http
readinessProbe:
+ failureThreshold: 20
httpGet:
path: /-/ready
port: 9090
scheme: HTTP
- initialDelaySeconds: 10
- periodSeconds: 30
- resources:
- limits:
- cpu: "1"
- memory: 1Gi
- requests:
- cpu: 100m
- memory: 256Mi
+ periodSeconds: 5
terminationGracePeriodSeconds: 120
- apiVersion: v1
kind: Service
metadata:
labels:
- app.kubernetes.io/name: thanos-querier
+ app.kubernetes.io/component: thanos-query
+ app.kubernetes.io/instance: thanos-querier
+ app.kubernetes.io/name: thanos
+ app.kubernetes.io/version: v0.10.1
name: thanos-querier
namespace: monitoring
spec:
@@ -73,12 +91,17 @@ items:
port: 9090
targetPort: http
selector:
- app.kubernetes.io/name: thanos-querier
+ app.kubernetes.io/component: thanos-query
+ app.kubernetes.io/instance: thanos-querier
+ app.kubernetes.io/name: thanos
- apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
labels:
- prometheus: metalmatze
+ app.kubernetes.io/component: thanos-query
+ app.kubernetes.io/instance: thanos-querier
+ app.kubernetes.io/name: thanos
+ app.kubernetes.io/version: v0.10.1
name: thanos-querier
namespace: monitoring
spec:
@@ -86,12 +109,17 @@ items:
- port: http
selector:
matchLabels:
- app.kubernetes.io/name: thanos-querier
+ app.kubernetes.io/component: thanos-query
+ app.kubernetes.io/instance: thanos-querier
+ app.kubernetes.io/name: thanos
- apiVersion: v1
kind: Service
metadata:
labels:
- app.kubernetes.io/name: thanos-store
+ app.kubernetes.io/component: thanos-store
+ app.kubernetes.io/instance: thanos-store
+ app.kubernetes.io/name: thanos
+ app.kubernetes.io/version: v0.10.1
name: thanos-store
namespace: monitoring
spec:
@@ -104,12 +132,17 @@ items:
port: 10902
targetPort: 10902
selector:
- app.kubernetes.io/name: thanos-store
+ app.kubernetes.io/component: thanos-store
+ app.kubernetes.io/instance: thanos-store
+ app.kubernetes.io/name: thanos
- apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
labels:
- prometheus: metalmatze
+ app.kubernetes.io/component: thanos-store
+ app.kubernetes.io/instance: thanos-store
+ app.kubernetes.io/name: thanos
+ app.kubernetes.io/version: v0.10.1
name: thanos-store
namespace: monitoring
spec:
@@ -117,24 +150,34 @@ items:
- port: http
selector:
matchLabels:
- app.kubernetes.io/name: thanos-store
+ app.kubernetes.io/component: thanos-store
+ app.kubernetes.io/instance: thanos-store
+ app.kubernetes.io/name: thanos
- apiVersion: apps/v1
kind: StatefulSet
metadata:
labels:
- app.kubernetes.io/name: thanos-store
+ app.kubernetes.io/component: thanos-store
+ app.kubernetes.io/instance: thanos-store
+ app.kubernetes.io/name: thanos
+ app.kubernetes.io/version: v0.10.1
name: thanos-store
namespace: monitoring
spec:
replicas: 1
selector:
matchLabels:
- app.kubernetes.io/name: thanos-store
+ app.kubernetes.io/component: thanos-store
+ app.kubernetes.io/instance: thanos-store
+ app.kubernetes.io/name: thanos
serviceName: thanos-store
template:
metadata:
labels:
- app.kubernetes.io/name: thanos-store
+ app.kubernetes.io/component: thanos-store
+ app.kubernetes.io/instance: thanos-store
+ app.kubernetes.io/name: thanos
+ app.kubernetes.io/version: v0.10.1
spec:
containers:
- args:
@@ -149,9 +192,9 @@ items:
secretKeyRef:
key: thanos.yaml
name: thanos-objectstorage
- image: quay.io/thanos/thanos:v0.9.0
+ image: quay.io/thanos/thanos:v0.10.1
livenessProbe:
- failureThreshold: 4
+ failureThreshold: 8
httpGet:
path: /-/healthy
port: 10902
@@ -164,33 +207,36 @@ items:
- containerPort: 10902
name: http
readinessProbe:
+ failureThreshold: 20
httpGet:
path: /-/ready
port: 10902
scheme: HTTP
- initialDelaySeconds: 10
- periodSeconds: 30
+ periodSeconds: 5
resources:
limits:
cpu: "2"
memory: 8Gi
requests:
cpu: 500m
- memory: 1Gi
volumeMounts:
- mountPath: /var/thanos/store
- name: thanos-store-data
+ name: data
readOnly: false
terminationGracePeriodSeconds: 120
volumes:
- emptyDir: {}
- name: thanos-store-data
+ name: data
+ volumeClaimTemplates: null
- apiVersion: v1
kind: Service
metadata:
labels:
- app.kubernetes.io/name: thanos-compactor
- name: thanos-compactor
+ app.kubernetes.io/component: thanos-compact
+ app.kubernetes.io/instance: thanos-compact
+ app.kubernetes.io/name: thanos
+ app.kubernetes.io/version: v0.10.1
+ name: thanos-compact
namespace: monitoring
spec:
ports:
@@ -198,54 +244,70 @@ items:
port: 10902
targetPort: http
selector:
- app.kubernetes.io/name: thanos-compactor
+ app.kubernetes.io/component: thanos-compact
+ app.kubernetes.io/instance: thanos-compact
+ app.kubernetes.io/name: thanos
- apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
labels:
- prometheus: metalmatze
- name: thanos-compactor
+ app.kubernetes.io/component: thanos-compact
+ app.kubernetes.io/instance: thanos-compact
+ app.kubernetes.io/name: thanos
+ app.kubernetes.io/version: v0.10.1
+ name: thanos-compact
namespace: monitoring
spec:
endpoints:
- port: http
selector:
matchLabels:
- app.kubernetes.io/name: thanos-compactor
+ app.kubernetes.io/component: thanos-compact
+ app.kubernetes.io/instance: thanos-compact
+ app.kubernetes.io/name: thanos
- apiVersion: apps/v1
kind: StatefulSet
metadata:
labels:
- app.kubernetes.io/name: thanos-compactor
- name: thanos-compactor
+ app.kubernetes.io/component: thanos-compact
+ app.kubernetes.io/instance: thanos-compact
+ app.kubernetes.io/name: thanos
+ app.kubernetes.io/version: v0.10.1
+ name: thanos-compact
namespace: monitoring
spec:
replicas: 1
selector:
matchLabels:
- app.kubernetes.io/name: thanos-compactor
- serviceName: thanos-compactor
+ app.kubernetes.io/component: thanos-compact
+ app.kubernetes.io/instance: thanos-compact
+ app.kubernetes.io/name: thanos
+ serviceName: thanos-compact
template:
metadata:
labels:
- app.kubernetes.io/name: thanos-compactor
+ app.kubernetes.io/component: thanos-compact
+ app.kubernetes.io/instance: thanos-compact
+ app.kubernetes.io/name: thanos
+ app.kubernetes.io/version: v0.10.1
spec:
containers:
- args:
- compact
- --wait
+ - --objstore.config=$(OBJSTORE_CONFIG)
+ - --data-dir=/var/thanos/compact
+ - --debug.accept-malformed-index
- --retention.resolution-raw=16d
- --retention.resolution-5m=42d
- --retention.resolution-1h=180d
- - --objstore.config=$(OBJSTORE_CONFIG)
- - --data-dir=/var/thanos/compactor
env:
- name: OBJSTORE_CONFIG
valueFrom:
secretKeyRef:
key: thanos.yaml
name: thanos-objectstorage
- image: quay.io/thanos/thanos:v0.9.0
+ image: quay.io/thanos/thanos:v0.10.1
livenessProbe:
failureThreshold: 4
httpGet:
@@ -253,30 +315,24 @@ items:
port: 10902
scheme: HTTP
periodSeconds: 30
- name: thanos-compactor
+ name: thanos-compact
ports:
- containerPort: 10902
name: http
readinessProbe:
+ failureThreshold: 20
httpGet:
path: /-/ready
port: 10902
scheme: HTTP
- initialDelaySeconds: 10
- periodSeconds: 30
- resources:
- limits:
- cpu: 500m
- memory: 2Gi
- requests:
- cpu: 100m
- memory: 1Gi
+ periodSeconds: 5
volumeMounts:
- - mountPath: /var/thanos/compactor
- name: thanos-compactor-data
+ - mountPath: /var/thanos/compact
+ name: data
readOnly: false
terminationGracePeriodSeconds: 120
volumes:
- emptyDir: {}
- name: thanos-compactor-data
+ name: data
+ volumeClaimTemplates: null
kind: List
local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet';
local kt = {
local commonConfig = {
config+:: {
namespace: 'monitoring',
version: '0.10.1',
image: 'quay.io/thanos/thanos:v%s' % self.version,
objectStorageConfig: {
name: 'thanos-objectstorage',
key: 'thanos.yaml',
},
},
},
local query = (import 'kube-thanos/kube-thanos-query.libsonnet'),
query: query + query.withExternalPrefix + query.withServiceMonitor + commonConfig + {
config+:: {
name: 'thanos-querier',
replicas: 3,
replicaLabels: ['prometheus_replica', 'rule_replica'],
stores: [
'dnssrv+_grpc._tcp.thanos-store.monitoring.svc.cluster.local',
'dnssrv+_grpc._tcp.prometheus-operated.monitoring.svc.cluster.local',
'dnssrv+_grpc._tcp.thanos-ruler-metalmatze.monitoring.svc.cluster.local',
],
externalPrefix: '/thanos',
},
deployment+: {
// TODO: Need to do some more overwrites.
// Maybe more helpers like withExternalPrefix make sense!
},
},
local store = (import 'kube-thanos/kube-thanos-store.libsonnet'),
store: store + store.withResources + store.withServiceMonitor + commonConfig + {
config+:: {
name: 'thanos-store',
replicas: 1,
resources: {
limits: {
cpu: '2',
memory: '8Gi',
},
requests: {
cpu: '500m',
},
},
},
},
local compact = (import 'kube-thanos/kube-thanos-compact.libsonnet'),
compact: compact + compact.withRetention + compact.withServiceMonitor + commonConfig + {
config+:: {
name: 'thanos-compact',
retentionResolutionRaw: '16d',
retentionResolution5m: '42d',
retentionResolution1h: '180d',
},
},
};
k.core.v1.list.new(
[kt.query[o] for o in std.objectFields(kt.query)] +
[kt.store[o] for o in std.objectFields(kt.store)] +
[kt.compact[o] for o in std.objectFields(kt.compact)],
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment