跳转至

通过 Helm 部署 Insight Agent

本文描述了在命令行中通过 Helm 命令安装 Insight Agent 社区版的操作步骤。

安装 Insight Agent

  1. 使用以下命令添加镜像仓库的地址

    helm repo add insight https://release.daocloud.io/chartrepo/insight
    helm repo update
    helm search repo  insight/insight-agent --versions
    
  2. 安装 Insight Agent 需要确保全局服务集群中的 Insight Server 正常运行,执行以下安装命令安装 Insight Agent 社区版,该配置不启用 Tracing 功能:

    先设置部署版本、服务地址和端口以及 Elasticsearch 的用户名和密码。 服务地址可参考下方的 如何获取连接地址 获取。请将以下占位值替换为实际配置:

    version="<部署版本>"
    es_host="<Elasticsearch 地址>"
    es_port="<Elasticsearch 端口>"
    es_user="<Elasticsearch 用户名>"
    es_password="<Elasticsearch 密码>"
    vminsert_host="<vminsert 地址>"
    vminsert_port="<vminsert 端口>"
    otel_col_host="<opentelemetry-collector 地址>"
    otel_col_auditlog_port="<opentelemetry-collector 审计日志端口>"
    
    helm upgrade --install --create-namespace --cleanup-on-fail \
        --version "${version}" \
        insight-agent  insight/insight-agent \
        --set global.exporters.logging.elasticsearch.host="${es_host}" \
        --set global.exporters.logging.elasticsearch.port="${es_port}" \
        --set global.exporters.logging.elasticsearch.user="${es_user}" \
        --set global.exporters.logging.elasticsearch.password="${es_password}" \
        --set global.exporters.metric.host="${vminsert_host}" \
        --set global.exporters.metric.port="${vminsert_port}" \
        --set global.exporters.auditLog.host="${otel_col_host}" \
        --set global.exporters.auditLog.port="${otel_col_auditlog_port}" \
        -n insight-system
    

    Info

    可参考 如何获取连接地址 获取地址信息。

  3. 执行以下命令确认安装状态:

    helm list -A
    kubectl get pods -n insight-system
    

如何获取连接地址

在全局服务集群安装 Insight Agent

如果 Agent 是安装在管理集群,推荐通过域名来访问集群:

export vminsert_host="vminsert-insight-victoria-metrics-k8s-stack.insight-system.svc.cluster.local" # 指标
export es_host="insight-es-master.insight-system.svc.cluster.local" # 日志
export otel_col_host="insight-opentelemetry-collector.insight-system.svc.cluster.local" # 链路

在工作集群安装 Insight Agent

全局服务集群使用默认的 LoadBalancer 方式暴露服务时,登录全局服务集群的控制台,执行以下命令:

export INSIGHT_SERVER_IP=$(kubectl get service insight-server -n insight-system --output=jsonpath={.spec.clusterIP})
curl --location --request POST 'http://'"${INSIGHT_SERVER_IP}"'/apis/insight.io/v1alpha1/agentinstallparam'

将获得如下的返回值:

{"global":{"exporters":{"logging":{"output":"elasticsearch","elasticsearch":{"host":"10.6.182.32"},"kafka":{},"host":"10.6.182.32"},"metric":{"host":"10.6.182.32"},"auditLog":    {"host":"10.6.182.32"}}},"opentelemetry-operator":{"enabled":true},"opentelemetry-collector":{"enabled":true}}

其中:

  • global.exporters.logging.elasticsearch.host 是日志服务地址【不需要再设置对应服务的端口,都会使用相应默认值】;
  • global.exporters.metric.host 是指标服务地址;
  • global.exporters.trace.host 是链路服务地址;
  • global.exporters.auditLog.host 是审计日志服务地址 (和链路使用的同一个服务不同端口);

登录全局服务集群的控制台,执行以下命令:

kubectl get service -n insight-system | grep lb
kubectl get service -n mcamel-system | grep es

其中:

  • lb-vminsert-insight-victoria-metrics-k8s-stack 是指标服务的地址;
  • lb-insight-opentelemetry-collector 是链路服务的地址;
  • mcamel-common-es-cluster-masters-es-http 是日志服务的地址;

全局服务集群使用 Nodeport 方式暴露服务时,登录全局服务集群的控制台,执行以下命令:

kubectl get service -n insight-system
kubectl get service -n mcamel-system

其中:

  • vminsert-insight-victoria-metrics-k8s-stack 是指标服务的地址;
  • insight-opentelemetry-collector 是链路服务的地址;
  • mcamel-common-es-cluster-masters-es-http 是日志服务的地址;

升级 Insight Agent

  1. 登录目标集群的控制台,执行以下命令备份 --set 参数。

    helm get values insight-agent -n insight-system -o yaml > insight-agent.yaml
    
  2. 执行以下命令更新仓库。

    helm repo update
    
  3. 执行以下命令进行升级。

    helm upgrade insight-agent insight/insight-agent \
    -n insight-system \
    -f ./insight-agent.yaml \
    --version "${version}"   # 指定升级版本
    
  4. 执行以下命令确认安装状态:

    kubectl get pods -n insight-system
    

卸载 Insight Agent

helm uninstall insight-agent -n insight-system --timeout 10m

评论