My chart: kube-prometheus-stack-54.2.2
I added four external nodes:
---
apiVersion: v1
kind: Service
metadata:
name: external-infra
namespace: ops-monit
labels:
app: external-infra
spec:
ports:
- name: metrics
port: 9100
protocol: TCP
targetPort: 9100
---
apiVersion: v1
kind: Endpoints
metadata:
name: external-infra
namespace: ops-monit
subsets:
- addresses:
- ip: 10.128.0.13
- ip: 10.128.0.4
- ip: 10.128.0.7
- ip: 10.128.0.10
ports:
- name: metrics
port: 9100
protocol: TCP
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: external-infra
namespace: ops-monit
labels:
app: external-infra
spec:
endpoints:
- port: metrics
interval: 10s
path: /metrics
selector:
matchLabels:
app: external-infra
namespaceSelector:
matchNames:
- ops-monit
Then I checked that the service sees the endpoints:
$ kubectl describe ep external-infra
Name: external-infra
Namespace: ops-monit
Labels: <none>
Annotations: <none>
Subsets:
Addresses: 10.128.0.13,10.128.0.4,10.128.0.7,10.128.0.10
NotReadyAddresses: <none>
Ports:
Name Port Protocol
---- ---- --------
metrics 9100 TCP
Events: <none>
$ kubectl describe svc external-infra
Name: external-infra
Namespace: ops-monit
Labels: app=external-infra
Annotations: <none>
Selector: <none>
Type: ClusterIP
IP Family Policy: SingleStack
IP Families: IPv4
IP: 10.120.203.151
IPs: 10.120.203.151
Port: metrics 9100/TCP
TargetPort: 9100/TCP
Endpoints: 10.128.0.13:9100,10.128.0.4:9100,10.128.0.7:9100 + 1 more...
Session Affinity: None
Events: <none>
But Prometheus still doesn’t see my nodes:

What is my mistake?
The Stack requires writing more text because there is more code than text. I hope the Stackoverflow will accept this text and allow me to create this question.