grafana / helm-charts

Apache License 2.0
1.66k stars 2.28k forks source link

Documentation feedback for loki-distributed chart #171

Open Skaronator opened 3 years ago

Skaronator commented 3 years ago

Hi,

just switched to the loki distributed helm chart and it took a bit longer to get it up and running than I though. The overall readme is good so far. Also the examples are great but some little things could be improved to save a lot of time!

And thanks for the distributed helm chart. Feels so much better to run that in Kubernetes :100:

Skaronator commented 3 years ago

An example ruler configration would be great to. This is what it should look like:

    ruler:
      alertmanager_url: http://prometheus-alertmanager.monitoring.svc.cluster.local:80
      enable_alertmanager_v2: true
      enable_api: true
      enable_sharding: true
      rule_path: /tmp/loki/rules
      storage:
        type: local
        local:
          directory: /etc/loki/rules
      ring:
        kvstore:
          store: memberlist
rogercwang commented 3 years ago

The example configuration is also missing replication_factor: 1 while the default values.yaml includes it.

rogercwang commented 3 years ago

After some trail and error, I think the Gateway served as loki's service endpoint. We can set promtail, grafana, fluentd ... to use loki-distributed-gateway service. This service can distributes loki API requests to corresponding service according to the API path. the nginxConfig inside https://github.com/grafana/helm-charts/blob/main/charts/loki-distributed/values.yaml define the dispatched rules.

By the way, the tail API is not served by loki-distributed-query-frontend. If setting the loki-distributed-query-frontend as loki datasource in Grafana, the Live stream function in Explore tab would not work.

The nginx.conf inside the gateway pod.

  server {
    listen             8080;
    ...
    location = /loki/api/v1/push {
      proxy_pass       http://loki-loki-distributed-distributor.monitoring.svc.cluster.local:3100$request_uri;
    }

    location = /loki/api/v1/tail {
      proxy_pass       http://loki-loki-distributed-querier.monitoring.svc.cluster.local:3100$request_uri;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
    }

    location ~ /loki/api/.* {
      proxy_pass       http://loki-loki-distributed-query-frontend.monitoring.svc.cluster.local:3100$request_uri;
    }
  }
unguiculus commented 3 years ago

Thanks for the feedback. I'll have a look. Also, PRs are welcome.

unguiculus commented 3 years ago

@rogercwang You should point the Grafana datasource to the gateway.

atmosx commented 3 years ago

Another issue I came across is the tablemanager fails to start with error mkdir /var/loki failed. The fix is to create a volume:

          volumeMounts:
            - name: config
              mountPath: /etc/loki/config
            - name: data
              mountPath: /var/loki
...
      volumes:
        - name: data
          emptyDir: {}
        - name: config
          configMap:
            name: gather-loki-distributed

I am not sure if an emptyDir is a good idea though. I'm converting the helm chart to a single, large YAML file and deploy through terraform kubectl. I noticed that there is a definition to add extra volumes, but with no values by default.

unguiculus commented 3 years ago

@atmosx Can you share more details? table-manager runs fine here without that volume.

stevehipwell commented 3 years ago

@atmosx are you using boltdb-shipper and S3? If so did you need to enable persistence as it isn't clear by the comments if this is needed for all boltdb-shipper uses or just for filesystem.

Also could you share the configuration that you used?

atmosx commented 3 years ago

Hello,

It's been a while and I don't remember the specifics. I don't remember what was my rationale for mounting a volume to /var/loki 🤔 . From @unguiculus comment I understand that if we lose data (e.g. the pod is deployed on another node) there's no harm done.

@stevehipwell We're running kubernetes on Digital Ocean. We're using DO spaces, the API is S3 compatible.

I'm copying the config that works for me. Variables using ${var} syntax and are setup dynamically during provisioning:

---
# Source: loki-distributed/templates/distributor/poddisruptionbudget-distributor.yaml
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
  namespace: loki
  name: gather-loki-distributed-distributor
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: distributor
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: loki-distributed
      app.kubernetes.io/instance: gather
      app.kubernetes.io/component: distributor
  maxUnavailable: 1
---
# Source: loki-distributed/templates/ingester/poddisruptionbudget-ingester.yaml
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
  namespace: loki
  name: gather-loki-distributed-ingester
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: ingester
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: loki-distributed
      app.kubernetes.io/instance: gather
      app.kubernetes.io/component: ingester
  maxUnavailable: 1
---
# Source: loki-distributed/templates/memcached-chunks/poddisruptionbudget-memcached-chunks.yaml
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
  namespace: loki
  name: gather-loki-distributed-memcached-chunks
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: memcached-chunks
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: loki-distributed
      app.kubernetes.io/instance: gather
      app.kubernetes.io/component: memcached-chunks
  maxUnavailable: 1
---
# Source: loki-distributed/templates/memcached-frontend/poddisruptionbudget-memcached-frontend.yaml
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
  namespace: loki
  name: gather-loki-distributed-memcached-frontend
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: memcached-frontend
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: loki-distributed
      app.kubernetes.io/instance: gather
      app.kubernetes.io/component: memcached-frontend
  maxUnavailable: 1
---
# Source: loki-distributed/templates/memcached-index-queries/poddisruptionbudget-memcached-index-queries.yaml
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
  namespace: loki
  name: gather-loki-distributed-memcached-index-queries
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: memcached-index-queries
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: loki-distributed
      app.kubernetes.io/instance: gather
      app.kubernetes.io/component: memcached-index-queries
  maxUnavailable: 1
---
# Source: loki-distributed/templates/querier/poddisruptionbudget-querier.yaml
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
  namespace: loki
  name: gather-loki-distributed-querier
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: querier
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: loki-distributed
      app.kubernetes.io/instance: gather
      app.kubernetes.io/component: querier
  maxUnavailable: 1
