# 官方github:https://github.com/grafana/loki
# 安装
helm repo add grafana https://grafana.github.io/helm-charts
helm repo update
#
kubectl create ns loki
# 安装,设置副本数3,使用pvc
# 时间较长
helm upgrade --install loki grafana/loki-stack --set grafana.enabled=true,grafana.service.type=NodePort,loki.replicas=3,loki.persistence.enabled=true,loki.persistence.storageClassName=rook-ceph-block,loki.persistence.size=50Gi -n loki
# 配置 ingress
# 生成https证书
kubectl create secret tls test-secret --cert=www.test.com.crt --key=www.test.com.key -n loki
# 编辑ingress文件
vim loki-ingress-https.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: loki-grafana
namespace: loki
annotations:
kubernetes.io/ingress.class: "nginx"
spec:
tls:
- hosts:
- loki-grafana.test.com
secretName: test-secret
rules:
- host: loki-grafana.test.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: loki-grafana
port:
name: service
#
kubectl apply -f loki-ingress-https.yaml
# 使用
# 获取grafana密码
kubectl get secret --namespace loki loki-grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
# grafana选择explore
# 数据源使用loki