IBM Cloud Docs
使用 HELM 图表在 Red Hat OpenShift 中管理 Monitoring 代理程序

使用 HELM 图表在 Red Hat OpenShift 中管理 Monitoring 代理程序

您可以使用 Helm Chart 在 Kubernetes 集群上安装,升级和删除 Monitoring 代理程序。

准备工作

  • 在本地计算机上安装 V 3 Helm CLI 的最新发行版。

    Helm是一个Kubernetes包管理器,它使用Helm图表来定义、安装和升级集群中复杂的Kubernetes应用程序。 Helm chart 用于对规范打包,这些规范可为构建应用程序的 Kubernetes 资源生成 YAML 文件。 这些 Kubernetes 资源会在集群中自动应用,并由 Helm 分配版本。 您还可以使用 Helm 来指定和打包您自己的应用程序,并让 Helm 为 Kubernetes 资源生成 YAML 文件。

  • 检查您是否具有在集群上部署 Monitoring 代理程序的访问权和许可权。

  • 验证 ibm-observe 名称空间在集群中是否可用。 代理程序部署在此名称空间中。

部署代理程序

完成以下步骤以使用 Helm部署代理程序:

步骤 1. 设置 SysdigHelm存储库

向 Helm 实例添加 Monitoring Helm 存储库。

完成以下步骤:

  1. 设置集群上下文。

    obmcloud ks cluster config --cluster <CLUSTER_NAME>
    
  2. 添加Helm资源库。

    helm repo add sysdig https://charts.sysdig.com
    
  3. 更新存储库以检索所有 Helm chart 的最新版本。

    helm repo update
    
  4. 列出 Sysdig 软件版本当前可用的Helm图表。

    helm search repo sysdig
    
  5. 验证是否列出了 Helm Chart sysdig/sysdig-deploy

如果发生了以下错误:

helm repo add sysdig https://charts.sysdig.com    --debug
Error: context deadline exceeded
helm.go:84: [debug] context deadline exceeded

运行以下命令并重试。

rm $HOME/Library/Preferences/helm/repositories.lock

步骤 2. 创建值 yaml 文件

定义 yaml 文件并包含用于部署您计划部署的 Monitoring 代理程序和 Workload Protection 组件的值。 例如,将文件命名为 agent-values-monitor-secure.yaml

以下 yaml 是可用于配置 Monitoring 代理程序和 Workload Protection 组件的模板。 您可以通过使用 # 除去或注释代理程序部署不需要的部分来定制文件。

global:
  clusterConfig:
    name: CLUSTER_NAME
  sysdig:
    accessKey: MONITORING_INSTANCE_ACCESS_KEY
    secureAPIToken: SECURE_TOKEN
  kspm:
    deploy: true
agent:
  image:
    tag: AGENT_TAG
    registry: icr.io
  slim:
    enabled: true
    image:
      repository: ext/sysdig/agent-slim
    kmoduleImage:
      repository: ext/sysdig/agent-kmodule
  collectorSettings:
    collectorHost: INGESTION_ENDPOINT    # for example, ingest.eu-gb.monitoring.cloud.ibm.com
nodeAnalyzer:
  nodeAnalyzer:
    deploy: true
    apiEndpoint: API_ENDPOINT   # for example, eu-gb.monitoring.cloud.ibm.com
    benchmarkRunner:
      deploy: false
kspmCollector:
  apiEndpoint: API_ENDPOINT    # for example, eu-gb.monitoring.cloud.ibm.com
admissionController:
  enabled: true
  sysdig:
    url: WEB_UI_ENDPOINT    # for example, https://ingest.eu-gb.monitoring.cloud.ibm.com
  clusterName: CLUSTER_NAME

Where

  • CLUSTER_NAME 是要在其中部署代理程序的集群的名称。
  • MONITORING_INSTANCE_ACCESS_KEY 是 Monitoring 实例访问密钥。
  • SECURE_TOKEN 是安全 API 令牌。
  • AGENT_TAG 是您计划部署的代理程序的版本。
  • INGESTION_ENDPOINT 是实例的采集端点。
  • API_ENDPOINT 是 intance 的 API 端点。
  • WEB_UI_ENDPOINT 是实例的 Web UI 端点。

用于部署代理程序的值 yaml 文件的样本

例如,请参阅仅部署 Monitoring 代理程序的值文件的以下样本:

global:
  clusterConfig:
    name: mycluster-au-syd
  sysdig:
    accessKey: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
    secureAPIToken: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
  kspm:
    deploy: true
agent:
  image:
    registry: icr.io
  slim:
    enabled: true
    image:
      repository: ext/sysdig/agent-slim
    kmoduleImage:
      repository: ext/sysdig/agent-kmodule
  collectorSettings:
    collectorHost: ingest.au-syd.monitoring.cloud.ibm.com

用于部署代理程序和 Node Analyzer 的值 yaml 文件的样本

例如,请参阅用于部署 Monitoring 代理程序和 Node Analyzer 组件的值文件的以下样本:

global:
  clusterConfig:
    name: mycluster-au-syd
  sysdig:
    accessKey: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
    secureAPIToken: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
  kspm:
    deploy: true
agent:
  image:
    registry: icr.io
  slim:
    enabled: true
    image:
      repository: ext/sysdig/agent-slim
    kmoduleImage:
      repository: ext/sysdig/agent-kmodule
  collectorSettings:
    collectorHost: ingest.au-syd.monitoring.cloud.ibm.com
nodeAnalyzer:
  nodeAnalyzer:
    deploy: true
    apiEndpoint: API_ENDPOINT   # for example, eu-gb.monitoring.cloud.ibm.com
    benchmarkRunner:
      deploy: false

步骤 3. 安装 Helm Chart

要部署代理程序和/或 Workload Protection 组件,必须安装 sysdig/sysdig-deploy Chart 并使用在上一步中配置的变量 yaml 文件。

运行以下命令以使用 Helm Chart 安装代理程序:

helm install -n ibm-observe sysdig-agent sysdig/sysdig-deploy -f agent-values-monitor-secure.yaml

如果迂到以下错误: Error: INSTALLATION FAILED: Kubernetes cluster unreachable: xxxxxx failed to refresh token: oauth2: cannot fetch token: 400 Bad Request,请设置集群上下文并重试。

更新代理程序

要使用 Helm更新代理程序版本,请完成以下步骤:

  1. 更新图表。

    helm repo update
    
  2. 查找用于部署代理程序的值 yaml 文件,并使用要部署的代理程序版本修改 agent.image.tag

  3. 升级代理程序。

    helm upgrade -n ibm-observe sysdig-agent sysdig/sysdig-deploy -f agent-values-monitor-secure.yaml
    

除去代理程序

要使用 Helm删除代理程序,必须卸载 Chart。

完成以下步骤:

  1. 列出已安装的 Chart。

    helm list -n ibm-observe
    

    命令输出的图表列表如下:

    NAME        	NAMESPACE  	REVISION	UPDATED                             	STATUS  	CHART              	APP VERSION
    sysdig-agent	ibm-observe	1       	2023-03-24 15:02:58.408108 +0100 CET	deployed	sysdig-deploy-1.6.3
    
  2. 卸载 Chart。

    helm delete sysdig-agent  -n ibm-observe
    

    就 Helm而言,sysdig-agent 是 teh 发行版的名称。

    如果忘记在命令中包含名称空间,那么会收到follo庆错误: Error: uninstall: Release not loaded: sysdig-agent: release: not found