k8s部署loki

一、部署loki-stack

0、介绍

架构介绍:
grafana/loki:单体 loki,性能支持线性伸缩;
grafana/loki-stack:loki 的工具栈,包括 loki、promtail、grafana 等,缺点是没有提供对接外部 MinIO 的配置;
grafana/loki-distributed:微服务模式的 loki 集群,性能上限最高,推荐生产环境使用;

组件介绍:
loki: 日志记录引擎,负责存储日志和处理查询
promtail: 代理,负责收集日志并将其发送给 loki
grafana: UI 界面

1、添加helm repo

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

2、自定义values部署

helm search repo loki-stack
helm pull grafana/loki-stack --version=2.10.2 --untar

helm --create-namespace  loki -n loki  install ./loki-stack -f ./values.yaml
模板1:精简安装
cat values.yaml 
loki:
  persistence:
    enabled: true
    size: 10Gi
    accessModes:
    - ReadWriteOnce
  commonConfig:
    replication_factor: 1
  storage:
    type: 'filesystem'
  config:
    limits_config:
      max_query_length: 0h
  service:
    type: LoadBalancer
singleBinary:
  replicas: 1
promtail:
  enabled: false
模板2:兼容污点更新
kubectl label node node01 platform.chandz.com/infra=true
kubectl taint node node01 platform.chandz.com/infra=true:NoSchedule

修改value并更新

loki:
  persistence:
    enabled: true
    size: 10Gi
    accessModes:
    - ReadWriteOnce
  commonConfig:
    replication_factor: 1
  storage:
    type: 'filesystem'
  config:
    limits_config:
      max_query_length: 0h
  service:
    type: LoadBalancer
  tolerations:
    - key: "platform.chandz.com/infra"
      operator: "Exists"
      effect: "NoSchedule"
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: platform.chandz.com/infra
            operator: In
            values:
            - "true"
singleBinary:
  replicas: 1
promtail:
  enabled: false
helm upgrade --install loki -n loki ./loki-stack -f values.yaml
模板3:全部组件安装
loki:
  enable: true
  service:
    type: NodePort
  tolerations:
    - key: "platform.chandz.com/infra"
      operator: "Exists"
      effect: "NoSchedule"
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: platform.chandz.com/infra
            operator: In
            values:
            - "true"
  persistence:
    enabled: true
    size: 5Gi
    accessModes:
    - ReadWriteOnce
    storageClassName: local-path

promtail:
  enabled: true

grafana:
  enabled: true
  service:
    type: NodePort
  tolerations:
    - key: "platform.chandz.com/infra"
      operator: "Exists"
      effect: "NoSchedule"
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: platform.chandz.com/infra
            operator: In
            values:
            - "true"
  persistence:
    type: pvc
    enabled: false
    storageClassName: local-path
    accessModes:
      - ReadWriteOnce
    size: 5Gi
高可用改造(测试中)
loki-stack/values.yaml
loki:
  replicas: 3
  persistence:
    enabled: true
    size: 10Gi
    accessModes:
    - ReadWriteOnce
  commonConfig:
    replication_factor: 3
  storage:
    type: 'filesystem'
  config:
    limits_config:
      max_query_length: 0h
    storage_config:
      aws:
        s3: http://QeytJ4j0u6Kodh4ki6Ra:ctrCLm0XRWmhZuv2flt5Wgf9QaGpNGFOXoMBCFxT@192.168.86.21:31388
        bucketnames: loki-stack-data
        s3forcepathstyle: true
      boltdb_shipper:
        shared_store: s3
    schema_config:
      configs:
        - from: 2024-03-30
          store: boltdb-shipper
          object_store: aws
          schema: v12
          index:
            prefix: loki_index_
            period: 24h
    compactor:
      shared_store: aws
      working_directory: /data/loki/boltdb-shipper-compactor
    ingester:
      lifecycler:
        ring:
          replication_factor: 3
  service:
    type: LoadBalancer
singleBinary:
  replicas: 3
promtail:
  enabled: true

分布式部署参考:
https://imwang.top/2023/03/03/loki-with-minio.html
https://www.cnblogs.com/hahaha111122222/p/16407693.html

3、配置grafana对接loki

1、获取grafana密码
kubectl get secret --namespace loki loki-grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
2、配置数据源(默认已经添加数据源)

在这里插入图片描述

  • 5
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值