---
# Source: loki-distributed/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  namespace: loki
  name: gather-loki-distributed
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
---
# Source: loki-distributed/templates/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  namespace: loki
  name: gather-loki-distributed
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
data:
  config.yaml: |
    auth_enabled: false

    server:
      http_listen_port: 3100

    distributor:
      ring:
        kvstore:
          store: memberlist

    memberlist:
      join_members:
        - gather-loki-distributed-memberlist

    ingester:
      lifecycler:
        ring:
          kvstore:
            store: memberlist
          replication_factor: 1
      chunk_idle_period: 30m
      chunk_block_size: 262144
      chunk_encoding: snappy
      chunk_retain_period: 1m
      max_transfer_retries: 3

    limits_config:
      enforce_metric_name: true
      reject_old_samples: true
      reject_old_samples_max_age: 720h
      max_cache_freshness_per_query: 10m

    schema_config:
      configs:
        - from: 2020-09-07
          store: boltdb-shipper
          object_store: aws
          schema: v11
          index:
            prefix: loki_index_
            period: 24h
          chunks:
            period: 24h

    storage_config:
      index_queries_cache_config:
        memcached:
          batch_size: 100
          parallelism: 100
        memcached_client:
          consistent_hash: true
          host: gather-loki-distributed-memcached-index-queries
          service: http
      aws:
        # s3: s3://${spaces_access_key}:${spaces_access_secret}@${spaces_endpoint}
        s3forcepathstyle: true
        bucketnames: ${spaces_bucket_name}
        endpoint: ${spaces_endpoint}
        region:
        access_key_id: ${spaces_access_key}
        secret_access_key: ${spaces_access_secret}
      boltdb_shipper:
        shared_store: aws
        active_index_directory: /var/loki/index
        cache_location: /var/loki/cache
        cache_ttl: 120h
      filesystem:
        directory: /var/loki/chunks

    chunk_store_config:
      chunk_cache_config:
        memcached_client:
          consistent_hash: true
          host: gather-loki-distributed-memcached-chunks
          service: http
        memcached:
          batch_size: 100
          parallelism: 100

    table_manager:
      retention_deletes_enabled: true
      retention_period: 720h

    query_range:
      align_queries_with_step: true
      max_retries: 5
      split_queries_by_interval: 15m
      cache_results: true
      results_cache:
        cache:
          memcached_client:
            consistent_hash: true
            host: gather-loki-distributed-memcached-frontend
            max_idle_conns: 16
            service: http
            timeout: 500ms
            update_interval: 1m

    frontend_worker:
      frontend_address: gather-loki-distributed-query-frontend:9095

    frontend:
      log_queries_longer_than: 5s
      compress_responses: true

    compactor:
      shared_store: s3
      working_directory: /loki/compactor

    ruler:
      storage:
        type: local
        local:
          directory: /etc/loki/rules
      ring:
        kvstore:
          store: memberlist
      rule_path: /tmp/loki/scratch
      alertmanager_url: http://alertmanager-main.monitoring.svc.cluster.local
      external_url: http://alertmanager-main.monitoring.svc.cluster.local
---
# Source: loki-distributed/templates/gateway/configmap-gateway.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  namespace: loki
  name: gather-loki-distributed-gateway
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: gateway
data:
  nginx.conf: |
    worker_processes  5;  ## Default: 1
    error_log  /dev/stderr;
    pid        /tmp/nginx.pid;
    worker_rlimit_nofile 8192;

    events {
      worker_connections  4096;  ## Default: 1024
    }

    http {
      client_body_temp_path /tmp/client_temp;
      proxy_temp_path       /tmp/proxy_temp_path;
      fastcgi_temp_path     /tmp/fastcgi_temp;
      uwsgi_temp_path       /tmp/uwsgi_temp;
      scgi_temp_path        /tmp/scgi_temp;

      default_type application/octet-stream;
      log_format   main '$remote_addr - $remote_user [$time_local]  $status '
        '"$request" $body_bytes_sent "$http_referer" '
        '"$http_user_agent" "$http_x_forwarded_for"';
      access_log   /dev/stderr  main;
      sendfile     on;
      tcp_nopush   on;
      resolver kube-dns.kube-system.svc.cluster.local;

      server {
        listen             8080;

        location = / {
          return 200 'OK';
          auth_basic off;
        }

        location = /api/prom/push {
          proxy_pass       http://gather-loki-distributed-distributor.loki.svc.cluster.local:3100$request_uri;
        }

        location = /api/prom/tail {
          proxy_pass       http://gather-loki-distributed-querier.loki.svc.cluster.local:3100$request_uri;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "upgrade";
        }

        location ~ /api/prom/.* {
          proxy_pass       http://gather-loki-distributed-query-frontend.loki.svc.cluster.local:3100$request_uri;
        }

        location = /loki/api/v1/push {
          proxy_pass       http://gather-loki-distributed-distributor.loki.svc.cluster.local:3100$request_uri;
        }

        location = /loki/api/v1/tail {
          proxy_pass       http://gather-loki-distributed-querier.loki.svc.cluster.local:3100$request_uri;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "upgrade";
        }

        location ~ /loki/api/.* {
          proxy_pass       http://gather-loki-distributed-query-frontend.loki.svc.cluster.local:3100$request_uri;
        }
      }
    }
---
# Source: loki-distributed/templates/compactor/persistentvolumeclaim-compactor.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  namespace: loki
  name: data-gather-loki-distributed-compactor
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: compactor
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: do-block-storage
  resources:
    requests:
      storage: "100Gi"
