Deploying PLG stack on kubernetes

Objective Link to heading

Deploy the Promtail-Loki-Grafana stack on a Kubernetes cluster using Helm. Heavily based on the video guide and docs found in references.

Set up the required helm charts Link to heading

helm repo add grafana https://grafana.github.io/helm-charts
helm repo update

To save the default values of a helm chart, run:

helm show values grafana/loki-stack > values.yaml

Update helm values file Link to heading

# P of the PLG stack - Promtail
promtail:
  enabled: true
  config:
    logLevel: info
    serverPort: 3101
    clients:
      - url: http://{{ .Release.Name }}:3100/loki/api/v1/push

# L of the PLG stack - Loki
loki:
  enabled: true
  persistence:
    enabled: false # disabled!
    # storageClassName: nfs-client # if following the same tutorial
    # size: 1Gi # as above
  isDefault: true
  url: http://{{(include "loki.serviceName" .)}}:{{ .Values.loki.service.port }}
  readinessProbe:
    httpGet:
      path: /ready
      port: http-metrics
    initialDelaySeconds: 45
  livenessProbe:
    httpGet:
      path: /ready
      port: http-metrics
    initialDelaySeconds: 45
  datasource:
    jsonData: {}
    uid: ""

# G of the PLG stack - Grafana
grafana:
  enabled: true
  sidecar:
    datasources:
      enabled: true
      maxLines: 1000
  image:
    tag: 8.3.5
  adminPassword: "very secret admin pass"

Update values file to serve Grafana from a non-root URL Link to heading

grafana:
  # other options as previous
  grafana.ini:
    server:
      domain: example.com
      root_url: https://example.com/grafana/
      serve_from_sub_path: true

Run the installation commands Link to heading

helm install loki-stack grafana/loki-stack --values loki-stack-values.yaml -n loki --create-namespace

Ingress configuration Link to heading

Finally, an ingress resource needs to be created with the path configuration matching the earlier root_url’s value, e.g.

# ingress resource definition
  rules:
  - host: example.com
    http:
      paths:
      - path: /grafana/
        pathType: Prefix
        backend:
          service:
            name: loki-stack-grafana
            port:
              number: 80

References Link to heading