Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/helm-verify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ jobs:
- name: Install helm-unittest
run: .github/scripts/helm-verify/install-helm-unittest.sh
- name: Run the chart unit tests
run: helm unittest charts/substrate
run: helm unittest charts/substrate charts/substrate-podcert charts/substrate-atelet
4 changes: 4 additions & 0 deletions charts/substrate-atelet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ release grants permissions to the atelet ServiceAccount by name. atelet also
uses it to reach that release's API server. Names other than `substrate`
prefix each object with the release name, for example `team-atelet`.

`metrics.podMonitor` takes the same keys as in the substrate chart and renders
atelet's `PodMonitor`. The substrate chart renders that monitor only while
it renders atelet.

## Existing installs

Upgrading the substrate release with `atelet.enabled=false` deletes atelet.
Expand Down
44 changes: 44 additions & 0 deletions charts/substrate-atelet/templates/podmonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{{/*
Copyright 2026 The Agent Substrate Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/}}
{{/*
atelet's PodMonitor, as the substrate chart renders it when atelet.enabled is
true. atelet serves its metrics on the `prometheus` port.
*/}}
{{- if .Values.metrics.podMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: {{ include "substrate.fullname" (list "atelet" .) }}
namespace: {{ .Release.Namespace }}
labels:
app: atelet
{{- with .Values.metrics.podMonitor.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels:
app: atelet
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
podMetricsEndpoints:
- port: prometheus
path: /metrics
{{- with .Values.metrics.podMonitor.interval }}
interval: {{ . }}
{{- end }}
{{- end }}
70 changes: 70 additions & 0 deletions charts/substrate-atelet/tests/podmonitor_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Copyright 2026 The Agent Substrate Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

suite: atelet PodMonitor
templates:
- podmonitor.yaml
tests:
- it: renders nothing by default
asserts:
- hasDocuments:
count: 0

- it: selects the atelet pods on their prometheus port
set:
metrics.podMonitor.enabled: true
release:
namespace: ate-system
asserts:
- isKind:
of: PodMonitor
- equal:
path: metadata.name
value: atelet
- equal:
path: spec.selector.matchLabels.app
value: atelet
- equal:
path: spec.namespaceSelector.matchNames[0]
value: ate-system
- equal:
path: spec.podMetricsEndpoints[0].port
value: prometheus
- notExists:
path: spec.podMetricsEndpoints[0].interval

# The name follows substrateReleaseName, like every other atelet object, so it
# matches the monitor the substrate chart renders when it owns atelet.
- it: names the monitor after the substrate release
set:
metrics.podMonitor.enabled: true
substrateReleaseName: team
asserts:
- equal:
path: metadata.name
value: team-atelet

- it: carries the interval and the discovery labels
set:
metrics.podMonitor.enabled: true
metrics.podMonitor.interval: 60s
metrics.podMonitor.labels:
release: prometheus
asserts:
- equal:
path: spec.podMetricsEndpoints[0].interval
value: 60s
- equal:
path: metadata.labels.release
value: prometheus
10 changes: 10 additions & 0 deletions charts/substrate-atelet/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ atelet:
cpu: "2"
memory: 1Gi

# Prometheus Operator PodMonitor for atelet's metrics port.
metrics:
podMonitor:
# Requires the monitoring.coreos.com/v1 CRDs.
enabled: false
# Scrape interval. Empty leaves Prometheus' own default.
interval: ""
# Labels on the PodMonitor, such as the ones a podMonitorSelector matches.
labels: {}

# Object storage credentials/settings for the node object-store plugin.
objectStorePlugin:
extraEnv: []
Expand Down
3 changes: 3 additions & 0 deletions charts/substrate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ See `values.yaml` for the full set; the important keys:
| `otel.metrics.endpoint` | `""` | OTLP endpoint for metrics, overriding `otel.endpoint` |
| `otel.logs.enabled` | `true` | Enable OTLP actor events from ateapi and the ateworkers, plus the router access log. Actor events go to stdout when OTLP logs are disabled |
| `otel.logs.endpoint` | `""` | OTLP endpoint for logs, overriding `otel.endpoint` |
| `metrics.podMonitor.enabled` | `false` | Render a Prometheus Operator `PodMonitor` for each workload that serves metrics. Requires the `monitoring.coreos.com/v1` CRDs |
| `metrics.podMonitor.interval` | `""` | Scrape interval. Empty leaves the Prometheus default |
| `metrics.podMonitor.labels` | `{}` | Labels on every `PodMonitor`, such as the ones a `podMonitorSelector` matches |

## Router timeouts

Expand Down
102 changes: 102 additions & 0 deletions charts/substrate/templates/podmonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{{/*
Copyright 2026 The Agent Substrate Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/}}
{{/*
One PodMonitor per workload that serves metrics. Six do, from three sources,
and no two agree on the port name:

ate-api-server, atelet, the atenet router, the atenet egress and the
Kubernetes credential provider start the metrics server themselves
(serverboot's StartMetricsServer). The first two name that port `prometheus`,
the other three name it `metrics`.

ate-controller serves controller-runtime's own metrics server. Its
ctrl.Options sets no Metrics field, and only BindAddress "0" disables that
server, so it binds the default :8080, which its pod already declares as
`metrics`. This endpoint carries the controller_runtime_* and workqueue_*
families that docs/metrics/substrate.yaml lists under
bridged_metric_families.

The router and the egress each run an agentgateway container of their own,
serving its stats on a second port: `gw-metrics` on the router, `stats` on
the egress. Those are the gateway's own metrics rather than the ate
registry's, and they are as uncollected as the rest, so each of those two
monitors carries both endpoints.

Only the first three carry prometheus.io/* annotations, and an annotation is
read only by a Prometheus configured for pod-annotation discovery. A Prometheus
Operator installation discovers PodMonitors instead and ignores annotations, so
without these objects every one of these endpoints is served and none is
collected.

A PodMonitor addresses a NAMED container port, so the name is per workload: one
shared name would match some pods and silently miss the others. The pod label
is per workload too: each carries a bare `app: <component>` except the
credential provider, whose label is the substrate.fullname helper's output and
so depends on the release name.

podcertificate-controller gets no monitor: it emits no metrics, which
docs/metrics/substrate.yaml states under blind_spots. atelet and the credential
provider get one only when the chart renders them. With atelet.enabled=false,
the substrate-atelet chart renders atelet's monitor under the same name.

One object per workload rather than one selecting several: an interval and a
relabeling are a component's own, and the atelet is a DaemonSet whose series
are per node.
*/}}
{{- if .Values.metrics.podMonitor.enabled }}
{{- $components := list
(dict "app" "ate-api-server" "ports" (list "prometheus") "enabled" true)
(dict "app" "ate-controller" "ports" (list "metrics") "enabled" true)
(dict "app" "atelet" "ports" (list "prometheus") "enabled" .Values.atelet.enabled)
(dict "app" "atenet-egress" "ports" (list "metrics" "stats") "enabled" true)
(dict "app" "atenet-router" "ports" (list "metrics" "gw-metrics") "enabled" true)
(dict "app" "k8s-credential-provider" "ports" (list "metrics") "fullnameLabel" true "enabled" .Values.credentialProvider.enabled)
}}
{{- range $components }}
{{- if .enabled }}
{{- $label := .app }}
{{- if .fullnameLabel }}
{{- $label = include "substrate.fullname" (list .app $) }}
{{- end }}
---
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: {{ include "substrate.fullname" (list .app $) }}
namespace: {{ $.Release.Namespace }}
labels:
app: {{ $label }}
{{- with $.Values.metrics.podMonitor.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels:
app: {{ $label }}
namespaceSelector:
matchNames:
- {{ $.Release.Namespace }}
podMetricsEndpoints:
{{- range .ports }}
- port: {{ . }}
path: /metrics
{{- with $.Values.metrics.podMonitor.interval }}
interval: {{ . }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
Loading