apiVersion: v1
data:
  loki-config.yaml: |-
    auth_enabled: false

    server:
      http_listen_port: 3100
      grpc_listen_port: 9096

    common:
      instance_addr: 127.0.0.1
      path_prefix: /tmp/loki
      storage:
        filesystem:
          chunks_directory: /tmp/loki/chunks
          rules_directory: /tmp/loki/rules
      replication_factor: 1
      ring:
        kvstore:
          store: inmemory

    query_range:
      results_cache:
        cache:
          embedded_cache:
            enabled: true
            max_size_mb: 100

    schema_config:
      configs:
        - from: 2020-10-24
          store: tsdb
          object_store: filesystem
          schema: v12
          index:
            prefix: index_
            period: 24h

    ruler:
      alertmanager_url: http://localhost:9093

    # By default, Loki will send anonymous, but uniquely-identifiable usage and configuration
    # analytics to Grafana Labs. These statistics are sent to https://stats.grafana.org/
    #
    # Statistics help us better understand how Loki is used, and they show us performance
    # levels for most users. This helps us prioritize features and documentation.
    # For more information on what's sent, look at
    # https://github.com/grafana/loki/blob/main/pkg/analytics/stats.go
    # Refer to the buildReport method to see what goes into a report.
    #
    # If you would like to disable reporting, uncomment the following lines:
    analytics:
      reporting_enabled: false
kind: ConfigMap
metadata:
  creationTimestamp: null
  name: loki-config
  labels:
    run: loki
    app: demo-logging
---
apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    run: loki
    app: demo-logging
  name: test-loki
spec:
  replicas: 1
  selector:
    matchLabels:
      run: loki
      app: demo-logging
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        run: loki
        app: demo-logging
    spec:
      containers:
      - image: docker.io/grafana/loki:2.9.2
        name: loki
        resources: {}
        args:
          - -config.file=/mnt/config/loki-config.yaml
        volumeMounts:
          - mountPath: /mnt/config/
            name: loki-config
          - mountPath: /tmp/
            name: tmp
        ports:
          - containerPort: 3100
            name: loki-http
            protocol: TCP
          - containerPort: 9096
            name: loki-grpc
            protocol: TCP
        securityContext:
          seccompProfile:
            type: RuntimeDefault
      volumes:
        - configMap:
            name: loki-config
          name: loki-config
        - emptyDir: {}
          name: tmp
---
apiVersion: v1
kind: Service
metadata:
  name: loki-http
  labels:
    run: loki
    app: demo-logging
spec:
  ports:
    - name: loki-http
      port: 3100
      protocol: TCP
      targetPort: 3100
  selector:
    run: loki
    app: demo-logging