Integrate ServiceMonitor matchLabels with Kustomize commonLabels

While I deploying v2ray-exporter with Kustomize, I realized that commonLabels in kustomization.yaml doesn’t take care of the spec.selector.matchLabels field in ServiceMonitors. That makes sense, as ServiceMonitor is a part of CoreOS’s Prometheus Operator project, neither included nor maintained by Kubernetes. But how can we direct Kustomize to fill the labels in ServiceMonitors or even any fields in customized resources?

September 12, 2020 · Wi1dcard