---
# Source: loki-distributed/templates/compactor/service-compactor.yaml
apiVersion: v1
kind: Service
metadata:
  namespace: loki
  name: gather-loki-distributed-compactor
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: compactor
spec:
  type: ClusterIP
  ports:
    - name: http
      port: 3100
      targetPort: http
      protocol: TCP
  selector:
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/component: compactor
---
# Source: loki-distributed/templates/distributor/service-distributor.yaml
apiVersion: v1
kind: Service
metadata:
  namespace: loki
  name: gather-loki-distributed-distributor
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: distributor
spec:
  type: ClusterIP
  ports:
    - name: http
      port: 3100
      targetPort: http
      protocol: TCP
    - name: grpc
      port: 9095
      targetPort: grpc
      protocol: TCP
  selector:
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/component: distributor
---
# Source: loki-distributed/templates/gateway/service-gateway.yaml
apiVersion: v1
kind: Service
metadata:
  namespace: loki
  name: gather-loki-distributed-gateway
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: gateway
spec:
  type: ClusterIP
  ports:
    - name: http
      port: 80
      targetPort: http
      protocol: TCP
  selector:
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/component: gateway
---
# Source: loki-distributed/templates/ingester/service-ingester-headless.yaml
apiVersion: v1
kind: Service
metadata:
  namespace: loki
  name: gather-loki-distributed-ingester-headless
  labels:
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/component: ingester
spec:
  type: ClusterIP
  clusterIP: None
  ports:
    - name: http
      port: 3100
      targetPort: http
      protocol: TCP
    - name: grpc
      port: 9095
      targetPort: grpc
      protocol: TCP
  selector:
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/component: ingester
---
# Source: loki-distributed/templates/ingester/service-ingester.yaml
apiVersion: v1
kind: Service
metadata:
  namespace: loki
  name: gather-loki-distributed-ingester
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: ingester
spec:
  type: ClusterIP
  ports:
    - name: http
      port: 3100
      targetPort: http
      protocol: TCP
    - name: grpc
      port: 9095
      targetPort: grpc
      protocol: TCP
  selector:
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/component: ingester
---
# Source: loki-distributed/templates/memcached-chunks/service-memcached-chunks.yaml
apiVersion: v1
kind: Service
metadata:
  namespace: loki
  name: gather-loki-distributed-memcached-chunks
  labels:
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/component: memcached-chunks
spec:
  type: ClusterIP
  clusterIP: None
  ports:
    - name: http
      port: 11211
      targetPort: http
      protocol: TCP
    - name: http-metrics
      port: 9150
      targetPort: http-metrics
      protocol: TCP
  selector:
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/component: memcached-chunks
---
# Source: loki-distributed/templates/memcached-frontend/service-memcached-frontend.yaml
apiVersion: v1
kind: Service
metadata:
  namespace: loki
  name: gather-loki-distributed-memcached-frontend
  labels:
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/component: memcached-frontend
spec:
  type: ClusterIP
  clusterIP: None
  ports:
    - name: http
      port: 11211
      targetPort: http
      protocol: TCP
    - name: http-metrics
      port: 9150
      targetPort: http-metrics
      protocol: TCP
  selector:
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/component: memcached-frontend
---
# Source: loki-distributed/templates/memcached-index-queries/service-memcached-index-queries.yaml
apiVersion: v1
kind: Service
metadata:
  namespace: loki
  name: gather-loki-distributed-memcached-index-queries
  labels:
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/component: memcached-index-queries
spec:
  type: ClusterIP
  clusterIP: None
  ports:
    - name: http
      port: 11211
      targetPort: http
      protocol: TCP
    - name: http-metrics
      port: 9150
      targetPort: http-metrics
      protocol: TCP
  selector:
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/component: memcached-index-queries
---
# Source: loki-distributed/templates/querier/service-querier-headless.yaml
apiVersion: v1
kind: Service
metadata:
  namespace: loki
  name: gather-loki-distributed-querier-headless
  labels:
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/component: querier
spec:
  type: ClusterIP
  clusterIP: None
  ports:
    - name: http
      port: 3100
      targetPort: http
      protocol: TCP
    - name: grpc
      port: 9095
      targetPort: grpc
      protocol: TCP
  selector:
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/component: querier
---
# Source: loki-distributed/templates/querier/service-querier.yaml
apiVersion: v1
kind: Service
metadata:
  namespace: loki
  name: gather-loki-distributed-querier
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: querier
spec:
  type: ClusterIP
  ports:
    - name: http
      port: 3100
      targetPort: http
      protocol: TCP
    - name: grpc
      port: 9095
      targetPort: grpc
      protocol: TCP
  selector:
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/component: querier
---
# Source: loki-distributed/templates/query-frontend/service-query-frontend.yaml
apiVersion: v1
kind: Service
metadata:
  namespace: loki
  name: gather-loki-distributed-query-frontend
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: query-frontend
spec:
  type: ClusterIP
  clusterIP: None
  ports:
    - name: http
      port: 3100
      targetPort: http
      protocol: TCP
    - name: grpc
      port: 9095
      targetPort: grpc
      protocol: TCP
  selector:
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/component: query-frontend
---
# Source: loki-distributed/templates/service-memberlist.yaml
apiVersion: v1
kind: Service
metadata:
  namespace: loki
  name: gather-loki-distributed-memberlist
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
spec:
  type: ClusterIP
  clusterIP: None
  ports:
    - name: http
      port: 7946
      targetPort: http-memberlist
      protocol: TCP
  selector:
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/part-of: memberlist
---
# Source: loki-distributed/templates/table-manager/service-table-manager.yaml
apiVersion: v1
kind: Service
metadata:
  namespace: loki
  name: gather-loki-distributed-table-manager
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: table-manager
spec:
  type: ClusterIP
  ports:
    - name: http
      port: 3100
      targetPort: http
      protocol: TCP
    - name: grpc
      port: 9095
      targetPort: grpc
      protocol: TCP
  selector:
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/component: table-manager
---
# Source: loki-distributed/templates/compactor/deployment-compactor.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: loki
  name: gather-loki-distributed-compactor
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: compactor
spec:
  replicas: 1
  revisionHistoryLimit: 5
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app.kubernetes.io/name: loki-distributed
      app.kubernetes.io/instance: gather
      app.kubernetes.io/component: compactor
  template:
    metadata:
      annotations:
        checksum/config: 137fd6a856753d5070e95a259b3f5e441d3eff8194f5f7b7a00788a63477ee0b
      labels:
        app.kubernetes.io/name: loki-distributed
        app.kubernetes.io/instance: gather
        app.kubernetes.io/component: compactor
    spec:
      serviceAccountName: gather-loki-distributed

      securityContext:
        fsGroup: 10001
        runAsGroup: 10001
        runAsNonRoot: true
        runAsUser: 10001
      terminationGracePeriodSeconds: 30
      containers:
        - name: loki
          image: docker.io/grafana/loki:2.1.0
          imagePullPolicy: IfNotPresent
          args:
            - -config.file=/etc/loki/config/config.yaml
            - -target=compactor
            - -boltdb.shipper.compactor.working-directory=/var/loki/compactor
          ports:
            - name: http
              containerPort: 3100
              protocol: TCP
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop:
              - ALL
            readOnlyRootFilesystem: true
          readinessProbe:
            httpGet:
              path: /ready
              port: http
            initialDelaySeconds: 30
            timeoutSeconds: 1
          volumeMounts:
            - name: config
              mountPath: /etc/loki/config
            - name: data
              mountPath: /var/loki
          resources:
            {}
      volumes:
        - name: config
          configMap:
            name: gather-loki-distributed
        - name: data
          persistentVolumeClaim:
            claimName: data-gather-loki-distributed-compactor
