While I deploying v2ray-exporter with Kustomize, I realized that
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?
It seems to me really easy to get confused with
commonLabels in Kustomize configuration files or
kustomization.yaml. The name
commonLabels exists in both of them, but the definitions are totally different.