Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add jsonnet for ingester StatefulSet with WAL #72

Merged
merged 5 commits into from
Aug 26, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## master / unreleased

* [CHANGE] Add overrides config to tsdb store-gateway. #167
* [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

## 1.3.0 / 2020-08-21

Expand Down
4 changes: 4 additions & 0 deletions cortex/config.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@

store_gateway_replication_factor: 3,

// By default ingesters will be run as StatefulSet with WAL.
// If this is set to true, ingesters will use staless deployments without WAL.
ingester_deployment_without_wal: false,

// Blocks storage engine doesn't require the table manager.
// When running blocks with chunks as secondary storage engine for querier only, we need table-manager to apply
// retention policies.
Expand Down
91 changes: 77 additions & 14 deletions cortex/ingester.libsonnet
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
local container = $.core.v1.container,

ingester_args::
$._config.ringConfig +
$._config.storeConfig +
Expand Down Expand Up @@ -40,9 +38,28 @@
else {}
),

ingester_statefulset_args:: {
'ingester.wal-enabled': true,
'ingester.checkpoint-enabled': true,
'ingester.recover-from-wal': true,
'ingester.wal-dir': $._config.wal_dir,
'ingester.checkpoint-duration': '15m',
'-log.level': 'info',
'ingester.tokens-file-path': $._config.wal_dir + '/tokens',
},

_config+:: {
wal_dir: '/wal_data',
ingester+: {
statefulset_replicas: 3,
statefulset_disk: '150Gi',
},
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this go directly to config.libsonnet?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also moved wal_dir inside _config.ingester where it made most sense. Will merge on green.


ingester_ports:: $.util.defaultPorts,

local name = 'ingester',
local container = $.core.v1.container,

ingester_container::
container.new(name, $._images.ingester) +
Expand All @@ -53,26 +70,72 @@
$.util.readinessProbe +
$.jaeger_mixin,

local deployment = $.apps.v1.deployment,
local volumeMount = $.core.v1.volumeMount,

ingester_statefulset_container::
$.ingester_container +
container.withArgsMixin($.util.mapToFlags($.ingester_statefulset_args)) +
container.withVolumeMountsMixin([
volumeMount.new('ingester-pvc', $._config.wal_dir),
]),

ingester_deployment_labels:: {},

local pvc = $.core.v1.persistentVolumeClaim,
local volume = $.core.v1.volume,
local statefulSet = $.apps.v1.statefulSet,

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'),

statefulset_storage_config_mixin::
statefulSet.mixin.spec.template.metadata.withAnnotationsMixin({ schemaID: $._config.schemaID },) +
$.util.configVolumeMount('schema-' + $._config.schemaID, '/etc/cortex/schema'),

ingester_statefulset:
if $._config.ingester_deployment_without_wal == false then
statefulSet.new('ingester', $._config.ingester.statefulset_replicas, [$.ingester_statefulset_container], ingester_pvc) +
statefulSet.mixin.spec.withServiceName('ingester') +
statefulSet.mixin.spec.template.spec.withVolumes([volume.fromPersistentVolumeClaim('ingester-pvc', 'ingester-pvc')]) +
statefulSet.mixin.metadata.withNamespace($._config.namespace) +
statefulSet.mixin.metadata.withLabels({ name: 'ingester' }) +
statefulSet.mixin.spec.template.metadata.withLabels({ name: 'ingester' } + $.ingester_deployment_labels) +
statefulSet.mixin.spec.selector.withMatchLabels({ name: 'ingester' }) +
statefulSet.mixin.spec.template.spec.securityContext.withRunAsUser(0) +
statefulSet.mixin.spec.template.spec.withTerminationGracePeriodSeconds(4800) +
statefulSet.mixin.spec.updateStrategy.withType('RollingUpdate') +
$.statefulset_storage_config_mixin +
$.util.configVolumeMount('overrides', '/etc/cortex') +
$.util.podPriority('high') +
$.util.antiAffinityStatefulSet
else null,

local deployment = $.apps.v1.deployment,

ingester_deployment:
deployment.new(name, 3, [$.ingester_container], $.ingester_deployment_labels) +
$.util.antiAffinity +
$.util.configVolumeMount('overrides', '/etc/cortex') +
deployment.mixin.metadata.withLabels({ name: name }) +
deployment.mixin.spec.withMinReadySeconds(60) +
deployment.mixin.spec.strategy.rollingUpdate.withMaxSurge(0) +
deployment.mixin.spec.strategy.rollingUpdate.withMaxUnavailable(1) +
deployment.mixin.spec.template.spec.withTerminationGracePeriodSeconds(4800) +
$.storage_config_mixin +
$.util.podPriority('high'),
if $._config.ingester_deployment_without_wal then
deployment.new(name, 3, [$.ingester_container], $.ingester_deployment_labels) +
$.util.antiAffinity +
$.util.configVolumeMount('overrides', '/etc/cortex') +
deployment.mixin.metadata.withLabels({ name: name }) +
deployment.mixin.spec.withMinReadySeconds(60) +
deployment.mixin.spec.strategy.rollingUpdate.withMaxSurge(0) +
deployment.mixin.spec.strategy.rollingUpdate.withMaxUnavailable(1) +
deployment.mixin.spec.template.spec.withTerminationGracePeriodSeconds(4800) +
$.storage_config_mixin +
$.util.podPriority('high')
else null,

ingester_service_ignored_labels:: [],

ingester_service:
$.util.serviceFor($.ingester_deployment, $.ingester_service_ignored_labels),
if $._config.ingester_deployment_without_wal then
$.util.serviceFor($.ingester_deployment, $.ingester_service_ignored_labels)
else
$.util.serviceFor($.ingester_statefulset, $.ingester_service_ignored_labels),

local podDisruptionBudget = $.policy.v1beta1.podDisruptionBudget,

Expand Down