---
# Source: loki-distributed/templates/distributor/deployment-distributor.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: loki
  name: gather-loki-distributed-distributor
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: distributor
    app.kubernetes.io/part-of: memberlist
spec:
  replicas: 3
  strategy:
    rollingUpdate:
      maxSurge: 0
      maxUnavailable: 1
  revisionHistoryLimit: 5
  selector:
    matchLabels:
      app.kubernetes.io/name: loki-distributed
      app.kubernetes.io/instance: gather
      app.kubernetes.io/component: distributor
  template:
    metadata:
      annotations:
        checksum/config: 137fd6a856753d5070e95a259b3f5e441d3eff8194f5f7b7a00788a63477ee0b
      labels:
        app.kubernetes.io/name: loki-distributed
        app.kubernetes.io/instance: gather
        app.kubernetes.io/component: distributor
        app.kubernetes.io/part-of: memberlist
    spec:
      serviceAccountName: gather-loki-distributed

      securityContext:
        fsGroup: 10001
        runAsGroup: 10001
        runAsNonRoot: true
        runAsUser: 10001
      terminationGracePeriodSeconds: 30
      containers:
        - name: loki
          image: docker.io/grafana/loki:2.1.0
          imagePullPolicy: IfNotPresent
          args:
            - -config.file=/etc/loki/config/config.yaml
            - -target=distributor
          ports:
            - name: http
              containerPort: 3100
              protocol: TCP
            - name: grpc
              containerPort: 9095
              protocol: TCP
            - name: http-memberlist
              containerPort: 7946
              protocol: TCP
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop:
              - ALL
            readOnlyRootFilesystem: true
          readinessProbe:
            httpGet:
              path: /ready
              port: http
            initialDelaySeconds: 30
            timeoutSeconds: 1
          volumeMounts:
            - name: config
              mountPath: /etc/loki/config
          resources:
            {}
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            - labelSelector:
                matchLabels:
                  app.kubernetes.io/name: loki-distributed
                  app.kubernetes.io/instance: gather
                  app.kubernetes.io/component: distributor
              topologyKey: kubernetes.io/hostname
          preferredDuringSchedulingIgnoredDuringExecution:
            - weight: 100
              podAffinityTerm:
                labelSelector:
                  matchLabels:
                    app.kubernetes.io/name: loki-distributed
                    app.kubernetes.io/instance: gather
                    app.kubernetes.io/component: distributor
                topologyKey: failure-domain.beta.kubernetes.io/zone

      volumes:
        - name: config
          configMap:
            name: gather-loki-distributed
---
# Source: loki-distributed/templates/gateway/deployment-gateway.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: loki
  name: gather-loki-distributed-gateway
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: gateway
spec:
  replicas: 1
  strategy:
    rollingUpdate:
      maxSurge: 0
      maxUnavailable: 1
  revisionHistoryLimit: 5
  selector:
    matchLabels:
      app.kubernetes.io/name: loki-distributed
      app.kubernetes.io/instance: gather
      app.kubernetes.io/component: gateway
  template:
    metadata:
      annotations:
        checksum/config: a59a700f4b1d721af28d951f841fadb31a7260a550a15cfb726929722a1dabce
      labels:
        app.kubernetes.io/name: loki-distributed
        app.kubernetes.io/instance: gather
        app.kubernetes.io/component: gateway
    spec:
      serviceAccountName: gather-loki-distributed

      securityContext:
        fsGroup: 101
        runAsGroup: 101
        runAsNonRoot: true
        runAsUser: 101
      terminationGracePeriodSeconds: 30
      containers:
        - name: nginx
          image: docker.io/nginxinc/nginx-unprivileged:1.19-alpine
          imagePullPolicy: IfNotPresent
          ports:
            - name: http
              containerPort: 8080
              protocol: TCP
          readinessProbe:
            httpGet:
              path: /
              port: http
            initialDelaySeconds: 15
            timeoutSeconds: 1
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop:
              - ALL
            readOnlyRootFilesystem: true
          volumeMounts:
            - name: config
              mountPath: /etc/nginx
            - name: tmp
              mountPath: /tmp
            - name: docker-entrypoint-d-override
              mountPath: /docker-entrypoint.d
          resources:
            {}
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            - labelSelector:
                matchLabels:
                  app.kubernetes.io/name: loki-distributed
                  app.kubernetes.io/instance: gather
                  app.kubernetes.io/component: gateway
              topologyKey: kubernetes.io/hostname
          preferredDuringSchedulingIgnoredDuringExecution:
            - weight: 100
              podAffinityTerm:
                labelSelector:
                  matchLabels:
                    app.kubernetes.io/name: loki-distributed
                    app.kubernetes.io/instance: gather
                    app.kubernetes.io/component: gateway
                topologyKey: failure-domain.beta.kubernetes.io/zone

      volumes:
        - name: config
          configMap:
            name: gather-loki-distributed-gateway
        - name: tmp
          emptyDir: {}
        - name: docker-entrypoint-d-override
          emptyDir: {}
