helm部署Vector agent
2021-08-05 本文已影响0人
行者深蓝
环境信息
- Kubernetes:v1.20.6
- 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 操作可以参考:
- https://docs.docker.com/engine/reference/commandline/pull/
- https://docs.docker.com/engine/reference/commandline/tag/
- https://docs.docker.com/engine/reference/commandline/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