Skip to content
streamprobe

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

FieldTypeDefaultMeaning
urlstring, requiredThe HLS playlist: a media playlist, or a multivariant one (its first variant is followed). Must start with http:// or https://; at most 2048 characters.
intervalduration30sHow often the stream is checked. Values under 5s are raised to 5s.
timeoutduration10sBounds one whole check: playlist, variant and segment.
staleAfterdurationthree target durationsHow long the live edge may stand still before the stream is Stale. Without a target duration in the playlist: three intervals.
checkSegmentbooltrueAsk the origin for the live-edge segment on every check (first 1 KB only).

status

FieldMeaning
conditionsThe Ready condition (see below).
observedGenerationThe spec generation this status was written for.
lastCheckTimeWhen the stream was last checked.
lastAdvanceTimeWhen the live edge was last seen moving.
liveEdgeSequence 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.
playlistURLThe media playlist actually read: url, or its first variant.
playlistLatencyMillisecondsTime to fetch that playlist.
segmentStatusHTTP status of the live-edge segment; 0 when not checked or no answer.
consecutiveFailuresChecks in a row that could not read the playlist; 0 after a good one.
lastErrorThe 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.

ReasonStatusWhen
FetchFailedFalseThe playlist could not be fetched (network, non-200) or parsed, a multivariant playlist had no variant, or the media playlist lists no segment.
EndedFalseThe playlist has #EXT-X-ENDLIST.
StaleFalseThe live edge has not moved for longer than staleAfter.
SegmentFailedFalseThe live-edge segment answered outside 2xx, or not at all.
LiveTrueOtherwise.
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.

MetricTypeMeaning
streamprobe_readygauge1 when Ready is True, else 0.
streamprobe_live_edgegaugeSequence number of the last segment.
streamprobe_seconds_since_advancegaugeSeconds since the live edge last moved, at the last check.
streamprobe_playlist_fetch_secondshistogramTime to fetch the media playlist.
streamprobe_checks_totalcounterChecks, 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:

ResourceVerbsWhy
streamprobesget, list, watchread the probes
streamprobes/statusget, update, patchwrite what a check found
events.k8s.io/eventscreate, patchone 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.