「GRAFANA-ALLOY」- Official Helm Chart | on Kubernetes

认识

文档:https://grafana.com/docs/alloy/latest/set-up/install/kubernetes/

Alloy can be deployed on Kubernetes by using the Helm chart for Alloy. 简而言之,该 Helm Chart 其用于在 Kubernetes Cluster 中部署 Alloy 服务。

性质

提供 Toleration 配置

controller.tolerations:

提供 Ingress 配置

ingress:

提供 Volume 挂载节点日志

alloy.mounts.dockercontainers: true
alloy.mounts.varlog: true

controller.volumes.extra:
alloy.mounts.extra:

提供 config.alloy 配置

alloy.configMap.content

...
      loki.write "default" {
        endpoint {
          url = "http://loki-gateway.monitor.svc.cluster.local/loki/api/v1/push"
          headers = {
            "X-Scope-OrgID" = "<tenants name>",
          }
          basic_auth {
              username = "vVBkQxXzunLc8Ro3NkSnLyTQ"
              password = "4HVZsgl80lZpnzdznfLf7jB6"
          }
        }
        external_labels = {
          cluster = "<cluster name>",
        }
      }
...

注意,在 Grafana 中,添加 Datasource 时,需要指定 X-Scope-OrgID 头,否则无法查询到日志;

通过 ConfigMap 来提供配置:

  • alloy.configMap.name:
  • alloy.configMap.key:

构建

Alloy, Helm Chart, vesion 0.10.0, appVersion: v1.5.0

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

helm search repo grafana/
helm pull grafana/alloy

应用

场景 | 部署 Alloy 服务

helm show values ./alloy-1.4.0.tgz > alloy-1.4.0.tgz.helm-values.yaml

helm upgrade --install alloy ./alloy-1.4.0.tgz -f alloy-1.4.0.tgz.helm-values.yaml

kubectl  get pods -l app.kubernetes.io/name=alloy -o wide

values.yaml

  • Image 进行容器镜像配置,使用国内镜像仓库;
  • Toleration 进行容忍配置,以调度到所有的节点上;
  • Volume 进行挂载配置,以访问 Node 上的 Pod 日志;
  • Config Alloy 进行 Alloy 配置,实现日志的抓取;

参考

Deploy Grafana Alloy on Kubernetes https://grafana.com/docs/alloy/latest/set-up/install/kubernetes/