This folder contains an example how the loki-rule-operator can be deployed on Kubernetes.
The deployment contains a ValidatingWebhookConfiguration
, which validates the LokiRules
when they are created or updated in the Kubernetes Api. This is helpfull, but not mandatory. This example uses cert-manager for creating and injecting a self-signed certificate for the webhook.
Replace the following variables in the manifests:
TAG
: image tag of the loki-rule-operator.LOKI_RULES_CONFIGMAP_NAME
: Name of the ConfigMap where all the rules will be stored. This ConfigMap should be mounted into the Loki Pod.LOKI_RULES_CONFIGMAP_NAMESPACE
: Namespace of the ConfigMap where all the rules will be stored.
kubectl apply -f crd
kubectl apply -f .
After the operator is created, the LOKI_RULES_CONFIGMAP
Configure the Ruler in the loki.yml
:
ruler:
storage:
type: local
local:
directory: /etc/loki/rules
Alter the deployment of Loki to mount the LOKI_RULES_CONFIGMAP.
...
spec:
...
template:
spec:
containers:
- name: loki
...
volumeMounts:
- name: loki-rules
mountPath: /etc/loki/rules/fake
...
volumes:
- name: loki-rules
configMap:
defaultMode: 420
name: {{ $LOKI_RULES_CONFIGMAP_NAME }}