Installing Loki with Helm

Prerequisites

Make sure you have Helm installed anddeployed to your cluster. Then addLoki’s chart repository to Helm:

  1. $ helm repo add loki https://grafana.github.io/loki/charts

You can update the chart repository by running:

  1. $ helm repo update

Deploy Loki to your cluster

Deploy with default config

  1. $ helm upgrade --install loki loki/loki-stack

Deploy in a custom namespace

  1. $ helm upgrade --install loki --namespace=loki loki/loki

Deploy with custom config

  1. $ helm upgrade --install loki loki/loki --set "key1=val1,key2=val2,..."

Deploy Loki Stack (Loki, Promtail, Grafana, Prometheus)

  1. $ helm upgrade --install loki loki/loki-stack --set grafana.enabled=true,prometheus.enabled=true,prometheus.alertmanager.persistentVolume.enabled=false,prometheus.server.persistentVolume.enabled=false

Deploy Loki Stack (Loki, Fluent Bit, Grafana, Prometheus)

  1. $ helm upgrade --install loki loki/loki-stack \
  2. --set fluent-bit.enabled=true,promtail.enabled=false,grafana.enabled=true,prometheus.enabled=true,prometheus.alertmanager.persistentVolume.enabled=false,prometheus.server.persistentVolume.enabled=false

Deploy Grafana to your cluster

To install Grafana on your cluster with Helm, use the following command:

  1. $ helm install stable/grafana -n loki-grafana

To get the admin password for the Grafana pod, run the following command:

  1. $ kubectl get secret --namespace <YOUR-NAMESPACE> loki-grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo

To access the Grafana UI, run the following command:

  1. $ kubectl port-forward --namespace <YOUR-NAMESPACE> service/loki-grafana 3000:80

Navigate to http://localhost:3000 and login with admin and the passwordoutput above. Then follow the instructions for adding the Loki Data Source, using the URLhttp://loki:3100/ for Loki.

Run Loki behind HTTPS ingress

If Loki and Promtail are deployed on different clusters you can add an Ingressin front of Loki. By adding a certificate you create an HTTPS endpoint. Forextra security you can also enable Basic Authentication on the Ingress.

In Promtail, set the following values to communicate using HTTPS and basicauthentication:

  1. loki:
  2. serviceScheme: https
  3. user: user
  4. password: pass

Sample Helm template for Ingress:

  1. apiVersion: extensions/v1beta1
  2. kind: Ingress
  3. metadata:
  4. annotations:
  5. kubernetes.io/ingress.class: {{ .Values.ingress.class }}
  6. ingress.kubernetes.io/auth-type: "basic"
  7. ingress.kubernetes.io/auth-secret: {{ .Values.ingress.basic.secret }}
  8. name: loki
  9. spec:
  10. rules:
  11. - host: {{ .Values.ingress.host }}
  12. http:
  13. paths:
  14. - backend:
  15. serviceName: loki
  16. servicePort: 3100
  17. tls:
  18. - secretName: {{ .Values.ingress.cert }}
  19. hosts:
  20. - {{ .Values.ingress.host }}