forked from grafana/cortex-jsonnet
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathingester.libsonnet
More file actions
116 lines (98 loc) · 4.77 KB
/
ingester.libsonnet
File metadata and controls
116 lines (98 loc) · 4.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
{
local podDisruptionBudget = $.policy.v1.podDisruptionBudget,
local pvc = $.core.v1.persistentVolumeClaim,
local statefulSet = $.apps.v1.statefulSet,
local volume = $.core.v1.volume,
local volumeMount = $.core.v1.volumeMount,
// The ingesters should persist TSDB blocks and WAL on a persistent
// volume in order to be crash resilient.
local ingester_data_pvc =
pvc.new() +
pvc.mixin.spec.resources.withRequests({ storage: $._config.cortex_ingester_data_disk_size }) +
pvc.mixin.spec.withAccessModes(['ReadWriteOnce']) +
pvc.mixin.spec.withStorageClassName($._config.cortex_ingester_data_disk_class) +
pvc.mixin.metadata.withName('ingester-data'),
ingester_args::
$._config.grpcConfig +
$._config.ringConfig +
$._config.blocksStorageConfig +
$._config.distributorConfig + // This adds the distributor ring flags to the ingester.
$._config.ingesterLimitsConfig +
{
target: 'ingester',
// Ring config.
'ingester.num-tokens': 512,
'ingester.join-after': '0s',
'ingester.heartbeat-period': '15s',
'ingester.unregister-on-shutdown': $._config.unregister_ingesters_on_shutdown,
// Limits config.
'runtime-config.file': '/etc/cortex/overrides.yaml',
'server.grpc-max-concurrent-streams': 10000,
'server.grpc-max-send-msg-size-bytes': 10 * 1024 * 1024,
'server.grpc-max-recv-msg-size-bytes': 10 * 1024 * 1024,
'blocks-storage.tsdb.dir': '/data/tsdb',
'blocks-storage.tsdb.block-ranges-period': '2h',
'blocks-storage.tsdb.head-chunks-write-queue-size': 1e6,
'blocks-storage.tsdb.retention-period': '96h', // 4 days protection against blocks not being uploaded from ingesters.
'blocks-storage.tsdb.ship-interval': '1m',
// Persist ring tokens so that when the ingester will be restarted
// it will pick the same tokens
'ingester.tokens-file-path': '/data/tokens',
},
ingester_ports:: $.util.defaultPorts,
local name = 'ingester',
local container = $.core.v1.container,
local envType = container.envType,
ingester_container::
container.new(name, $._images.ingester) +
container.withPorts($.ingester_ports) +
container.withArgsMixin($.util.mapToFlags($.ingester_args)) +
container.withEnvMap($.ingester_env_map) +
$.util.resourcesRequests('4', '15Gi') +
$.util.resourcesLimits(null, '25Gi') +
$.util.readinessProbe +
$.go_container_mixin +
$.jaeger_mixin,
ingester_deployment_labels:: {},
ingester_env_map:: {
},
local ingester_pvc =
pvc.new('ingester-pvc') +
pvc.mixin.spec.resources.withRequests({ storage: $._config.ingester.statefulset_disk }) +
pvc.mixin.spec.withAccessModes(['ReadWriteOnce']) +
pvc.mixin.spec.withStorageClassName('fast'),
ingester_service_ignored_labels:: [],
newIngesterPdb(pdbName, ingesterName)::
podDisruptionBudget.new(pdbName) +
podDisruptionBudget.mixin.metadata.withLabels({ name: pdbName }) +
podDisruptionBudget.mixin.spec.selector.withMatchLabels({ name: ingesterName }) +
podDisruptionBudget.mixin.spec.withMaxUnavailable(1),
ingester_pdb: self.newIngesterPdb('ingester-pdb', name),
newIngesterStatefulSet(name, container, with_anti_affinity=true)::
statefulSet.new(name, 3, [
container + $.core.v1.container.withVolumeMountsMixin([
volumeMount.new('ingester-data', '/data'),
]),
], ingester_data_pvc) +
statefulSet.mixin.spec.withServiceName(name) +
statefulSet.mixin.metadata.withNamespace($._config.namespace) +
statefulSet.mixin.metadata.withLabels({ name: name }) +
statefulSet.mixin.spec.template.metadata.withLabels({ name: name } + $.ingester_deployment_labels) +
statefulSet.mixin.spec.selector.withMatchLabels({ name: name }) +
statefulSet.mixin.spec.template.spec.securityContext.withRunAsUser(0) +
// When the ingester needs to flush blocks to the storage, it may take quite a lot of time.
// For this reason, we grant an high termination period (80 minutes).
statefulSet.mixin.spec.template.spec.withTerminationGracePeriodSeconds(1200) +
statefulSet.mixin.spec.updateStrategy.withType('RollingUpdate') +
$.util.configVolumeMount($._config.overrides_configmap, '/etc/cortex') +
$.util.podPriority('high') +
// Parallelly scale up/down ingester instances instead of starting them
// one by one. This does NOT affect rolling updates: they will continue to be
// rolled out one by one (the next pod will be rolled out once the previous is
// ready).
statefulSet.mixin.spec.withPodManagementPolicy('Parallel') +
(if with_anti_affinity then $.util.antiAffinity else {}),
ingester_statefulset: self.newIngesterStatefulSet('ingester', $.ingester_container),
ingester_service:
$.util.serviceFor($.ingester_statefulset, $.ingester_service_ignored_labels),
}