0

我正在尝试使用服务监视器部署入口控制器,我正在使用如下所示的 helm values 文件:

controller:
  replicaCount: 3
  minAvailable: 1

  config:
    use-forwarded-headers: "true"
    use-proxy-protocol: "true"
    keep-alive: "3600"
  service:
    externalTrafficPolicy: Local
    type: LoadBalancer
  metrics:
    enabled: true
    serviceMonitor:
      enabled: true

rbac:
  create: true

serviceAccount:
  create: true
  name: nginx-ingress-serviceaccount

当我使用提供的值文件运行 helm 模板时,服务监视器不可见。

helm template ingress-nginx/ingress-nginx --values values.yaml --version "4.0.5"

有没有人有类似的问题?提前感谢您的回复。

4

1 回答 1

0

ServiceMonitor 需要填充 3 个条件,请确保您的集群和配置满足这些条件:https ://github.com/kubernetes/ingress-nginx/blob/6299c39842c31ff1e17d72503003ca36e2976a9a/charts/ingress-nginx/templates/controller-servicemonitor.yaml #L1

您的集群应该支持:monitoring.coreos.com/v1 API 版本

如果您使用 API 条件不存在的旧图表版本,您将能够使用当前 values.yaml 部署 ServiceMonitor

helm template ingress-nginx/ingress-nginx --values values.yaml --version "3.15.2" | grep -i mon
# Source: ingress-nginx/templates/controller-servicemonitor.yaml
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor

另外,请注意:https ://helm.sh/docs/helm/helm_template/

Render chart templates locally and display the output.

Any values that would normally be looked up or retrieved in-cluster will be faked locally. Additionally, none of the server-side testing of chart validity (e.g. whether an API is supported) is done.

这意味着如果你在你的机器上运行命令行,它永远不会显示,ServiceMonitor除非你有一个支持的本地 k8s 集群monitoring.coreos.com/v1或者你也伪造它:) 如下

helm template ingress-nginx/ingress-nginx --values values.yaml --version "4.0.5" --api-versions "monitoring.coreos.com/v1" | grep -i mon
# Source: ingress-nginx/templates/controller-servicemonitor.yaml
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor

于 2021-11-19T13:57:22.590 回答