---
# Source: loki-distributed/templates/query-frontend/deployment-query-frontend.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: loki
  name: gather-loki-distributed-query-frontend
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: query-frontend
spec:
  replicas: 1
  strategy:
    rollingUpdate:
      maxSurge: 0
      maxUnavailable: 1
  revisionHistoryLimit: 5
  selector:
    matchLabels:
      app.kubernetes.io/name: loki-distributed
      app.kubernetes.io/instance: gather
      app.kubernetes.io/component: query-frontend
  template:
    metadata:
      annotations:
        checksum/config: 137fd6a856753d5070e95a259b3f5e441d3eff8194f5f7b7a00788a63477ee0b
      labels:
        app.kubernetes.io/name: loki-distributed
        app.kubernetes.io/instance: gather
        app.kubernetes.io/component: query-frontend
    spec:
      serviceAccountName: gather-loki-distributed

      securityContext:
        fsGroup: 10001
        runAsGroup: 10001
        runAsNonRoot: true
        runAsUser: 10001
      terminationGracePeriodSeconds: 30
      containers:
        - name: loki
          image: docker.io/grafana/loki:2.1.0
          imagePullPolicy: IfNotPresent
          args:
            - -config.file=/etc/loki/config/config.yaml
            - -target=query-frontend
          ports:
            - name: http
              containerPort: 3100
              protocol: TCP
            - name: grpc
              containerPort: 9095
              protocol: TCP
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop:
              - ALL
            readOnlyRootFilesystem: true
          volumeMounts:
            - name: config
              mountPath: /etc/loki/config
          resources:
            {}
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            - labelSelector:
                matchLabels:
                  app.kubernetes.io/name: loki-distributed
                  app.kubernetes.io/instance: gather
                  app.kubernetes.io/component: query-frontend
              topologyKey: kubernetes.io/hostname
          preferredDuringSchedulingIgnoredDuringExecution:
            - weight: 100
              podAffinityTerm:
                labelSelector:
                  matchLabels:
                    app.kubernetes.io/name: loki-distributed
                    app.kubernetes.io/instance: gather
                    app.kubernetes.io/component: query-frontend
                topologyKey: failure-domain.beta.kubernetes.io/zone

      volumes:
        - name: config
          configMap:
            name: gather-loki-distributed
---
# Source: loki-distributed/templates/table-manager/deployment-table-manager.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: loki
  name: gather-loki-distributed-table-manager
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: table-manager
spec:
  replicas: 1
  revisionHistoryLimit: 5
  selector:
    matchLabels:
      app.kubernetes.io/name: loki-distributed
      app.kubernetes.io/instance: gather
      app.kubernetes.io/component: table-manager
  template:
    metadata:
      annotations:
        checksum/config: 137fd6a856753d5070e95a259b3f5e441d3eff8194f5f7b7a00788a63477ee0b
      labels:
        app.kubernetes.io/name: loki-distributed
        app.kubernetes.io/instance: gather
        app.kubernetes.io/component: table-manager
    spec:
      serviceAccountName: gather-loki-distributed
      securityContext:
        fsGroup: 10001
        runAsGroup: 10001
        runAsNonRoot: true
        runAsUser: 10001
      terminationGracePeriodSeconds: 30
      containers:
        - name: loki
          image: docker.io/grafana/loki:2.1.0
          imagePullPolicy: IfNotPresent
          args:
            - -config.file=/etc/loki/config/config.yaml
            - -target=table-manager
          ports:
            - name: http
              containerPort: 3100
              protocol: TCP
            - name: grpc
              containerPort: 9095
              protocol: TCP
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop:
              - ALL
            readOnlyRootFilesystem: false
          readinessProbe:
            httpGet:
              path: /ready
              port: http
            initialDelaySeconds: 30
            timeoutSeconds: 1
          volumeMounts:
            - name: config
              mountPath: /etc/loki/config
            - name: data
              mountPath: /var/loki
          resources:
            {}
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            - labelSelector:
                matchLabels:
                  app.kubernetes.io/name: loki-distributed
                  app.kubernetes.io/instance: gather
                  app.kubernetes.io/component: table-manager
              topologyKey: kubernetes.io/hostname
          preferredDuringSchedulingIgnoredDuringExecution:
            - weight: 100
              podAffinityTerm:
                labelSelector:
                  matchLabels:
                    app.kubernetes.io/name: loki-distributed
                    app.kubernetes.io/instance: gather
                    app.kubernetes.io/component: table-manager
                topologyKey: failure-domain.beta.kubernetes.io/zone
      volumes:
        - name: data
          emptyDir: {}
        - name: config
          configMap:
            name: gather-loki-distributed
