grafana / loki

Like Prometheus, but for logs.
https://grafana.com/loki
GNU Affero General Public License v3.0
23.35k stars 3.38k forks source link

Resources for `memcached` cannot be configured #13755

Open StefanKock opened 1 month ago

StefanKock commented 1 month ago

Describe the bug Resources for memcached are ignored.

Possible solution Probably a coding error in https://github.com/grafana/loki/blob/helm-loki-6.7.4/production/helm/loki/templates/memcached/_memcached-statefulset.tpl#L93

Fix it maybe with:

{{- if $.ctx.Values.memcached.resources }}
            {{- toYaml $.ctx.Values.memcached.resources | nindent 12 }}

To Reproduce Steps to reproduce the behavior:

  1. Add the following paragraph to the Helm values:
    memcached:
    image:
    # Setting pullPolicy works
    pullPolicy: Always
    # Setting resources does not work
    resources:
    limits:
      memory: 10Gi
    requests:
      cpu: 500m
      memory: 1Gi
  2. Template helm values: helm template grafana/loki -f my-values.loki.yaml --version 6.7.4
  3. See in the templated result that resources are not applied:

    ---
    # Source: loki/templates/chunks-cache/statefulset-chunks-cache.yaml
    apiVersion: apps/v1
    kind: StatefulSet
    metadata:
    name: release-name-loki-chunks-cache
    labels:
    helm.sh/chart: loki-6.7.4
    app.kubernetes.io/name: loki
    app.kubernetes.io/instance: release-name
    app.kubernetes.io/version: "3.1.0"
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: "memcached-chunks-cache"
    name: "memcached-chunks-cache"
    annotations:
    {}
    spec:
    podManagementPolicy: Parallel
    replicas: 1
    selector:
    matchLabels:
      app.kubernetes.io/name: loki
      app.kubernetes.io/instance: release-name
      app.kubernetes.io/component: "memcached-chunks-cache"
      name: "memcached-chunks-cache"
    updateStrategy:
    type: RollingUpdate
    serviceName: release-name-loki-chunks-cache
    
    template:
    metadata:
      labels:
        app.kubernetes.io/name: loki
        app.kubernetes.io/instance: release-name
        app.kubernetes.io/component: "memcached-chunks-cache"
        name: "memcached-chunks-cache"
      annotations:
    spec:
    # /../
      containers:
        - name: memcached
          image: memcached:1.6.23-alpine
          imagePullPolicy: Always
          resources:
            limits:
              memory: 9830Mi
            requests:
              cpu: 500m
              memory: 9830Mi
    # /../

Expected behavior memcached resources block can be overridden.

# /../
      containers:
        - name: memcached
          resources:
            limits:
              memory: 10Gi
            requests:
              cpu: 500m
              memory: 1Gi
# /../

Environment:

Screenshots, Promtail config, or terminal output If applicable, add any output to help explain your problem.

rknightion commented 1 month ago

In newer versions of the chart I thought you had to configure the resources in chunksCache/resultsCache sections (setting those there is working okay for us in SSD mode). the memcached section is for image related settings I think.

Resources are then auto-generated based on the max memory option but can be overridden https://github.com/grafana/loki/blob/main/production/helm/loki/values.yaml#L3050