How to install Loki and Promtail with Helm

A guide to deploying Loki and Promtail on Kubernetes

Featured image

Image Reference



Overview

Following our previous post about Loki, let’s explore how to install and configure these tools using Helm charts.

Note: We're not using Loki-Stack due to version compatibility issues with recent Grafana query features.


Installing Loki

We’ll deploy Loki in SingleBinary mode for simplicity.

Adding Helm Repository

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

Preparing Installation Files

# Clone repository
git clone https://github.com/grafana/loki.git
cd loki/production/helm/loki/

# Update dependencies
helm dependency update

# Create values directory
mkdir values
cp values.yaml values/somaz.yaml

Configuration (values/somaz.yaml)

global:
  clusterDomain: "somaz-cluster.local"
  dnsService: "coredns"
  dnsNamespace: "kube-system"
deploymentMode: SingleBinary
loki:
  commonConfig:
    replication_factor: 1
  storage:
    type: filesystem
  schemaConfig:
    configs:
    - from: "2024-01-01"
      store: tsdb
      index:
        prefix: loki_index_
        period: 24h
      object_store: filesystem
      schema: v13
singleBinary:
  replicas: 1
  persistence:
    enabled: true
    storageClass: "default"
    accessModes:
      - ReadWriteOnce
    size: 10Gi
gateway:
  enabled: true
  service:
    type: NodePort
    nodePort: 31400
# Disable unnecessary components for single binary mode
chunksCache:
  enabled: false
resultsCache:
  enabled: false
# ... (other components disabled)

Installation Commands

# Verify configuration
helm lint --values ./values/somaz.yaml

# Test installation
helm install loki . -n monitoring -f ./values/somaz.yaml --create-namespace --dry-run >> output.yaml

# Install
helm install loki . -n monitoring -f ./values/somaz.yaml --create-namespace

# Upgrade if needed
helm upgrade loki . -n monitoring -f ./values/somaz.yaml

Verifying Installation


Installing Promtail

Preparing Installation Files

git clone https://github.com/grafana/helm-charts.git
cd helm-charts/charts/promtail
helm dependency update

mkdir values
cp values.yaml values/somaz.yaml

Configuration (values/somaz.yaml)

daemonset:
  enabled: true
serviceMonitor:
  enabled: true
config:
  enabled: true
  logLevel: info
  logFormat: logfmt
  serverPort: 3101
  clients:
    - url: http://loki-gateway/loki/api/v1/push

Installation Commands

# Verify configuration
helm lint --values ./values/somaz.yaml

# Test installation
helm install promtail . -n monitoring -f ./values/somaz.yaml --create-namespace --dry-run >> output.yaml

# Install
helm install promtail . -n monitoring -f ./values/somaz.yaml --create-namespace

# Upgrade if needed
helm upgrade promtail . -n monitoring -f ./values/somaz.yaml


Next Steps

In our next post, we’ll explore:


References