---
# Source: loki-distributed/templates/ingester/statefulset-ingester.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
  namespace: loki
  name: gather-loki-distributed-ingester
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: ingester
    app.kubernetes.io/part-of: memberlist
spec:
  replicas: 3
  updateStrategy:
    rollingUpdate:
      partition: 0
  serviceName: gather-loki-distributed-ingester-headless
  revisionHistoryLimit: 5
  selector:
    matchLabels:
      app.kubernetes.io/name: loki-distributed
      app.kubernetes.io/instance: gather
      app.kubernetes.io/component: ingester
  template:
    metadata:
      annotations:
        checksum/config: 137fd6a856753d5070e95a259b3f5e441d3eff8194f5f7b7a00788a63477ee0b
      labels:
        app.kubernetes.io/name: loki-distributed
        app.kubernetes.io/instance: gather
        app.kubernetes.io/component: ingester
        app.kubernetes.io/part-of: memberlist
    spec:
      serviceAccountName: gather-loki-distributed
      securityContext:
        fsGroup: 10001
        runAsGroup: 10001
        runAsNonRoot: true
        runAsUser: 10001
      terminationGracePeriodSeconds: 300
      containers:
        - name: loki
          image: docker.io/grafana/loki:2.1.0
          imagePullPolicy: IfNotPresent
          args:
            - -config.file=/etc/loki/config/config.yaml
            - -target=ingester
          ports:
            - name: http
              containerPort: 3100
              protocol: TCP
            - name: grpc
              containerPort: 9095
              protocol: TCP
            - name: http-memberlist
              containerPort: 7946
              protocol: TCP
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop:
              - ALL
            readOnlyRootFilesystem: true
          readinessProbe:
            httpGet:
              path: /ready
              port: http
            initialDelaySeconds: 30
            timeoutSeconds: 1
          volumeMounts:
            - name: config
              mountPath: /etc/loki/config
            - name: data
              mountPath: /var/loki
          resources:
            {}
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            - labelSelector:
                matchLabels:
                  app.kubernetes.io/name: loki-distributed
                  app.kubernetes.io/instance: gather
                  app.kubernetes.io/component: ingester
              topologyKey: kubernetes.io/hostname
          preferredDuringSchedulingIgnoredDuringExecution:
            - weight: 100
              podAffinityTerm:
                labelSelector:
                  matchLabels:
                    app.kubernetes.io/name: loki-distributed
                    app.kubernetes.io/instance: gather
                    app.kubernetes.io/component: ingester
                topologyKey: failure-domain.beta.kubernetes.io/zone

      volumes:
        - name: config
          configMap:
            name: gather-loki-distributed
  volumeClaimTemplates:
    - metadata:
        name: data
      spec:
        accessModes:
          - ReadWriteOnce
        storageClassName: do-block-storage
        resources:
          requests:
            storage: "25Gi"
---
# Source: loki-distributed/templates/memcached-chunks/statefulset-memcached-chunks.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
  namespace: loki
  name: gather-loki-distributed-memcached-chunks
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: memcached-chunks
spec:
  replicas: 2
  updateStrategy:
    rollingUpdate:
      partition: 0
  serviceName: gather-loki-distributed-memcached-chunks
  revisionHistoryLimit: 5
  selector:
    matchLabels:
      app.kubernetes.io/name: loki-distributed
      app.kubernetes.io/instance: gather
      app.kubernetes.io/component: memcached-chunks
  template:
    metadata:
      labels:
        app.kubernetes.io/name: loki-distributed
        app.kubernetes.io/instance: gather
        app.kubernetes.io/component: memcached-chunks
    spec:
      serviceAccountName: gather-loki-distributed

      securityContext:
        fsGroup: 11211
        runAsGroup: 11211
        runAsNonRoot: true
        runAsUser: 11211
      terminationGracePeriodSeconds: 30
      containers:
        - name: memcached
          image: docker.io/memcached:1.6.7-alpine
          imagePullPolicy: IfNotPresent
          ports:
            - name: http
              containerPort: 11211
              protocol: TCP
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop:
              - ALL
            readOnlyRootFilesystem: true
          readinessProbe:
            tcpSocket:
              port: http
            initialDelaySeconds: 5
            timeoutSeconds: 1
          resources:
            limits:
              cpu: 2000m
              memory: 4096Mi
            requests:
              cpu: 500m
              memory: 1024Mi
        - name: exporter
          args:
            - --memcached.address=localhost:11211
            - --web.listen-address=0.0.0.0:9150
          image: docker.io/prom/memcached-exporter:v0.6.0
          imagePullPolicy: IfNotPresent
          ports:
            - name: http-metrics
              containerPort: 9150
              protocol: TCP
          resources:
            {}
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            - labelSelector:
                matchLabels:
                  app.kubernetes.io/name: loki-distributed
                  app.kubernetes.io/instance: gather
                  app.kubernetes.io/component: memcached-chunks
              topologyKey: kubernetes.io/hostname
          preferredDuringSchedulingIgnoredDuringExecution:
            - weight: 100
              podAffinityTerm:
                labelSelector:
                  matchLabels:
                    app.kubernetes.io/name: loki-distributed
                    app.kubernetes.io/instance: gather
                    app.kubernetes.io/component: memcached-chunks
                topologyKey: failure-domain.beta.kubernetes.io/zone
