Rancher UI 开启 Cilium 指标监控
本文永久链接: https://www.xtplayer.cn/cilium/rancher-ui-enables-cilium-metric-monitoring/
如果在 Rancher UI 创建集群使用内置的 Cilium CNI 驱动,默认是没有启用 Cilium 的指标监控功能。Cilium Chart 是有启用监控指标功能参数的,比如如下链接所示:
因此如果需要启用 Cilium 的指标监控,需要自定义 Cilium Chart 运行参数。
Cilium Chart 自定义参数
在 Rancher UI 创建集群,有两种方法自定义 Cilium Chart 参数。
通过 chartValues 自定义 Cilium Chart 参数
编辑集群的 YAML 配置,在 spec.rkeConfig.chartValues 下可以自定义 Chart 参数。配置示例如下:
spec: |
通过 HelmChartConfig 自定义 Cilium Chart 参数
RKE2 有一个 HelmChartConfig CRD 资源,具体说明可以参考以下文档。
https://docs.rke2.io/add-ons/helm#customizing-packaged-components-with-helmchartconfig
可以通过 HelmChartConfig CRD,添加自定义的 Cilium Chart 参数。将 HelmChartConfig 部署到 Kubernetes 集群之后,RKE2 会将自定义的参数与 Cilium Chart values 合并。
注意: 一个 HelmChartConfig 配置只能对应一个 Chart 应用,如果有多个 Chart 应用,需要创建多个 HelmChartConfig,并且 HelmChartConfig 的名称需要与 Chart 应用名称对应。
apiVersion: helm.cattle.io/v1 |
apiVersion: helm.cattle.io/v1 |
启用 grafana 自动识别其他命名空间中的监控图表配置映射
根据前面步骤操作后,会在 kube-system 命名空间中生成名为 cilium-dashboard 的 configmap,它的数据内容为 cilium-dashboard.json。查看这个 configmap 的YAML,在 Labels 中可以看到有 grafana_dashboard: "1"。grafana 会自动识别这个 Label ,具有这个 Labels 的 dashboard.json configmap,grafana 会自动加载。
但是在 Rancher UI 部署的 rancher-monitoring App,默认配置下只识别 cattle-dashboards 命名空间下的 dashboard.json configmap。要想其他命名空间中的 dashboard.json configmap 被自动识别,需要修改grafana.sidecar.dashboards.searchNamespace 参数,将其设置为 ALL,默认为 cattle-dashboards。或者按如下方式,指定多个命名空间。
sidecar: |


