1local k = import 'ksonnet-util/kausal.libsonnet';
2
3{
4  local with(x) = if $._config.wal_enabled then x else {},
5
6  _config+:: {
7    stateful_ingesters: if $._config.wal_enabled then true else super.stateful_ingesters,
8    loki+: with({
9      ingester+: {
10        // disables transfers when running as statefulsets.
11        // pod rolling stragety will always fail transfers
12        // and the WAL supersedes this.
13        max_transfer_retries: 0,
14        wal+: {
15          enabled: true,
16          dir: '/loki/wal',
17          replay_memory_ceiling: '7GB',  // should be set upto ~50% of available memory
18        },
19      },
20    }),
21  },
22
23  local pvc = k.core.v1.persistentVolumeClaim,
24
25  ingester_wal_pvc:: with(
26    pvc.new('ingester-wal') +
27    pvc.mixin.spec.resources.withRequests({ storage: '150Gi' }) +
28    pvc.mixin.spec.withAccessModes(['ReadWriteOnce']) +
29    pvc.mixin.spec.withStorageClassName($._config.ingester_pvc_class)
30  ),
31
32  local container = k.core.v1.container,
33  local volumeMount = k.core.v1.volumeMount,
34
35  ingester_container+:: with(
36    k.util.resourcesRequests('1', '7Gi') +
37    k.util.resourcesLimits('2', '14Gi') +
38    container.withVolumeMountsMixin([
39      volumeMount.new('ingester-wal', $._config.loki.ingester.wal.dir),
40    ]),
41  ),
42
43
44  local statefulSet = k.apps.v1.statefulSet,
45  ingester_statefulset+: with(
46    statefulSet.spec.withVolumeClaimTemplatesMixin($.ingester_wal_pvc),
47  ),
48
49}
50