---
# Source: loki-distributed/templates/memcached-frontend/statefulset-memcached-frontend.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
  namespace: loki
  name: gather-loki-distributed-memcached-frontend
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: memcached-frontend
spec:
  replicas: 2
  updateStrategy:
    rollingUpdate:
      partition: 0
  serviceName: gather-loki-distributed-memcached-frontend
  revisionHistoryLimit: 5
  selector:
    matchLabels:
      app.kubernetes.io/name: loki-distributed
      app.kubernetes.io/instance: gather
      app.kubernetes.io/component: memcached-frontend
  template:
    metadata:
      labels:
        app.kubernetes.io/name: loki-distributed
        app.kubernetes.io/instance: gather
        app.kubernetes.io/component: memcached-frontend
    spec:
      serviceAccountName: gather-loki-distributed

      securityContext:
        fsGroup: 11211
        runAsGroup: 11211
        runAsNonRoot: true
        runAsUser: 11211
      terminationGracePeriodSeconds: 30
      containers:
        - name: memcached
          image: docker.io/memcached:1.6.7-alpine
          imagePullPolicy: IfNotPresent
          ports:
            - name: http
              containerPort: 11211
              protocol: TCP
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop:
              - ALL
            readOnlyRootFilesystem: true
          readinessProbe:
            tcpSocket:
              port: http
            initialDelaySeconds: 5
            timeoutSeconds: 1
          resources:
            null
        - name: exporter
          args:
            - --memcached.address=localhost:11211
            - --web.listen-address=0.0.0.0:9150
          image: docker.io/prom/memcached-exporter:v0.6.0
          imagePullPolicy: IfNotPresent
          ports:
            - name: http-metrics
              containerPort: 9150
              protocol: TCP
          resources:
            {}
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            - labelSelector:
                matchLabels:
                  app.kubernetes.io/name: loki-distributed
                  app.kubernetes.io/instance: gather
                  app.kubernetes.io/component: memcached-frontend
              topologyKey: kubernetes.io/hostname
          preferredDuringSchedulingIgnoredDuringExecution:
            - weight: 100
              podAffinityTerm:
                labelSelector:
                  matchLabels:
                    app.kubernetes.io/name: loki-distributed
                    app.kubernetes.io/instance: gather
                    app.kubernetes.io/component: memcached-frontend
                topologyKey: failure-domain.beta.kubernetes.io/zone
---
# Source: loki-distributed/templates/memcached-index-queries/statefulset-memcached-index-queries.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
  namespace: loki
  name: gather-loki-distributed-memcached-index-queries
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: memcached-index-queries
spec:
  replicas: 2
  updateStrategy:
    rollingUpdate:
      partition: 0
  serviceName: gather-loki-distributed-memcached-index-queries
  revisionHistoryLimit: 5
  selector:
    matchLabels:
      app.kubernetes.io/name: loki-distributed
      app.kubernetes.io/instance: gather
      app.kubernetes.io/component: memcached-index-queries
  template:
    metadata:
      labels:
        app.kubernetes.io/name: loki-distributed
        app.kubernetes.io/instance: gather
        app.kubernetes.io/component: memcached-index-queries
    spec:
      serviceAccountName: gather-loki-distributed

      securityContext:
        fsGroup: 11211
        runAsGroup: 11211
        runAsNonRoot: true
        runAsUser: 11211
      terminationGracePeriodSeconds: 30
      containers:
        - name: memcached
          image: docker.io/memcached:1.6.7-alpine
          imagePullPolicy: IfNotPresent
          ports:
            - name: http
              containerPort: 11211
              protocol: TCP
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop:
              - ALL
            readOnlyRootFilesystem: true
          readinessProbe:
            tcpSocket:
              port: http
            initialDelaySeconds: 5
            timeoutSeconds: 1
          resources:
            null
        - name: exporter
          args:
            - --memcached.address=localhost:11211
            - --web.listen-address=0.0.0.0:9150
          image: docker.io/prom/memcached-exporter:v0.6.0
          imagePullPolicy: IfNotPresent
          ports:
            - name: http-metrics
              containerPort: 9150
              protocol: TCP
          resources:
            {}
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            - labelSelector:
                matchLabels:
                  app.kubernetes.io/name: loki-distributed
                  app.kubernetes.io/instance: gather
                  app.kubernetes.io/component: memcached-index-queries
              topologyKey: kubernetes.io/hostname
          preferredDuringSchedulingIgnoredDuringExecution:
            - weight: 100
              podAffinityTerm:
                labelSelector:
                  matchLabels:
                    app.kubernetes.io/name: loki-distributed
                    app.kubernetes.io/instance: gather
                    app.kubernetes.io/component: memcached-index-queries
                topologyKey: failure-domain.beta.kubernetes.io/zone
---
# Source: loki-distributed/templates/querier/statefulset-querier.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
  namespace: loki
  name: gather-loki-distributed-querier
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: querier
    app.kubernetes.io/part-of: memberlist
