Reference
StreamProbe, field by field
Group streaming.allan-nava.github.io, version v1alpha1, kind StreamProbe, namespaced, short name sp. The API is alpha: fields may still change before v1.
spec
| Field | Type | Default | Meaning |
|---|---|---|---|
url | string, required | The HLS playlist: a media playlist, or a multivariant one (its first variant is followed). Must start with http:// or https://; at most 2048 characters. | |
interval | duration | 30s | How often the stream is checked. Values under 5s are raised to 5s. |
timeout | duration | 10s | Bounds one whole check: playlist, variant and segment. |
staleAfter | duration | three target durations | How long the live edge may stand still before the stream is Stale. Without a target duration in the playlist: three intervals. |
checkSegment | bool | true | Ask the origin for the live-edge segment on every check (first 1 KB only). |
status
| Field | Meaning |
|---|---|
conditions | The Ready condition (see below). |
observedGeneration | The spec generation this status was written for. |
lastCheckTime | When the stream was last checked. |
lastAdvanceTime | When the live edge was last seen moving. |
liveEdge | Sequence number of the last segment: mediaSequence + segments − 1. |
mediaSequence | #EXT-X-MEDIA-SEQUENCE at the last good check. |
targetDurationSeconds | #EXT-X-TARGETDURATION at the last good check. |
playlistURL | The media playlist actually read: url, or its first variant. |
playlistLatencyMilliseconds | Time to fetch that playlist. |
segmentStatus | HTTP status of the live-edge segment; 0 when not checked or no answer. |
consecutiveFailures | Checks in a row that could not read the playlist; 0 after a good one. |
lastError | The error of the last failed check; empty after a good one. |
The Ready condition
Tried in this order; the first that applies sets the reason. An event (Normal for Live, Warning otherwise) is recorded when the reason changes.
| Reason | Status | When |
|---|---|---|
FetchFailed | False | The playlist could not be fetched (network, non-200) or parsed, a multivariant playlist had no variant, or the media playlist lists no segment. |
Ended | False | The playlist has #EXT-X-ENDLIST. |
Stale | False | The live edge has not moved for longer than staleAfter. |
SegmentFailed | False | The live-edge segment answered outside 2xx, or not at all. |
Live | True | Otherwise. |
kubectl wait --for=condition=Ready sp/unified-live-demo --timeout=2m
kubectl get sp -o custom-columns=NAME:.metadata.name,REASON:.status.conditions[0].reason,EDGE:.status.liveEdge
Metrics
On the manager's metrics endpoint, next to controller-runtime's own. Labels namespace and name; the series of a deleted probe are dropped.
| Metric | Type | Meaning |
|---|---|---|
streamprobe_ready | gauge | 1 when Ready is True, else 0. |
streamprobe_live_edge | gauge | Sequence number of the last segment. |
streamprobe_seconds_since_advance | gauge | Seconds since the live edge last moved, at the last check. |
streamprobe_playlist_fetch_seconds | histogram | Time to fetch the media playlist. |
streamprobe_checks_total | counter | Checks, with an extra reason label. |
An alert on a stream down for five minutes, for instance:
min_over_time(streamprobe_ready[5m]) == 0
Permissions
Generated from the markers on the controller into config/rbac/role.yaml:
| Resource | Verbs | Why |
|---|---|---|
streamprobes | get, list, watch | read the probes |
streamprobes/status | get, update, patch | write what a check found |
events.k8s.io/events | create, patch | one event per change of verdict |
Install, run, remove
From a clone of the repository, against the cluster of your current kubectl context:
make install # the CRD
make run # the controller on this machine (Ctrl+C to stop)
make deploy # the controller in the cluster, from the published image
make deploy IMG=ghcr.io/allan-nava/streamprobe-operator:0.1.0 # a release instead of :main
kubectl apply -k config/samples # the example StreamProbe
make undeploy # remove the controller
make uninstall # remove the CRD, and with it every StreamProbe
The image is ghcr.io/allan-nava/streamprobe-operator, for linux/amd64 and linux/arm64: :main and :sha-<commit> follow the main branch, :X.Y.Z, :X.Y and :latest the releases. Each release also attaches install.yaml, the whole install pinned to its image:
kubectl apply -f https://github.com/Allan-Nava/streamprobe-operator/releases/latest/download/install.yaml
For development: make test (unit tests and envtest, no Docker), make lint, make manifests generate after changing the markers, make test-e2e on kind.