Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit ed81ea9

Browse files
authored
Add jsonnet for ingester StatefulSet with WAL (#72)
* Add jsonnet for ingester StatefulSet with WAL Signed-off-by: Ganesh Vernekar <[email protected]> * Add CHANGELOG entry Signed-off-by: Ganesh Vernekar <[email protected]> * Fix lint Signed-off-by: Ganesh Vernekar <[email protected]> * Fix review comments Signed-off-by: Ganesh Vernekar <[email protected]>
1 parent 84512ae commit ed81ea9

File tree

3 files changed

+81
-14
lines changed

3 files changed

+81
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## master / unreleased
44

55
* [CHANGE] Add overrides config to tsdb store-gateway. #167
6+
* [CHANGE] Ingesters now default to running as `StatefulSet` with WAL enabled. It is controlled by the config `$._config.ingester_deployment_without_wal` which is `false` by default. Setting the config to `true` will yeild the old behaviour (stateless `Deployment` without WAL enabled). #72
67

78
## 1.3.0 / 2020-08-21
89

cortex/config.libsonnet

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,17 @@
6363

6464
store_gateway_replication_factor: 3,
6565

66+
// By default ingesters will be run as StatefulSet with WAL.
67+
// If this is set to true, ingesters will use staless deployments without WAL.
68+
ingester_deployment_without_wal: false,
69+
70+
ingester: {
71+
// These config options are only for the chunks storage.
72+
wal_dir: '/wal_data',
73+
statefulset_replicas: 3,
74+
statefulset_disk: '150Gi',
75+
},
76+
6677
// Blocks storage engine doesn't require the table manager.
6778
// When running blocks with chunks as secondary storage engine for querier only, we need table-manager to apply
6879
// retention policies.

cortex/ingester.libsonnet

Lines changed: 69 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{
2-
local container = $.core.v1.container,
3-
42
ingester_args::
53
$._config.ringConfig +
64
$._config.storeConfig +
@@ -40,9 +38,20 @@
4038
else {}
4139
),
4240

41+
ingester_statefulset_args:: {
42+
'ingester.wal-enabled': true,
43+
'ingester.checkpoint-enabled': true,
44+
'ingester.recover-from-wal': true,
45+
'ingester.wal-dir': $._config.ingester.wal_dir,
46+
'ingester.checkpoint-duration': '15m',
47+
'-log.level': 'info',
48+
'ingester.tokens-file-path': $._config.ingester.wal_dir + '/tokens',
49+
},
50+
4351
ingester_ports:: $.util.defaultPorts,
4452

4553
local name = 'ingester',
54+
local container = $.core.v1.container,
4655

4756
ingester_container::
4857
container.new(name, $._images.ingester) +
@@ -53,26 +62,72 @@
5362
$.util.readinessProbe +
5463
$.jaeger_mixin,
5564

56-
local deployment = $.apps.v1.deployment,
65+
local volumeMount = $.core.v1.volumeMount,
66+
67+
ingester_statefulset_container::
68+
$.ingester_container +
69+
container.withArgsMixin($.util.mapToFlags($.ingester_statefulset_args)) +
70+
container.withVolumeMountsMixin([
71+
volumeMount.new('ingester-pvc', $._config.ingester.wal_dir),
72+
]),
5773

5874
ingester_deployment_labels:: {},
5975

76+
local pvc = $.core.v1.persistentVolumeClaim,
77+
local volume = $.core.v1.volume,
78+
local statefulSet = $.apps.v1.statefulSet,
79+
80+
local ingester_pvc =
81+
pvc.new('ingester-pvc') +
82+
pvc.mixin.spec.resources.withRequests({ storage: $._config.ingester.statefulset_disk }) +
83+
pvc.mixin.spec.withAccessModes(['ReadWriteOnce']) +
84+
pvc.mixin.spec.withStorageClassName('fast'),
85+
86+
statefulset_storage_config_mixin::
87+
statefulSet.mixin.spec.template.metadata.withAnnotationsMixin({ schemaID: $._config.schemaID },) +
88+
$.util.configVolumeMount('schema-' + $._config.schemaID, '/etc/cortex/schema'),
89+
90+
ingester_statefulset:
91+
if $._config.ingester_deployment_without_wal == false then
92+
statefulSet.new('ingester', $._config.ingester.statefulset_replicas, [$.ingester_statefulset_container], ingester_pvc) +
93+
statefulSet.mixin.spec.withServiceName('ingester') +
94+
statefulSet.mixin.spec.template.spec.withVolumes([volume.fromPersistentVolumeClaim('ingester-pvc', 'ingester-pvc')]) +
95+
statefulSet.mixin.metadata.withNamespace($._config.namespace) +
96+
statefulSet.mixin.metadata.withLabels({ name: 'ingester' }) +
97+
statefulSet.mixin.spec.template.metadata.withLabels({ name: 'ingester' } + $.ingester_deployment_labels) +
98+
statefulSet.mixin.spec.selector.withMatchLabels({ name: 'ingester' }) +
99+
statefulSet.mixin.spec.template.spec.securityContext.withRunAsUser(0) +
100+
statefulSet.mixin.spec.template.spec.withTerminationGracePeriodSeconds(4800) +
101+
statefulSet.mixin.spec.updateStrategy.withType('RollingUpdate') +
102+
$.statefulset_storage_config_mixin +
103+
$.util.configVolumeMount('overrides', '/etc/cortex') +
104+
$.util.podPriority('high') +
105+
$.util.antiAffinityStatefulSet
106+
else null,
107+
108+
local deployment = $.apps.v1.deployment,
109+
60110
ingester_deployment:
61-
deployment.new(name, 3, [$.ingester_container], $.ingester_deployment_labels) +
62-
$.util.antiAffinity +
63-
$.util.configVolumeMount('overrides', '/etc/cortex') +
64-
deployment.mixin.metadata.withLabels({ name: name }) +
65-
deployment.mixin.spec.withMinReadySeconds(60) +
66-
deployment.mixin.spec.strategy.rollingUpdate.withMaxSurge(0) +
67-
deployment.mixin.spec.strategy.rollingUpdate.withMaxUnavailable(1) +
68-
deployment.mixin.spec.template.spec.withTerminationGracePeriodSeconds(4800) +
69-
$.storage_config_mixin +
70-
$.util.podPriority('high'),
111+
if $._config.ingester_deployment_without_wal then
112+
deployment.new(name, 3, [$.ingester_container], $.ingester_deployment_labels) +
113+
$.util.antiAffinity +
114+
$.util.configVolumeMount('overrides', '/etc/cortex') +
115+
deployment.mixin.metadata.withLabels({ name: name }) +
116+
deployment.mixin.spec.withMinReadySeconds(60) +
117+
deployment.mixin.spec.strategy.rollingUpdate.withMaxSurge(0) +
118+
deployment.mixin.spec.strategy.rollingUpdate.withMaxUnavailable(1) +
119+
deployment.mixin.spec.template.spec.withTerminationGracePeriodSeconds(4800) +
120+
$.storage_config_mixin +
121+
$.util.podPriority('high')
122+
else null,
71123

72124
ingester_service_ignored_labels:: [],
73125

74126
ingester_service:
75-
$.util.serviceFor($.ingester_deployment, $.ingester_service_ignored_labels),
127+
if $._config.ingester_deployment_without_wal then
128+
$.util.serviceFor($.ingester_deployment, $.ingester_service_ignored_labels)
129+
else
130+
$.util.serviceFor($.ingester_statefulset, $.ingester_service_ignored_labels),
76131

77132
local podDisruptionBudget = $.policy.v1beta1.podDisruptionBudget,
78133

0 commit comments

Comments
 (0)