Skip to content

fix(k8s): start SearXNG when its metrics Secret is missing - #6811

Merged
dan-petty merged 8 commits into
mainfrom
fix/6805-searxng-optional-metrics-secret
Nov 23, 2026
Merged

dan-petty merged 8 commits into
mainfrom
fix/6805-searxng-optional-metrics-secret

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

SearXNG starts and searches when Secret devops/searxng-metrics-auth is missing. Only /metrics is off.

  • The reference of init container render-settings to the Secret is optional: true. With no password, the script writes '' for general.open_metrics, logs one line that names the Secret and exits 0, and /metrics answers HTTP 404.
  • A new check of the k8s row runs the script with sh against the volumes that the kubelet mounts, with and without the Secret.
  • Entry password of row devops/searxng-metrics-auth is not required, and OPTIONAL_FEATURE_SECRETS names the row, so a push with no password skips it with a warning.
  • k8s/README.md and docs/CLUSTER.md say that the Secret is optional. While it is missing, Alloy makes no target from ServiceMonitor searxng, so TargetDown does not fire.

Closes #6805

Change: openspec/changes/archive/2026-11-22-6805-searxng-optional-metrics-secret/

… its metrics Secret

The check of the k8s row runs the script of the init container against the volumes that the
kubelet mounts. Without Secret devops/searxng-metrics-auth, the kubelet does not start the init
container, because its reference to the Secret is required.
The reference of render-settings to Secret devops/searxng-metrics-auth is optional. With no
password, the script writes an empty general.open_metrics, which turns /metrics off, and logs
one line that names the Secret.
The metrics are an optional feature, so the row of devops/searxng-metrics-auth is in
OPTIONAL_FEATURE_SECRETS and a push with no password skips it.
Entry password of devops/searxng-metrics-auth is not required, and OPTIONAL_FEATURE_SECRETS
names the row, so deploy-stack does not stop on the password of an optional feature.
The Cluster Secrets paragraph and the SearXNG section say what the pod, /metrics and Alloy do
while Secret devops/searxng-metrics-auth is missing.
@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/k8s Kubernetes commands, Helm charts, pods, services, and policies labels Nov 22, 2026
@dan-petty

dan-petty commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner Author

What the scrape does while the Secret is missing

The ServiceMonitor searxng stays. While Secret devops/searxng-metrics-auth is missing, the scrape does not fail: Alloy makes no scrape target at all. The live log of k8s-monitoring-alloy-metrics-0 on 2026-11-22 shows this each time Alloy reads the monitor:

level=error msg="error generating scrapeconfig from serviceMonitor" ... kind=serviceMonitor name=searxng err="secrets \"searxng-metrics-auth\" not found"

So no up series exists for the endpoint, and TargetDown (up == 0) does not fire. The issue expected an alert that shows the missing Secret; no current rule gives one. The only signals are the Alloy error line above and the one line that render-settings logs (kubectl -n devops logs deploy/searxng -c render-settings). SearXNG answers /metrics with HTTP 404 open metrics is disabled (stats_open_metrics in searx/webapp.py).

A push that adds the password to an existing Secret restarts deployment/searxng. A push that creates the Secret restarts nothing (SecretPlan.changed() is false when no live Secret exists), so the running pod keeps the endpoint off until a person restarts the Deployment. The new pod serves the endpoint. Alloy reads the Secret again only when it reads the monitor again (the two reads in the log of 2026-11-22 were about 5 hours apart), so the target can come some hours after the push.

Person step

  • To turn the endpoint on: uv run keyring set devops-cli searxng_metrics_password, then devops k8s push-secrets --only devops/searxng-metrics-auth. If the push created the Secret, then kubectl -n devops rollout restart deployment/searxng. No push is needed before the merge: the new pod starts without the Secret.
  • After the Argo CD sync: kubectl -n devops get pods -l app.kubernetes.io/name=searxng shows no pod in Init:CreateContainerConfigError, and devops k8s searxng-check passes.

Review points

  • The change sets required=False on entry password of row devops/searxng-metrics-auth, so the README row says no and skip with a warning. Before, a push of stack devops with no keyring value stopped all of deploy-stack. Now such a push writes the Secret with key username only, and the endpoint stays off.
  • Not done, for the owner to decide in its own item: a generator for the metrics password (as for monitoring/grafana-image-renderer), so that the push makes the value and no person types it; and an alert on the Alloy error for a ServiceMonitor whose Secret is missing.
  • The check tests/gate/k8s_checks/searxng_render.py runs the script with the local sh (dash on the runner). The script uses POSIX sh only; it also passed under bash --posix. The sh of the pinned SearXNG image was not run.

…thing

A push restarts the workloads of a changed Secret only. A push that
creates Secret devops/searxng-metrics-auth restarts nothing, so the
running pod keeps the endpoint off. The documents now tell the person
to restart deployment/searxng after such a push.
@dan-petty
dan-petty marked this pull request as ready for review November 23, 2026 00:39
@dan-petty
dan-petty merged commit a11d112 into main Nov 23, 2026
30 checks passed
@dan-petty
dan-petty deleted the fix/6805-searxng-optional-metrics-secret branch November 23, 2026 00:43
dan-petty pushed a commit that referenced this pull request Nov 23, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.197.0](v0.196.0...v0.197.0)
(2026-11-23)


### Features

* **repos:** report the drift of onboarded repositories nightly
([#6816](#6816))
([7432f0f](7432f0f))
* **roadmap:** Add toolsets for implement and review
([#6810](#6810))
([ec5b16b](ec5b16b))


### Bug Fixes

* **deps:** update container images
([#6817](#6817))
([fb349e5](fb349e5))
* **k8s:** start SearXNG when its metrics Secret is missing
([#6811](#6811))
([a11d112](a11d112))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/k8s Kubernetes commands, Helm charts, pods, services, and policies type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(k8s): start SearXNG when its metrics Secret is missing

1 participant