Skip to content

Commit

Permalink
sts rulers (#3179)
Browse files Browse the repository at this point in the history
  • Loading branch information
owen-d authored Jan 15, 2021
1 parent 28c0b31 commit 5b6d64c
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 9 deletions.
5 changes: 5 additions & 0 deletions production/ksonnet/loki/boltdb_shipper.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
'boltdb.shipper.cache-location': '/data/boltdb-cache',
} else {},

ruler_args+:: if $._config.using_boltdb_shipper then {
// Use PVC for caching
'boltdb.shipper.cache-location': '/data/boltdb-cache',
} else {},

// we don't dedupe index writes when using boltdb-shipper so don't deploy a cache for it.
memcached_index_writes: if $._config.using_boltdb_shipper then {} else super.memcached_index_writes,

Expand Down
4 changes: 4 additions & 0 deletions production/ksonnet/loki/config.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
querier_pvc_size: '10Gi',
querier_pvc_class: 'fast',

stateful_rulers: false,
ruler_pvc_size: '10Gi',
ruler_pvc_class: 'fast',

compactor_pvc_size: '10Gi',
compactor_pvc_class: 'fast',

Expand Down
45 changes: 36 additions & 9 deletions production/ksonnet/loki/ruler.libsonnet
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
local container = $.core.v1.container,
local pvc = $.core.v1.persistentVolumeClaim,
local statefulSet = $.apps.v1.statefulSet,
local deployment = $.apps.v1.deployment,
local volumeMount = $.core.v1.volumeMount,

ruler_args:: $._config.commonArgs {
target: 'ruler',
Expand All @@ -13,13 +17,15 @@
$.util.resourcesRequests('1', '6Gi') +
$.util.resourcesLimits('16', '16Gi') +
$.util.readinessProbe +
$.jaeger_mixin
$.jaeger_mixin +
if $._config.stateful_rulers then
container.withVolumeMountsMixin([
volumeMount.new('ruler-data', '/data'),
]) else {}
else {},

local deployment = $.apps.v1.deployment,

ruler_deployment:
if $._config.ruler_enabled then
if $._config.ruler_enabled && !$._config.stateful_rulers then
deployment.new('ruler', 2, [$.ruler_container]) +
deployment.mixin.spec.template.spec.withTerminationGracePeriodSeconds(600) +
$.config_hash_mixin +
Expand All @@ -28,10 +34,31 @@
$.util.antiAffinity
else {},

local service = $.core.v1.service,
ruler_service: if !$._config.ruler_enabled
then {}
else
if $._config.stateful_rulers
then $.util.serviceFor($.ruler_statefulset)
else $.util.serviceFor($.ruler_deployment),

ruler_service:
if $._config.ruler_enabled then
$.util.serviceFor($.ruler_deployment)
else {},

// PVC for rulers when running as statefulsets
ruler_data_pvc:: if $._config.ruler_enabled && $._config.stateful_rulers then
pvc.new('ruler-data') +
pvc.mixin.spec.resources.withRequests({ storage: $._config.ruler_pvc_size }) +
pvc.mixin.spec.withAccessModes(['ReadWriteOnce']) +
pvc.mixin.spec.withStorageClassName($._config.ruler_pvc_class)
else {},

ruler_statefulset: if $._config.ruler_enabled && $._config.stateful_rulers then
statefulSet.new('ruler', 2, [$.ruler_container], $.ruler_data_pvc) +
statefulSet.mixin.spec.withServiceName('ruler') +
statefulSet.mixin.spec.withPodManagementPolicy('Parallel') +
$.config_hash_mixin +
$.util.configVolumeMount('loki', '/etc/loki/config') +
$.util.configVolumeMount('overrides', '/etc/loki/overrides') +
$.util.antiAffinity +
statefulSet.mixin.spec.updateStrategy.withType('RollingUpdate') +
statefulSet.mixin.spec.template.spec.securityContext.withFsGroup(10001) // 10001 is the group ID assigned to Loki in the Dockerfile
else {},
}

0 comments on commit 5b6d64c

Please sign in to comment.