美文网首页
helm部署Vector agent

helm部署Vector agent

作者: 行者深蓝 | 来源:发表于2021-08-05 15:27 被阅读0次

    环境信息

    1. Kubernetes:v1.20.6
    2. Helm:v3.5.2

    本安装前准备工作

    1. 同步海外源镜像

    在国内环境部署应用,经常因为获取国外源站容器镜像超时,导致部署失败,可以提前将容器镜像同步到本地镜像仓库中,以自有镜像仓库uhub.service.ucloud.cn/ucloud_pts 为例,login仓库,执行命令: docker login uhub.service.ucloud.cn/ucloud_pts
    需要同步镜像列表如下:

    docker.io/timberio/vector:0.15.X-debian
    

    关于docker pull tag push 操作可以参考:

    3. 创建 imagePullSecrets

    创建容器集群访问仓库地址 uhub.service.ucloud.cn/ucloud_pts,拉取镜像需要的 secret

    kubectl create namespace logsystem
    kubectl create secret docker-registry registry-vector-secret \
            --namespace=logsystem \
            --docker-server=uhub.service.ucloud.cn/ucloud_pts \
            --docker-username='xxxxxx' \
            --docker-password='xxxxxx'
    

    4. 添加 Helm仓库

    这里选用 timberio 提供的chart仓库

    helm repo add timberio https://packages.timber.io/helm/latest
    helm repo update
    

    5. 定义配置,完成部署

    cat > vector-agent-values.yaml << EOF
    image:
      repository: uhub.service.ucloud.cn/ucloud_pts
      tag: "0.15.X-debian"
    imagePullSecrets:
      - registry-vector-secret
    extraVolumes:
      - name: data-log-pods
        hostPath:
          path: /data/log/pods/
    extraVolumeMounts:
      - name: data-log-pods
        mountPath: /data/log/pods/
    customConfig:
      data_dir: /data
      sources:
        kubernetes_logs:
          type: kubernetes_logs
          data_dir: "/data/log/pods/"
          timezone: local
      sinks:
        sink_to_loki:
          type: loki
          inputs:
            - kubernetes_logs
          endpoint: "https://loki-gateway.onwalk.net/loki/api/v1/push"
          labels:
            "cluster": "admin"
          encoding:
            codec: json
            timestamp_format: rfc3339
          healthcheck:
            enabled: false
    EOF
    helm upgrade --install vector-agent timberio/vector-agent -n loki -f vector-agent-values.yaml
    kubectl rollout restart -n loki daemonset/vector-agent
    
    helm upgrade --install vector-agent  -n logsystem    \
         -f vector-agent-values.yaml timberio/vector-agent
    kubectl rollout restart -n loki daemonset/vector-agent
    

    参考

    1. https://vector.dev/docs/reference/configuration/sources/kubernetes_logs/
    2. https://vector.dev/docs/reference/configuration/sinks/loki/
    3. https://grafana.com/docs/loki/latest/api/#post-lokiapiv1push

    相关文章

      网友评论

          本文标题:helm部署Vector agent

          本文链接:https://www.haomeiwen.com/subject/lwtevltx.html