spec:
  replicas: 3
  updateStrategy:
    rollingUpdate:
      partition: 0
  serviceName: gather-loki-distributed-querier-headless
  revisionHistoryLimit: 5
  selector:
    matchLabels:
      app.kubernetes.io/name: loki-distributed
      app.kubernetes.io/instance: gather
      app.kubernetes.io/component: querier
  template:
    metadata:
      annotations:
        checksum/config: 137fd6a856753d5070e95a259b3f5e441d3eff8194f5f7b7a00788a63477ee0b
      labels:
        app.kubernetes.io/name: loki-distributed
        app.kubernetes.io/instance: gather
        app.kubernetes.io/component: querier
        app.kubernetes.io/part-of: memberlist
    spec:
      serviceAccountName: gather-loki-distributed

      securityContext:
        fsGroup: 10001
        runAsGroup: 10001
        runAsNonRoot: true
        runAsUser: 10001
      terminationGracePeriodSeconds: 30
      containers:
        - name: loki
          image: docker.io/grafana/loki:2.1.0
          imagePullPolicy: IfNotPresent
          args:
            - -config.file=/etc/loki/config/config.yaml
            - -target=querier
          ports:
            - name: http
              containerPort: 3100
              protocol: TCP
            - name: grpc
              containerPort: 9095
              protocol: TCP
            - name: http-memberlist
              containerPort: 7946
              protocol: TCP
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop:
              - ALL
            readOnlyRootFilesystem: true
          readinessProbe:
            httpGet:
              path: /ready
              port: http
            initialDelaySeconds: 30
            timeoutSeconds: 1
          volumeMounts:
            - name: config
              mountPath: /etc/loki/config
            - name: data
              mountPath: /var/loki
          resources:
            {}
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            - labelSelector:
                matchLabels:
                  app.kubernetes.io/name: loki-distributed
                  app.kubernetes.io/instance: gather
                  app.kubernetes.io/component: querier
              topologyKey: kubernetes.io/hostname
          preferredDuringSchedulingIgnoredDuringExecution:
            - weight: 100
              podAffinityTerm:
                labelSelector:
                  matchLabels:
                    app.kubernetes.io/name: loki-distributed
                    app.kubernetes.io/instance: gather
                    app.kubernetes.io/component: querier
                topologyKey: failure-domain.beta.kubernetes.io/zone

      volumes:
        - name: config
          configMap:
            name: gather-loki-distributed
  volumeClaimTemplates:
    - metadata:
        name: data
      spec:
        accessModes:
          - ReadWriteOnce
        storageClassName: do-block-storage
        resources:
          requests:
            storage: "10Gi"
---
# Source: loki-distributed/templates/prometheusrule.yaml
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  namespace: monitoring
  name: gather-loki-distributed
  labels:
    prometheus: k8s
    role: alert-rules
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
spec:
  groups:
    - name: loki-rules
      rules:
      - expr: sum(rate(loki_request_duration_seconds_bucket[1m])) by (le, job)
        record: job:loki_request_duration_seconds_bucket:sum_rate
      - expr: sum(rate(loki_request_duration_seconds_bucket[1m])) by (le, job, route)
        record: job_route:loki_request_duration_seconds_bucket:sum_rate
      - expr: sum(rate(container_cpu_usage_seconds_total[1m])) by (node, namespace, pod, container)
        record: node_namespace_pod_container:container_cpu_usage_seconds_total:sum_rate
---
# Source: loki-distributed/templates/compactor/servicemonitor-compactor.yaml
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  namespace: loki
  name: gather-loki-distributed-compactor
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: compactor
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: loki-distributed
      app.kubernetes.io/instance: gather
      app.kubernetes.io/component: compactor
  endpoints:
    - port: http
      scheme: http
---
# Source: loki-distributed/templates/distributor/servicemonitor-distributor.yaml
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  namespace: loki
  name: gather-loki-distributed-distributor
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: distributor
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: loki-distributed
      app.kubernetes.io/instance: gather
      app.kubernetes.io/component: distributor
  endpoints:
    - port: http
      scheme: http
---
# Source: loki-distributed/templates/ingester/servicemonitor-ingester.yaml
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  namespace: loki
  name: gather-loki-distributed-ingester
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: ingester
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: loki-distributed
      app.kubernetes.io/instance: gather
      app.kubernetes.io/component: ingester
  endpoints:
    - port: http
      scheme: http
---
# Source: loki-distributed/templates/memcached-chunks/servicemonitor-memcached-chunks.yaml
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  namespace: loki
  name: gather-loki-distributed-memcached-chunks
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: memcached-chunks
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: loki-distributed
      app.kubernetes.io/instance: gather
      app.kubernetes.io/component: memcached-chunks
  endpoints:
    - port: http-metrics
---
# Source: loki-distributed/templates/memcached-frontend/servicemonitor-memcached-frontend.yaml
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  namespace: loki
  name: gather-loki-distributed-memcached-frontend
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: memcached-frontend
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: loki-distributed
      app.kubernetes.io/instance: gather
      app.kubernetes.io/component: memcached-frontend
  endpoints:
    - port: http-metrics
---
# Source: loki-distributed/templates/memcached-index-queries/servicemonitor-memcached-index-queries.yaml
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  namespace: loki
  name: gather-loki-distributed-memcached-index-queries
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: memcached-index-queries
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: loki-distributed
      app.kubernetes.io/instance: gather
      app.kubernetes.io/component: memcached-index-queries
  endpoints:
    - port: http-metrics
---
# Source: loki-distributed/templates/querier/servicemonitor-querier.yaml
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: gather-loki-distributed-querier
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: querier
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: loki-distributed
      app.kubernetes.io/instance: gather
      app.kubernetes.io/component: querier
  endpoints:
    - port: http
      scheme: http
---
# Source: loki-distributed/templates/query-frontend/servicemonitor-query-frontend.yaml
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: gather-loki-distributed-query-frontend
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: query-frontend
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: loki-distributed
      app.kubernetes.io/instance: gather
      app.kubernetes.io/component: query-frontend
  endpoints:
    - port: http
      scheme: http
---
# Source: loki-distributed/templates/table-manager/servicemonitor-table-manager.yaml
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: gather-loki-distributed-table-manager
  labels:
    helm.sh/chart: loki-distributed-0.25.0
    app.kubernetes.io/name: loki-distributed
    app.kubernetes.io/instance: gather
    app.kubernetes.io/version: "2.1.0"
    app.kubernetes.io/managed-by: terraform
    app.kubernetes.io/component: table-manager
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: loki-distributed
      app.kubernetes.io/instance: gather
      app.kubernetes.io/component: table-manager
  endpoints:
    - port: http
      scheme: http
stevehipwell commented 3 years ago

Thanks @atmosx do you happen to have the Helm chart values that you used to get this config?

atmosx commented 3 years ago

Thanks @atmosx do you happen to have the Helm chart values that you used to get this config?

Nope 😞

stevehipwell commented 3 years ago

No worries @atmosx, thank you for the config I can work it out from there.