Skip to content

Commit 5e28950

Browse files
feat(compactor HS): add jsonnet for deploying horizontally scalable compactor (#18550)
1 parent ca33a82 commit 5e28950

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

production/ksonnet/loki/images.libsonnet

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
query_scheduler:: self.loki,
1515
ruler:: self.loki,
1616
compactor:: self.loki,
17+
compactor_worker:: self.loki,
1718
index_gateway:: self.loki,
1819
overrides_exporter:: self.loki,
1920
bloom_gateway:: self.loki,

production/ksonnet/loki/shipper.libsonnet

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
local statefulSet = k.apps.v1.statefulSet,
77
local service = k.core.v1.service,
88
local containerPort = k.core.v1.containerPort,
9+
local deployment = k.apps.v1.deployment,
910

1011
_config+:: {
1112
// flag for tuning things when boltdb-shipper is current or upcoming index type.
@@ -14,6 +15,7 @@
1415
using_shipper_store: $._config.using_boltdb_shipper || $._config.using_tsdb_shipper,
1516

1617
stateful_queriers: if self.using_shipper_store && !self.use_index_gateway then true else super.stateful_queriers,
18+
enable_horizontally_scalable_compactor: false,
1719

1820
compactor_pvc_size: '10Gi',
1921
compactor_pvc_class: 'fast',
@@ -47,8 +49,10 @@
4749
pvc.mixin.spec.withStorageClassName($._config.compactor_pvc_class)
4850
else {},
4951

50-
compactor_args:: if $._config.using_shipper_store then $._config.commonArgs {
52+
compactor_args:: if !$._config.using_shipper_store then {} else $._config.commonArgs {
5153
target: 'compactor',
54+
} + if $._config.enable_horizontally_scalable_compactor then {
55+
'compactor.horizontal-scaling-mode': 'main',
5256
} else {},
5357

5458
compactor_ports:: $.util.defaultPorts,
@@ -79,4 +83,35 @@
7983
compactor_service: if $._config.using_shipper_store then
8084
k.util.serviceFor($.compactor_statefulset, $._config.service_ignored_labels)
8185
else {},
86+
87+
local compactor_worker_enabled = $._config.using_shipper_store && $._config.enable_horizontally_scalable_compactor,
88+
89+
compactor_worker_args:: if compactor_worker_enabled then $._config.commonArgs {
90+
target: 'compactor',
91+
'compactor.horizontal-scaling-mode': 'worker',
92+
},
93+
94+
compactor_worker_container:: if !compactor_worker_enabled then {} else
95+
container.new('compactor-worker', $._images.compactor_worker) +
96+
container.withPorts($.util.defaultPorts) +
97+
container.withArgsMixin(k.util.mapToFlags($.compactor_worker_args)) +
98+
container.mixin.readinessProbe.httpGet.withPath('/ready') +
99+
container.mixin.readinessProbe.httpGet.withPort($._config.http_listen_port) +
100+
container.mixin.readinessProbe.withTimeoutSeconds(1) +
101+
container.withEnvMixin($._config.commonEnvs) +
102+
$.jaeger_mixin +
103+
k.util.resourcesRequests('1', '500Mi') +
104+
k.util.resourcesLimits('2', '1Gi') +
105+
container.withEnvMixin($._config.commonEnvs),
106+
107+
compactor_worker_deployment: if !compactor_worker_enabled then {} else
108+
deployment.new('compactor-worker', 1, [$.compactor_worker_container]) +
109+
$.config_hash_mixin +
110+
k.util.configVolumeMount('loki', '/etc/loki/config') +
111+
k.util.configVolumeMount(
112+
$._config.overrides_configmap_mount_name,
113+
$._config.overrides_configmap_mount_path,
114+
) +
115+
deployment.mixin.spec.strategy.rollingUpdate.withMaxSurge('15%') +
116+
deployment.mixin.spec.strategy.rollingUpdate.withMaxUnavailable('15%'),
82117
}

0 commit comments

Comments
 (0)