Compare commits
51
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4c5665aa75 | ||
|
|
38091cbe11 | ||
|
|
33c0266fc1 | ||
|
|
b10b50fd2d | ||
|
|
f9c517bd37 | ||
|
|
49cafb2f6d | ||
|
|
6fa10a7744 | ||
|
|
b341b26673 | ||
|
|
aad24d4186 | ||
|
|
7ef4475952 | ||
|
|
aca39a5a8f | ||
|
|
d7ca8dda11 | ||
|
|
c8483b3545 | ||
|
|
bb090e6809 | ||
|
|
5aee6a54ad | ||
|
|
8a53171ad0 | ||
|
|
299194247e | ||
|
|
6b6e1e7e04 | ||
|
|
752fcd5d03 | ||
|
|
55cd083484 | ||
|
|
ada3d3d0b4 | ||
|
|
1bd3111912 | ||
|
|
0e12e90509 | ||
|
|
613e1da011 | ||
|
|
6998845854 | ||
|
|
430c710fd0 | ||
|
|
6accd1d3cd | ||
|
|
6178063299 | ||
|
|
0b7a2b6c46 | ||
|
|
772311c574 | ||
|
|
7bf1681c2d | ||
|
|
c9cd0783df | ||
|
|
7e57b42316 | ||
|
|
9afb56536c | ||
|
|
23c089c8b7 | ||
|
|
a3eb69ee20 | ||
|
|
c6cb6b3aec | ||
|
|
29c299c0fe | ||
|
|
a3efc511c8 | ||
|
|
924b6e9e88 | ||
|
|
5bfa957f29 | ||
|
|
0806bdfab5 | ||
|
|
9d1b034d0f | ||
|
|
46af8158ca | ||
|
|
d30afa09c2 | ||
|
|
6a82260500 | ||
|
|
ab55215532 | ||
|
|
7b9886545f | ||
|
|
08004a508a | ||
|
|
3d3510b7bd | ||
|
|
bd9f0cb18d |
@@ -35,25 +35,25 @@ when:
|
||||
steps:
|
||||
- name: model-selection-tests
|
||||
depends_on: []
|
||||
image: gitea.renner.uno/gitea_admin/ci-claude:2.1.306
|
||||
image: gitea.renner.uno/gitea_admin/ci-claude:2.1.310
|
||||
commands:
|
||||
- sh scripts/ci/test-model-selection.sh
|
||||
|
||||
- name: pr-review-mistral-tests
|
||||
depends_on: []
|
||||
image: gitea.renner.uno/gitea_admin/ci-claude:2.1.306
|
||||
image: gitea.renner.uno/gitea_admin/ci-claude:2.1.310
|
||||
commands:
|
||||
- sh scripts/ci/test-pr-review-mistral.sh
|
||||
|
||||
- name: promtool-rules-guard-tests
|
||||
depends_on: []
|
||||
image: gitea.renner.uno/gitea_admin/ci-claude:2.1.306
|
||||
image: gitea.renner.uno/gitea_admin/ci-claude:2.1.310
|
||||
commands:
|
||||
- sh scripts/ci/test-promtool-rules.sh
|
||||
|
||||
- name: yaml-citations-guard-tests
|
||||
depends_on: []
|
||||
image: gitea.renner.uno/gitea_admin/ci-claude:2.1.306
|
||||
image: gitea.renner.uno/gitea_admin/ci-claude:2.1.310
|
||||
commands:
|
||||
- sh scripts/ci/test-yaml-citations.sh
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ steps:
|
||||
# fetch-models.sh response mapping. No cluster, no secrets, no network — the
|
||||
# ci-claude image just provides sh + jq. Keeps the flag-injection regression
|
||||
# test from rotting (it exercises the exact injection shapes).
|
||||
image: gitea.renner.uno/gitea_admin/ci-claude:2.1.306
|
||||
image: gitea.renner.uno/gitea_admin/ci-claude:2.1.310
|
||||
commands:
|
||||
- sh scripts/ci/test-model-selection.sh
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ steps:
|
||||
# this step is skipped — otherwise we'd fork-bomb PRs.
|
||||
when:
|
||||
- branch: main
|
||||
image: gitea.renner.uno/gitea_admin/ci-claude:2.1.306
|
||||
image: gitea.renner.uno/gitea_admin/ci-claude:2.1.310
|
||||
environment:
|
||||
CLAUDE_CODE_OAUTH_TOKEN:
|
||||
from_secret: claude_code_oauth_token
|
||||
|
||||
@@ -30,7 +30,7 @@ when:
|
||||
|
||||
steps:
|
||||
- name: update-audit-agent
|
||||
image: gitea.renner.uno/gitea_admin/ci-claude:2.1.306
|
||||
image: gitea.renner.uno/gitea_admin/ci-claude:2.1.310
|
||||
environment:
|
||||
CLAUDE_CODE_OAUTH_TOKEN:
|
||||
from_secret: claude_code_oauth_token
|
||||
|
||||
+13
-14
@@ -72,14 +72,14 @@ none of these commands.
|
||||
|
||||
## Secrets (before first play run)
|
||||
|
||||
Create `inventory/group_vars/edge_host/vault.yml` with ansible-vault; the
|
||||
current live values come straight out of the cluster:
|
||||
Create `inventory/group_vars/edge_host/vault.yml` with ansible-vault. The
|
||||
cluster broker has no `open3e` user: edge-1 logs in only as the register
|
||||
account `edge-1` (see "MQTT bridge" below), so
|
||||
`vault_edge_open3e_mqtt_password` reaches only the loopback broker, which
|
||||
allows anonymous clients; any random value works (`openssl rand -hex 24`).
|
||||
The zwave-js value comes out of the cluster:
|
||||
|
||||
```
|
||||
# sml2mqtt broker password
|
||||
kubectl -n home-assistant get secret mosquitto-sml2mqtt-credentials -o jsonpath='{.data.password}' | base64 -d
|
||||
# open3e broker password
|
||||
kubectl -n home-assistant get secret mosquitto-open3e-credentials -o jsonpath='{.data.password}' | base64 -d
|
||||
# zwave-js session secret
|
||||
kubectl -n home-assistant get secret zwave-js-session -o jsonpath='{.data.session-secret}' | base64 -d
|
||||
```
|
||||
@@ -230,15 +230,14 @@ They connect to a **local mosquitto on loopback** (`127.0.0.1:1883`,
|
||||
broker is briefly unreachable, and flushes on reconnect — edge-1 no longer
|
||||
hard-depends on cluster/network uptime for every publish.
|
||||
|
||||
Two bridge `connection`s preserve the existing cluster identities, so **no
|
||||
cluster-side change was needed**: one authenticates as the `open3e` user
|
||||
(carries `open3e/#` out + `open3e/cmnd` back), one as `sml2mqtt` (`sml2mqtt/#`
|
||||
out). The local broker is `allow_anonymous` on loopback — the trust boundary
|
||||
is the host; nothing off-host can reach it.
|
||||
The local broker is `allow_anonymous` on loopback — the trust boundary is the
|
||||
host; nothing off-host can reach it.
|
||||
|
||||
**Bridge credential (REN-1307).** The two vault-password bridges are being
|
||||
replaced by one bridge as the register account `edge-1`
|
||||
(`kubernetes/apps/home-assistant/mqtt-accounts.yaml`). Its password is pushed
|
||||
**Bridge credential (REN-1307).** One bridge `connection` logs in as the
|
||||
register account `edge-1` (`kubernetes/apps/home-assistant/mqtt-accounts.yaml`)
|
||||
and carries `open3e/#` out and `open3e/cmnd` back. The cluster broker does not
|
||||
accept the vault-password bridges in `bridge.d/legacy.conf`, which exists only
|
||||
until the first push. Its password is pushed
|
||||
by mqtt-account-controller to `edge-mqtt-cred` (`:8443`, the controller's
|
||||
esp32 API over HTTPS). That endpoint accepts only a client certificate from
|
||||
the MQTT CA with CN `mqtt-account-controller`; edge-1 holds the public CA and
|
||||
|
||||
@@ -95,9 +95,8 @@ the VM enrolled as `claude-ws-190-112.nb.renner.uno` / `100.96.190.112` (+ IPv6)
|
||||
> inventory targets the tunnel DHCP IP.
|
||||
|
||||
> **DNS trap.** `claude-ws.obg.renner.uno` resolves to the VM's lease **only at
|
||||
> the off-site DNS** (`@10.3.40.1`). The home resolver catch-alls `*.renner.uno`
|
||||
> to the public proxy (`162.55.50.97`, the Netbird VPS) — so from home the FQDN
|
||||
> lands on `root@netbird`, **not** the VM. Never use it as `ansible_host`.
|
||||
> the off-site DNS** (`@10.3.40.1`). From home this FQDN does not resolve (it
|
||||
> exists only at the off-site DNS @10.3.40.1). Never use it as `ansible_host`.
|
||||
|
||||
**Optional — mesh route to the k8s API (redundant read path):** to reach the API
|
||||
over the mesh too, add a Netbird dashboard **network route** advertising the
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#
|
||||
# Enforces the decisions the in-cluster CrowdSec already detects, at the point
|
||||
# where public traffic actually enters: these hosts terminate TLS for every
|
||||
# *.renner.uno name. A drop here never reaches the mesh, the relay or the
|
||||
# public renner.uno name. A drop here never reaches the mesh, the relay or the
|
||||
# cluster.
|
||||
#
|
||||
# Detection stays in the cluster. The reverse-proxy produces no parseable
|
||||
|
||||
@@ -157,6 +157,29 @@
|
||||
ansible.builtin.pause:
|
||||
seconds: 10
|
||||
|
||||
# The host's mesh client must not manage DNS: containers here resolve through
|
||||
# the host stub, and the renner.uno nameserver group is unreachable from it.
|
||||
- name: Check for the host NetBird client
|
||||
ansible.builtin.stat:
|
||||
path: /usr/bin/netbird
|
||||
register: _netbird_client
|
||||
|
||||
- name: Read the host NetBird client config
|
||||
ansible.builtin.command: netbird debug config
|
||||
register: _netbird_client_config
|
||||
changed_when: false
|
||||
when: _netbird_client.stat.exists
|
||||
|
||||
# disable-dns is only applied on a fresh `up`, not to a connected client.
|
||||
- name: Reconnect the host NetBird client with DNS management disabled
|
||||
ansible.builtin.shell: |
|
||||
set -eu
|
||||
netbird down
|
||||
netbird up --disable-dns
|
||||
when:
|
||||
- _netbird_client.stat.exists
|
||||
- not (_netbird_client_config.stdout | from_json).disableDns
|
||||
|
||||
- name: Display deployment status
|
||||
ansible.builtin.debug:
|
||||
msg: |
|
||||
|
||||
@@ -1,34 +1,26 @@
|
||||
#!/usr/bin/env python3
|
||||
"""authentik-gate-sync: an ingress class that puts an Authentik proxy gate in front of an app.
|
||||
"""authentik-gate-sync: the Authentik side of the gate Middleware.
|
||||
|
||||
Source of truth: every Ingress with spec.ingressClassName "authentik-gate". Traefik
|
||||
ignores that class (its IngressClass names another controller), so a source
|
||||
Ingress is never served directly. For each one this controller builds:
|
||||
An Ingress is gated when its traefik.ingress.kubernetes.io/router.middlewares
|
||||
annotation names the gate Middleware (authentik/gate, a ForwardAuth against the
|
||||
embedded outpost in authentik-server; kubernetes/apps/authentik/gate.yaml). The
|
||||
gate's configuration lives on that Ingress; for each one this controller builds:
|
||||
|
||||
Authentik proxy provider + application + outpost (+ group-membership
|
||||
expression policy bound to the application).
|
||||
Authentik's own Kubernetes integration then runs the outpost as
|
||||
ak-outpost-<gate> in the authentik namespace.
|
||||
app ns ExternalName Service <ingress>-gate -> the outpost Service,
|
||||
Traefik Ingress <ingress>-gate: the source's hosts, paths, TLS,
|
||||
labels and annotations, backend swapped for the gate,
|
||||
CNP <ingress>-gate: the backend pods admit this outpost.
|
||||
authentik CNP gate-<gate>: the outpost may reach only those backend pods.
|
||||
Authentik forward_single proxy provider for the Ingress's host +
|
||||
application (+ group-membership expression policy bound to it),
|
||||
the provider attached to the embedded outpost.
|
||||
app ns CNP <ingress>-gate: the backend pods admit Traefik.
|
||||
|
||||
Like any ingress controller it publishes the source's status.loadBalancer: the
|
||||
address Traefik reports for the route, or none while the gate has no route.
|
||||
|
||||
The source Ingress's backend is the real upstream; it becomes the provider's
|
||||
internal host and its host the external host. Annotations (all optional):
|
||||
Annotations (all optional):
|
||||
|
||||
auth.renner.uno/group group whose members may pass; none = any user
|
||||
auth.renner.uno/login-flow authentication flow slug; none = the brand's
|
||||
auth.renner.uno/authorization-flow authorization flow slug (default below)
|
||||
auth.renner.uno/skip-path provider skip_path_regex
|
||||
|
||||
Fail closed: the Traefik Ingress is applied last and only after the Authentik
|
||||
side reconciled, and is removed when that fails (e.g. the named group is gone),
|
||||
so there is never a route to an unguarded backend.
|
||||
Fail closed: until the provider exists, or after it is removed (e.g. the named
|
||||
group is gone), the embedded outpost has no provider for the host and rejects
|
||||
the request; Traefik answers 500 when the outpost is unreachable.
|
||||
|
||||
Ownership: Kubernetes objects carry app.kubernetes.io/managed-by; Authentik
|
||||
applications carry meta_publisher. Anything without the marker is never touched.
|
||||
@@ -48,10 +40,8 @@ LOG = logging.getLogger("authentik-gate-sync")
|
||||
|
||||
AK_URL = os.environ.get("AK_URL", "http://authentik-server.authentik.svc.cluster.local").rstrip("/")
|
||||
AK_TOKEN_FILE = os.environ.get("AK_TOKEN_FILE", "/var/run/secrets/authentik-gate-sync/token")
|
||||
INGRESS_CLASS = os.environ.get("INGRESS_CLASS", "authentik-gate")
|
||||
TARGET_CLASS = os.environ.get("TARGET_INGRESS_CLASS", "traefik")
|
||||
OUTPOST_NS = os.environ.get("OUTPOST_NAMESPACE", "authentik")
|
||||
SERVICE_CONNECTION = os.environ.get("SERVICE_CONNECTION", "Local Kubernetes Cluster")
|
||||
GATE_MIDDLEWARE = os.environ.get("GATE_MIDDLEWARE", "authentik-gate@kubernetescrd")
|
||||
INGRESS_NS = os.environ.get("INGRESS_NAMESPACE", "ingress")
|
||||
DEFAULT_AUTHZ_FLOW = os.environ.get("DEFAULT_AUTHORIZATION_FLOW", "default-provider-authorization-implicit-consent")
|
||||
INVALIDATION_FLOW = os.environ.get("INVALIDATION_FLOW", "default-provider-invalidation-flow")
|
||||
COOKIE_DOMAIN = os.environ.get("COOKIE_DOMAIN", "renner.uno")
|
||||
@@ -63,14 +53,9 @@ ANN = "auth.renner.uno/"
|
||||
MANAGER = "authentik-gate-sync"
|
||||
MANAGED_BY = {"app.kubernetes.io/managed-by": MANAGER}
|
||||
GATE_LABEL = "auth.renner.uno/gate"
|
||||
OUTPOST_PORT = 9000
|
||||
|
||||
# Never copied from the source onto the generated Ingress: cert-manager would
|
||||
# issue a second Certificate for the same secret, Flux would treat it as its own,
|
||||
# and the gate annotations mean nothing to Traefik.
|
||||
DROP_LABEL_PREFIXES = ("kustomize.toolkit.fluxcd.io/", "app.kubernetes.io/managed-by")
|
||||
DROP_ANNOTATION_PREFIXES = (ANN, "cert-manager.io/", "acme.cert-manager.io/",
|
||||
"kubectl.kubernetes.io/last-applied-configuration")
|
||||
EMBEDDED_OUTPOST = "goauthentik.io/outposts/embedded"
|
||||
TRAEFIK = {"k8s:io.kubernetes.pod.namespace": INGRESS_NS, "app.kubernetes.io/name": "traefik"}
|
||||
MIDDLEWARES_ANN = "traefik.ingress.kubernetes.io/router.middlewares"
|
||||
|
||||
K8S_API = "https://kubernetes.default.svc"
|
||||
K8S_TOKEN_FILE = "/var/run/secrets/kubernetes.io/serviceaccount/token"
|
||||
@@ -114,7 +99,7 @@ def http(method, url, body=None, headers=None, cafile=None, content_type="applic
|
||||
|
||||
def gate_name(ing):
|
||||
"""<ns>-<ingress>, truncated, plus a hash of both: unambiguous (a-b/c vs a/b-c)
|
||||
and short enough for label values and ak-outpost-<name> (63)."""
|
||||
and short enough for label values (63)."""
|
||||
ns, name = ing["metadata"]["namespace"], ing["metadata"]["name"]
|
||||
digest = hashlib.sha256(f"{ns}/{name}".encode()).hexdigest()[:6]
|
||||
return f"{ns}-{name}"[:45].rstrip("-") + "-" + digest
|
||||
@@ -126,6 +111,24 @@ def group_expression(group):
|
||||
return f"return ak_is_group_member(request.user, name={group!r})"
|
||||
|
||||
|
||||
def is_gated(ing):
|
||||
chain = ((ing.get("metadata") or {}).get("annotations") or {}).get(MIDDLEWARES_ANN, "")
|
||||
return GATE_MIDDLEWARE in (m.strip() for m in chain.split(","))
|
||||
|
||||
|
||||
def shared_hosts(sources):
|
||||
"""Hosts named by more than one gated Ingress. The outpost finds the provider
|
||||
by host, so such a host would get one gate for several Ingresses."""
|
||||
seen, shared = set(), set()
|
||||
for ing in sources:
|
||||
for r in ing.get("spec", {}).get("rules") or []:
|
||||
host = r.get("host")
|
||||
if host in seen:
|
||||
shared.add(host)
|
||||
seen.add(host)
|
||||
return shared
|
||||
|
||||
|
||||
def gate_spec(ing):
|
||||
"""Translate a source Ingress into the gate it asks for. Raises GateError."""
|
||||
meta = ing["metadata"]
|
||||
@@ -174,63 +177,15 @@ def gate_labels(gate):
|
||||
return {**MANAGED_BY, GATE_LABEL: gate["name"]}
|
||||
|
||||
|
||||
def outpost_service(gate):
|
||||
return f"ak-outpost-{gate['name']}"
|
||||
|
||||
|
||||
def external_name_service(gate):
|
||||
return {"apiVersion": "v1", "kind": "Service",
|
||||
"metadata": {"name": f"{gate['ingress']}-gate", "namespace": gate["namespace"],
|
||||
"labels": gate_labels(gate), "ownerReferences": owner_ref(gate)},
|
||||
"spec": {"type": "ExternalName",
|
||||
"externalName": f"{outpost_service(gate)}.{OUTPOST_NS}.svc.cluster.local",
|
||||
"ports": [{"name": "http", "port": OUTPOST_PORT, "targetPort": OUTPOST_PORT}]}}
|
||||
|
||||
|
||||
def route_ingress(ing, gate):
|
||||
"""The Traefik Ingress: the source with its backend swapped for the gate."""
|
||||
meta = ing["metadata"]
|
||||
labels = {k: v for k, v in (meta.get("labels") or {}).items() if not k.startswith(DROP_LABEL_PREFIXES)}
|
||||
annotations = {k: v for k, v in (meta.get("annotations") or {}).items()
|
||||
if not k.startswith(DROP_ANNOTATION_PREFIXES)}
|
||||
backend = {"service": {"name": f"{gate['ingress']}-gate", "port": {"number": OUTPOST_PORT}}}
|
||||
rules = []
|
||||
for r in ing["spec"]["rules"]:
|
||||
paths = [{"path": p.get("path", "/"), "pathType": p.get("pathType", "Prefix"), "backend": backend}
|
||||
for p in r["http"]["paths"]]
|
||||
rules.append({"host": r["host"], "http": {"paths": paths}})
|
||||
spec = {"ingressClassName": TARGET_CLASS, "rules": rules}
|
||||
if ing["spec"].get("tls"):
|
||||
spec["tls"] = ing["spec"]["tls"]
|
||||
return {"apiVersion": "networking.k8s.io/v1", "kind": "Ingress",
|
||||
"metadata": {"name": f"{gate['ingress']}-gate", "namespace": gate["namespace"],
|
||||
"labels": {**labels, **gate_labels(gate)}, "annotations": annotations,
|
||||
"ownerReferences": owner_ref(gate)},
|
||||
"spec": spec}
|
||||
|
||||
|
||||
def outpost_selector(gate):
|
||||
return {"k8s:io.kubernetes.pod.namespace": OUTPOST_NS, "goauthentik.io/outpost-name": gate["name"]}
|
||||
|
||||
|
||||
def backend_ingress_cnp(gate, pod_selector, target_port):
|
||||
return {"apiVersion": "cilium.io/v2", "kind": "CiliumNetworkPolicy",
|
||||
"metadata": {"name": f"{gate['ingress']}-gate", "namespace": gate["namespace"],
|
||||
"labels": gate_labels(gate), "ownerReferences": owner_ref(gate)},
|
||||
"spec": {"endpointSelector": {"matchLabels": pod_selector},
|
||||
"ingress": [{"fromEndpoints": [{"matchLabels": outpost_selector(gate)}],
|
||||
"ingress": [{"fromEndpoints": [{"matchLabels": TRAEFIK}],
|
||||
"toPorts": [{"ports": [{"port": str(target_port), "protocol": "TCP"}]}]}]}}
|
||||
|
||||
|
||||
def outpost_egress_cnp(gate, pod_selector, target_port):
|
||||
peer = {"k8s:io.kubernetes.pod.namespace": gate["namespace"], **pod_selector}
|
||||
return {"apiVersion": "cilium.io/v2", "kind": "CiliumNetworkPolicy",
|
||||
"metadata": {"name": f"gate-{gate['name']}", "namespace": OUTPOST_NS, "labels": gate_labels(gate)},
|
||||
"spec": {"endpointSelector": {"matchLabels": {"goauthentik.io/outpost-name": gate["name"]}},
|
||||
"egress": [{"toEndpoints": [{"matchLabels": peer}],
|
||||
"toPorts": [{"ports": [{"port": str(target_port), "protocol": "TCP"}]}]}]}}
|
||||
|
||||
|
||||
def resolve_backend(gate, service):
|
||||
"""(service port number, pod selector, target port) for the gate's backend.
|
||||
A named targetPort stays a name: Cilium resolves named ports against the
|
||||
@@ -254,34 +209,20 @@ def resolve_backend(gate, service):
|
||||
return sp["port"], selector, target
|
||||
|
||||
|
||||
def outpost_config():
|
||||
return {
|
||||
"log_level": "info",
|
||||
"authentik_host": AK_URL,
|
||||
"authentik_host_insecure": False,
|
||||
"authentik_host_browser": AK_BROWSER_URL,
|
||||
"refresh_interval": "minutes=5",
|
||||
"container_image": None,
|
||||
"object_naming_template": "ak-outpost-%(name)s",
|
||||
"kubernetes_namespace": OUTPOST_NS,
|
||||
"kubernetes_replicas": 1,
|
||||
"kubernetes_service_type": "ClusterIP",
|
||||
"kubernetes_disabled_components": ["ingress"],
|
||||
"kubernetes_image_pull_secrets": [],
|
||||
"kubernetes_ingress_annotations": {},
|
||||
"kubernetes_ingress_class_name": None,
|
||||
"kubernetes_ingress_secret_name": "authentik-outpost-tls",
|
||||
"kubernetes_json_patches": None,
|
||||
}
|
||||
def embedded_config(config):
|
||||
"""The embedded outpost's config with the host the gates depend on. The
|
||||
embedded outpost builds the sign-in redirect from authentik_host, so it is
|
||||
the public URL, which is also Authentik's default for it."""
|
||||
return {**(config or {}), "authentik_host": AK_BROWSER_URL, "authentik_host_insecure": False,
|
||||
"authentik_host_browser": AK_BROWSER_URL}
|
||||
|
||||
|
||||
def provider_body(gate, svc_port, flows):
|
||||
def provider_body(gate, flows):
|
||||
return {
|
||||
"name": gate["name"],
|
||||
"mode": "proxy",
|
||||
"mode": "forward_single",
|
||||
"external_host": f"{gate['scheme']}://{gate['host']}",
|
||||
"internal_host": f"http://{gate['service']}.{gate['namespace']}.svc.cluster.local:{svc_port}",
|
||||
"internal_host_ssl_validation": False,
|
||||
"internal_host": "",
|
||||
"cookie_domain": COOKIE_DOMAIN,
|
||||
"access_token_validity": "hours=24",
|
||||
"refresh_token_validity": "days=30",
|
||||
@@ -293,18 +234,6 @@ def provider_body(gate, svc_port, flows):
|
||||
}
|
||||
|
||||
|
||||
def lb_ingress(obj):
|
||||
return ((obj or {}).get("status") or {}).get("loadBalancer", {}).get("ingress") or []
|
||||
|
||||
|
||||
def status_patch(source, addresses):
|
||||
"""Merge patch publishing `addresses` as the source Ingress's load-balancer
|
||||
status, as an ingress controller does; None when it already matches."""
|
||||
if lb_ingress(source) == addresses:
|
||||
return None
|
||||
return {"status": {"loadBalancer": {"ingress": addresses or None}}}
|
||||
|
||||
|
||||
def drift(current, desired):
|
||||
return {k: v for k, v in desired.items() if current.get(k) != v}
|
||||
|
||||
@@ -342,23 +271,9 @@ class K8s:
|
||||
if e.code != 404:
|
||||
raise
|
||||
|
||||
def patch_status(self, ns, name, patch):
|
||||
path = f"/apis/networking.k8s.io/v1/namespaces/{ns}/ingresses/{name}/status"
|
||||
return http("PATCH", K8S_API + path, patch, headers=self._h(), cafile=K8S_CA_FILE,
|
||||
content_type="application/merge-patch+json")
|
||||
|
||||
def delete_managed(self, obj):
|
||||
try:
|
||||
live = self.get(object_path(obj))
|
||||
except ApiError as e:
|
||||
if e.code == 404:
|
||||
return
|
||||
raise
|
||||
if (live["metadata"].get("labels") or {}).get("app.kubernetes.io/managed-by") == MANAGER:
|
||||
self.delete(obj)
|
||||
LOG.info("deleted %s %s/%s", obj["kind"], obj["metadata"]["namespace"], obj["metadata"]["name"])
|
||||
|
||||
|
||||
# Swept by label: any object of these kinds marked as this controller's that no
|
||||
# gate wants is deleted. It creates only CNPs; Ingresses and Services carrying
|
||||
# the label are routes a gate must not have besides its own Ingress.
|
||||
COLLECTIONS = {
|
||||
"Ingress": "/apis/networking.k8s.io/v1/namespaces/{ns}/ingresses",
|
||||
"Service": "/api/v1/namespaces/{ns}/services",
|
||||
@@ -425,7 +340,24 @@ def get_application(ak, slug):
|
||||
return ak.get(f"core/applications/{slug}/")
|
||||
|
||||
|
||||
def ensure_gate(ak, gate, svc_port, flows, connection):
|
||||
def embedded_outpost(ak):
|
||||
# Matched again here: a filter the server ignored must not select another outpost.
|
||||
found = [o for o in ak.list("outposts/instances/", managed__iexact=EMBEDDED_OUTPOST)
|
||||
if o.get("managed") == EMBEDDED_OUTPOST]
|
||||
if len(found) != 1:
|
||||
raise ApiError(f"expected one embedded outpost, found {len(found)}")
|
||||
return found[0]
|
||||
|
||||
|
||||
def ensure_embedded_config(ak):
|
||||
outpost = embedded_outpost(ak)
|
||||
want = embedded_config(outpost.get("config"))
|
||||
if outpost.get("config") != want:
|
||||
ak.req("PATCH", f"outposts/instances/{outpost['pk']}/", {"config": want})
|
||||
LOG.info("embedded outpost: updated config")
|
||||
|
||||
|
||||
def ensure_gate(ak, gate, flows):
|
||||
name = gate["name"]
|
||||
if gate["group"] and ak.one("core/groups/", name=gate["group"]) is None:
|
||||
raise GateError(f"group {gate['group']!r} not found in Authentik")
|
||||
@@ -434,7 +366,7 @@ def ensure_gate(ak, gate, svc_port, flows, connection):
|
||||
if app is not None and app.get("meta_publisher") != MANAGER:
|
||||
raise GateError(f"application {name} exists and is not managed by {MANAGER}")
|
||||
|
||||
want = provider_body(gate, svc_port, flows)
|
||||
want = provider_body(gate, flows)
|
||||
provider = ak.one("providers/proxy/", name__iexact=name)
|
||||
if provider is None:
|
||||
provider = ak.req("POST", "providers/proxy/", want)
|
||||
@@ -461,17 +393,22 @@ def ensure_gate(ak, gate, svc_port, flows, connection):
|
||||
|
||||
ensure_access(ak, gate, app["pbm_uuid"])
|
||||
|
||||
want_outpost = {"name": name, "type": "proxy", "service_connection": connection,
|
||||
"providers": [provider["pk"]], "config": outpost_config()}
|
||||
outpost = ak.one("outposts/instances/", name__iexact=name)
|
||||
if outpost is None:
|
||||
ak.req("POST", "outposts/instances/", want_outpost)
|
||||
LOG.info("%s: created outpost", name)
|
||||
elif set(outpost.get("providers") or []) - {provider["pk"]}:
|
||||
raise GateError(f"outpost {name} serves providers this controller does not own")
|
||||
elif drift(outpost, want_outpost):
|
||||
ak.req("PATCH", f"outposts/instances/{outpost['pk']}/", drift(outpost, want_outpost))
|
||||
LOG.info("%s: updated outpost %s", name, sorted(drift(outpost, want_outpost)))
|
||||
# Re-read per gate: the providers list is replaced whole.
|
||||
embedded = embedded_outpost(ak)
|
||||
if provider["pk"] not in (embedded.get("providers") or []):
|
||||
ak.req("PATCH", f"outposts/instances/{embedded['pk']}/",
|
||||
{"providers": [*(embedded.get("providers") or []), provider["pk"]]})
|
||||
LOG.info("%s: attached provider to the embedded outpost", name)
|
||||
remove_dedicated_outposts(ak, name, provider["pk"])
|
||||
|
||||
|
||||
def remove_dedicated_outposts(ak, name, provider):
|
||||
"""Outposts named after the gate that serve only its provider: the embedded
|
||||
outpost serves every gate, so Authentik tears these and their pods down."""
|
||||
for o in ak.list("outposts/instances/", name__iexact=name):
|
||||
if o.get("providers") == [provider] and not o.get("managed"):
|
||||
ak.req("DELETE", f"outposts/instances/{o['pk']}/")
|
||||
LOG.info("%s: removed dedicated outpost", name)
|
||||
|
||||
|
||||
def ensure_access(ak, gate, target):
|
||||
@@ -511,15 +448,12 @@ def ensure_access(ak, gate, target):
|
||||
|
||||
|
||||
def remove_gate(ak, app):
|
||||
"""Delete an owned gate. The outpost serving only its provider goes first
|
||||
(Authentik tears its pods down), then the application (bindings cascade; its
|
||||
provider is PROTECTed while referenced), the provider, the policy. Ownership
|
||||
is found through the application, so until it is gone a failed step is
|
||||
retried on the next pass."""
|
||||
"""Delete an owned gate: the application (bindings cascade; its provider is
|
||||
PROTECTed while referenced), then the provider (which leaves the embedded
|
||||
outpost with it), the policy. Ownership is found through the application,
|
||||
so until it is gone a failed step is retried on the next pass."""
|
||||
name, provider = app["slug"], app.get("provider")
|
||||
for o in ak.list("outposts/instances/", name__iexact=name):
|
||||
if o.get("providers") == [provider]:
|
||||
ak.req("DELETE", f"outposts/instances/{o['pk']}/")
|
||||
remove_dedicated_outposts(ak, name, provider)
|
||||
ak.req("DELETE", f"core/applications/{name}/")
|
||||
if provider:
|
||||
ak.req("DELETE", f"providers/proxy/{provider}/")
|
||||
@@ -543,32 +477,15 @@ def owned_applications(ak):
|
||||
|
||||
# --- reconcile --------------------------------------------------------------
|
||||
|
||||
def publish_status(k8s, source, addresses):
|
||||
"""Status is cosmetic for the gate itself: a failure is logged, never fatal."""
|
||||
patch = status_patch(source, addresses)
|
||||
if patch is None:
|
||||
return
|
||||
m = source["metadata"]
|
||||
try:
|
||||
k8s.patch_status(m["namespace"], m["name"], patch)
|
||||
LOG.info("%s/%s: status %s", m["namespace"], m["name"],
|
||||
[a.get("ip") or a.get("hostname") for a in addresses])
|
||||
except Exception as e:
|
||||
LOG.warning("%s/%s: publishing status: %s", m["namespace"], m["name"], e)
|
||||
|
||||
|
||||
def reconcile():
|
||||
k8s = K8s()
|
||||
with open(AK_TOKEN_FILE) as f:
|
||||
ak = Authentik(f.read().strip())
|
||||
|
||||
sources = [i for i in k8s.get("/apis/networking.k8s.io/v1/ingresses").get("items", [])
|
||||
if i.get("spec", {}).get("ingressClassName") == INGRESS_CLASS]
|
||||
sources = [i for i in k8s.get("/apis/networking.k8s.io/v1/ingresses").get("items", []) if is_gated(i)]
|
||||
shared = shared_hosts(sources)
|
||||
flows = {f["slug"]: f["pk"] for f in ak.list("flows/instances/")}
|
||||
connection = ak.one("outposts/service_connections/kubernetes/", name=SERVICE_CONNECTION)
|
||||
if connection is None:
|
||||
raise ApiError(f"Kubernetes service connection {SERVICE_CONNECTION!r} not found")
|
||||
connection = connection["pk"]
|
||||
ensure_embedded_config(ak)
|
||||
|
||||
desired = set() # (kind, ns, name) of every Kubernetes object some gate wants
|
||||
gates = set() # gate names whose Authentik side should exist
|
||||
@@ -578,6 +495,8 @@ def reconcile():
|
||||
ref = f'{ing["metadata"]["namespace"]}/{ing["metadata"]["name"]}'
|
||||
try:
|
||||
gate = gate_spec(ing)
|
||||
if gate["host"] in shared:
|
||||
raise GateError(f"host {gate['host']} is gated by more than one Ingress")
|
||||
for slug in filter(None, (gate["authorization_flow"], gate["login_flow"], INVALIDATION_FLOW)):
|
||||
if slug not in flows:
|
||||
raise GateError(f"flow {slug!r} not found in Authentik")
|
||||
@@ -588,28 +507,18 @@ def reconcile():
|
||||
if e.code == 404:
|
||||
raise GateError(f"backend Service {gate['service']} does not exist") from None
|
||||
raise
|
||||
svc_port, pods, target_port = resolve_backend(gate, service)
|
||||
_, pods, target_port = resolve_backend(gate, service)
|
||||
gates.add(gate["name"])
|
||||
ensure_gate(ak, gate, svc_port, flows, connection)
|
||||
objs = [outpost_egress_cnp(gate, pods, target_port), backend_ingress_cnp(gate, pods, target_port),
|
||||
external_name_service(gate), route_ingress(ing, gate)] # the route goes last
|
||||
for obj in objs:
|
||||
live = k8s.apply(obj)
|
||||
desired.add((obj["kind"], obj["metadata"]["namespace"], obj["metadata"]["name"]))
|
||||
publish_status(k8s, ing, lb_ingress(live)) # the route's address, from Traefik
|
||||
ensure_gate(ak, gate, flows)
|
||||
cnp = backend_ingress_cnp(gate, pods, target_port)
|
||||
k8s.apply(cnp)
|
||||
desired.add((cnp["kind"], cnp["metadata"]["namespace"], cnp["metadata"]["name"]))
|
||||
except GateError as e:
|
||||
# The Ingress cannot be gated as written: its route goes now, the
|
||||
# rest with the sweep below.
|
||||
# The Ingress cannot be gated as written: its provider goes with the
|
||||
# sweep below, after which the outpost rejects the host.
|
||||
LOG.error("%s: %s", ref, e)
|
||||
failed += 1
|
||||
gates.discard(gate_name(ing))
|
||||
route = {"kind": "Ingress", "metadata": {"namespace": ing["metadata"]["namespace"],
|
||||
"name": f'{ing["metadata"]["name"]}-gate'}}
|
||||
try:
|
||||
k8s.delete_managed(route)
|
||||
except Exception as e: # the sweep retries
|
||||
LOG.error("%s: removing route: %s", ref, e)
|
||||
publish_status(k8s, ing, [])
|
||||
except Exception as e:
|
||||
# Transient: leave this gate exactly as the last good pass left it.
|
||||
LOG.error("%s: %s", ref, e)
|
||||
|
||||
@@ -11,11 +11,12 @@ LLAMA = {
|
||||
"cert-manager.io/cluster-issuer": "letsencrypt-cluster",
|
||||
"auth.renner.uno/login-flow": "sso-authentication",
|
||||
"auth.renner.uno/skip-path": r"^/(manifest\.webmanifest|sw\.js)$",
|
||||
"traefik.ingress.kubernetes.io/router.middlewares": "ingress-foo@kubernetescrd",
|
||||
"traefik.ingress.kubernetes.io/router.middlewares":
|
||||
"authentik-gate@kubernetescrd, ingress-foo@kubernetescrd",
|
||||
},
|
||||
},
|
||||
"spec": {
|
||||
"ingressClassName": "authentik-gate",
|
||||
"ingressClassName": "traefik",
|
||||
"tls": [{"hosts": ["llm.renner.uno"], "secretName": "llama-server-tls"}],
|
||||
"rules": [{"host": "llm.renner.uno", "http": {"paths": [
|
||||
{"path": "/", "pathType": "Prefix",
|
||||
@@ -41,7 +42,7 @@ class Names(unittest.TestCase):
|
||||
|
||||
def test_bounded(self):
|
||||
n = c.gate_name(ing("n" * 63, "i" * 253))
|
||||
self.assertLessEqual(len(c.outpost_service({"name": n})), 63)
|
||||
self.assertLessEqual(len(n), 63)
|
||||
self.assertNotIn("--", n)
|
||||
|
||||
def test_group_expression_is_a_literal(self):
|
||||
@@ -90,6 +91,22 @@ class GateSpec(unittest.TestCase):
|
||||
with self.assertRaises(c.GateError):
|
||||
c.gate_spec(ing)
|
||||
|
||||
def test_shared_hosts(self):
|
||||
other = copy.deepcopy(LLAMA)
|
||||
other["metadata"]["name"] = "llama-admin"
|
||||
self.assertEqual(c.shared_hosts([LLAMA, other]), {"llm.renner.uno"})
|
||||
other["spec"]["rules"][0]["host"] = "admin.renner.uno"
|
||||
self.assertEqual(c.shared_hosts([LLAMA, other]), set())
|
||||
|
||||
def test_gated_by_middleware_reference(self):
|
||||
self.assertTrue(c.is_gated(LLAMA))
|
||||
ing = copy.deepcopy(LLAMA)
|
||||
ing["metadata"]["annotations"]["traefik.ingress.kubernetes.io/router.middlewares"] = \
|
||||
"ingress-foo@kubernetescrd,authentik-gate-other@kubernetescrd"
|
||||
self.assertFalse(c.is_gated(ing))
|
||||
del ing["metadata"]["annotations"]
|
||||
self.assertFalse(c.is_gated(ing))
|
||||
|
||||
|
||||
class Backend(unittest.TestCase):
|
||||
def test_named_target_port_stays_named(self):
|
||||
@@ -126,65 +143,34 @@ class Objects(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.g = c.gate_spec(LLAMA)
|
||||
|
||||
def test_route_ingress(self):
|
||||
r = c.route_ingress(LLAMA, self.g)
|
||||
self.assertEqual(r["metadata"]["name"], "llama-server-gate")
|
||||
self.assertEqual(r["spec"]["ingressClassName"], "traefik")
|
||||
self.assertEqual(r["spec"]["tls"], LLAMA["spec"]["tls"])
|
||||
backend = r["spec"]["rules"][0]["http"]["paths"][0]["backend"]["service"]
|
||||
self.assertEqual(backend, {"name": "llama-server-gate", "port": {"number": 9000}})
|
||||
labels, ann = r["metadata"]["labels"], r["metadata"]["annotations"]
|
||||
self.assertEqual(labels["dns.renner.uno/public"], "true")
|
||||
self.assertNotIn("kustomize.toolkit.fluxcd.io/name", labels)
|
||||
self.assertEqual(labels["app.kubernetes.io/managed-by"], c.MANAGER)
|
||||
self.assertEqual(ann, {"traefik.ingress.kubernetes.io/router.middlewares": "ingress-foo@kubernetescrd"})
|
||||
self.assertEqual(r["metadata"]["ownerReferences"][0]["uid"], "u-1")
|
||||
|
||||
def test_external_name(self):
|
||||
s = c.external_name_service(self.g)
|
||||
self.assertEqual(s["spec"]["externalName"], f"ak-outpost-{self.g['name']}.authentik.svc.cluster.local")
|
||||
|
||||
def test_cnps(self):
|
||||
def test_backend_admits_traefik_only(self):
|
||||
pods = {"app.kubernetes.io/name": "llama-server"}
|
||||
e = c.outpost_egress_cnp(self.g, pods, 8080)
|
||||
self.assertEqual(e["metadata"]["namespace"], "authentik")
|
||||
self.assertEqual(e["spec"]["endpointSelector"]["matchLabels"],
|
||||
{"goauthentik.io/outpost-name": self.g["name"]})
|
||||
self.assertEqual(e["spec"]["egress"][0]["toEndpoints"][0]["matchLabels"],
|
||||
{"k8s:io.kubernetes.pod.namespace": "ai", "app.kubernetes.io/name": "llama-server"})
|
||||
i = c.backend_ingress_cnp(self.g, pods, 8080)
|
||||
self.assertEqual(i["metadata"]["namespace"], "ai")
|
||||
self.assertEqual(i["spec"]["ingress"][0]["fromEndpoints"][0]["matchLabels"],
|
||||
{"k8s:io.kubernetes.pod.namespace": "authentik",
|
||||
"goauthentik.io/outpost-name": self.g["name"]})
|
||||
self.assertEqual(i["spec"]["ingress"][0]["fromEndpoints"],
|
||||
[{"matchLabels": {"k8s:io.kubernetes.pod.namespace": "ingress",
|
||||
"app.kubernetes.io/name": "traefik"}}])
|
||||
self.assertEqual(i["spec"]["ingress"][0]["toPorts"][0]["ports"][0]["port"], "8080")
|
||||
|
||||
def test_provider_body(self):
|
||||
flows = {c.DEFAULT_AUTHZ_FLOW: "az", "sso-authentication": "au",
|
||||
c.INVALIDATION_FLOW: "inv"}
|
||||
p = c.provider_body(self.g, 8080, flows)
|
||||
p = c.provider_body(self.g, flows)
|
||||
self.assertEqual(p["mode"], "forward_single")
|
||||
self.assertEqual(p["external_host"], "https://llm.renner.uno")
|
||||
self.assertEqual(p["internal_host"], "http://llama-server.ai.svc.cluster.local:8080")
|
||||
self.assertEqual(p["internal_host"], "")
|
||||
self.assertEqual((p["authorization_flow"], p["authentication_flow"], p["invalidation_flow"]),
|
||||
("az", "au", "inv"))
|
||||
self.assertEqual(p["skip_path_regex"], r"^/(manifest\.webmanifest|sw\.js)$")
|
||||
|
||||
def test_status_mirrors_route_address(self):
|
||||
addrs = [{"ip": "10.2.99.86"}, {"ip": "fd99::86"}]
|
||||
route = {"status": {"loadBalancer": {"ingress": addrs}}}
|
||||
self.assertEqual(c.status_patch(LLAMA, c.lb_ingress(route)),
|
||||
{"status": {"loadBalancer": {"ingress": addrs}}})
|
||||
synced = dict(LLAMA, status={"loadBalancer": {"ingress": addrs}})
|
||||
self.assertIsNone(c.status_patch(synced, addrs))
|
||||
|
||||
def test_status_cleared_without_route(self):
|
||||
stale = dict(LLAMA, status={"loadBalancer": {"ingress": [{"ip": "10.2.99.86"}]}})
|
||||
self.assertEqual(c.status_patch(stale, []), {"status": {"loadBalancer": {"ingress": None}}})
|
||||
self.assertIsNone(c.status_patch(LLAMA, []))
|
||||
|
||||
def test_drift(self):
|
||||
self.assertEqual(c.drift({"a": 1, "b": 2}, {"a": 1, "b": 3}), {"b": 3})
|
||||
|
||||
def test_embedded_config_keeps_other_keys(self):
|
||||
cfg = c.embedded_config({"log_level": "debug", "authentik_host": c.AK_URL})
|
||||
self.assertEqual(cfg, {"log_level": "debug", "authentik_host": c.AK_BROWSER_URL,
|
||||
"authentik_host_insecure": False, "authentik_host_browser": c.AK_BROWSER_URL})
|
||||
|
||||
|
||||
class FakeAuthentik:
|
||||
"""In-memory stand-in for the endpoints the controller uses; records calls."""
|
||||
@@ -267,20 +253,69 @@ class Reconcile(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.ak = FakeAuthentik()
|
||||
self.g = c.gate_spec(LLAMA)
|
||||
self.embedded = self.ak.add("outposts/instances/", {
|
||||
"name": "authentik Embedded Outpost", "managed": c.EMBEDDED_OUTPOST,
|
||||
"providers": [], "config": {"log_level": "info"}})
|
||||
|
||||
def gate(self, group=None):
|
||||
g = dict(self.g, group=group)
|
||||
c.ensure_gate(self.ak, g, 8080, FLOWS, "conn")
|
||||
c.ensure_gate(self.ak, g, FLOWS)
|
||||
return g
|
||||
|
||||
def embedded_providers(self):
|
||||
return self.ak.get(f"outposts/instances/{self.embedded['pk']}/")["providers"]
|
||||
|
||||
def test_creates_owned_gate(self):
|
||||
self.gate()
|
||||
app = self.ak.get(f"core/applications/{self.g['name']}/")
|
||||
self.assertEqual(app["meta_publisher"], c.MANAGER)
|
||||
outpost = self.ak.one("outposts/instances/", name__iexact=self.g["name"])
|
||||
self.assertEqual(outpost["providers"], [app["provider"]])
|
||||
self.assertEqual(self.embedded_providers(), [app["provider"]])
|
||||
self.assertEqual(self.ak.list("outposts/instances/", name__iexact=self.g["name"]), [])
|
||||
self.assertEqual(self.ak.list("policies/bindings/"), [])
|
||||
|
||||
def test_keeps_other_providers_on_embedded_outpost(self):
|
||||
self.ak.db["outposts/instances/"][self.embedded["pk"]]["providers"] = [999]
|
||||
self.gate()
|
||||
app = self.ak.get(f"core/applications/{self.g['name']}/")
|
||||
self.assertEqual(self.embedded_providers(), [999, app["provider"]])
|
||||
|
||||
def test_removes_dedicated_outpost(self):
|
||||
self.gate()
|
||||
app = self.ak.get(f"core/applications/{self.g['name']}/")
|
||||
self.ak.add("outposts/instances/", {"name": self.g["name"], "providers": [app["provider"]]})
|
||||
shared = self.ak.add("outposts/instances/", {"name": self.g["name"].upper(),
|
||||
"providers": [app["provider"], 999]})
|
||||
self.gate()
|
||||
self.assertEqual([o["pk"] for o in self.ak.list("outposts/instances/", name__iexact=self.g["name"])],
|
||||
[shared["pk"]])
|
||||
|
||||
def test_embedded_lookup_ignores_unfiltered_results(self):
|
||||
ldap = self.ak.add("outposts/instances/", {"name": "LDAP Outpost", "managed": None, "providers": [7]})
|
||||
unfiltered = self.ak.list
|
||||
self.ak.list = lambda path, **q: unfiltered(path) # a server that ignores the filter
|
||||
self.assertEqual(c.embedded_outpost(self.ak)["pk"], self.embedded["pk"])
|
||||
del self.ak.db["outposts/instances/"][self.embedded["pk"]]
|
||||
with self.assertRaises(c.ApiError):
|
||||
c.embedded_outpost(self.ak)
|
||||
self.assertEqual(self.ak.get(f"outposts/instances/{ldap['pk']}/")["providers"], [7])
|
||||
|
||||
def test_embedded_config(self):
|
||||
c.ensure_embedded_config(self.ak)
|
||||
cfg = self.ak.get(f"outposts/instances/{self.embedded['pk']}/")["config"]
|
||||
self.assertEqual((cfg["log_level"], cfg["authentik_host"], cfg["authentik_host_browser"]),
|
||||
("info", c.AK_BROWSER_URL, c.AK_BROWSER_URL))
|
||||
before = len(self.ak.calls)
|
||||
c.ensure_embedded_config(self.ak)
|
||||
self.assertEqual(self.ak.calls[before:], [])
|
||||
|
||||
def test_provider_moves_from_proxy_mode(self):
|
||||
self.ak.add("providers/proxy/", {"name": self.g["name"], "mode": "proxy",
|
||||
"internal_host": "http://llama-server.ai.svc.cluster.local:8080",
|
||||
"assigned_application_slug": None})
|
||||
self.gate()
|
||||
provider = self.ak.one("providers/proxy/", name__iexact=self.g["name"])
|
||||
self.assertEqual((provider["mode"], provider["internal_host"]), ("forward_single", ""))
|
||||
|
||||
def test_second_pass_is_a_noop(self):
|
||||
self.gate()
|
||||
before = len(self.ak.calls)
|
||||
@@ -329,15 +364,15 @@ class Reconcile(unittest.TestCase):
|
||||
self.assertIsNone(self.ak.one("policies/expression/", name=self.g["name"]))
|
||||
|
||||
def test_remove_gate_and_ownership_scan(self):
|
||||
self.ak.add("providers/proxy/", {"name": "foreign", "assigned_application_slug": "foreign"})
|
||||
self.ak.add("core/applications/", {"slug": "foreign", "meta_publisher": "", "provider": 1})
|
||||
foreign = self.ak.add("providers/proxy/", {"name": "foreign", "assigned_application_slug": "foreign"})
|
||||
self.ak.add("core/applications/", {"slug": "foreign", "meta_publisher": "", "provider": foreign["pk"]})
|
||||
self.gate()
|
||||
owned = list(c.owned_applications(self.ak))
|
||||
self.assertEqual([a["slug"] for a in owned], [self.g["name"]])
|
||||
c.remove_gate(self.ak, owned[0])
|
||||
self.assertIsNone(self.ak.get(f"core/applications/{self.g['name']}/"))
|
||||
self.assertEqual([p["name"] for p in self.ak.list("providers/proxy/")], ["foreign"])
|
||||
self.assertEqual(self.ak.list("outposts/instances/"), [])
|
||||
self.assertEqual([o["pk"] for o in self.ak.list("outposts/instances/")], [self.embedded["pk"]])
|
||||
|
||||
def test_adopts_provider_orphaned_by_interrupted_teardown(self):
|
||||
self.gate()
|
||||
|
||||
Binary file not shown.
@@ -1,10 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
"""netbird-service-sync: reconcile NetBird reverse-proxy services from Ingresses.
|
||||
|
||||
Source of truth: every Ingress carrying one of the public labels.
|
||||
dns.renner.uno/public also takes the host out of the LAN DNS (external-dns-unifi
|
||||
skips it); netbird.renner.uno/public publishes on the proxy only and leaves the
|
||||
LAN record in place.
|
||||
Source of truth: every Ingress labeled netbird.renner.uno/public=true. DNS is
|
||||
independent of it: dns.renner.uno/internal (UDM) and dns.renner.uno/public
|
||||
(Cloudflare) are read by the two external-dns instances.
|
||||
For each host on such an Ingress the NetBird management gets one reverse-proxy
|
||||
service in TLS-passthrough mode on :443, targeting Traefik's ClusterIP through a
|
||||
subnet resource that covers the cluster's service CIDR. SNI and Host reach
|
||||
@@ -45,7 +44,7 @@ NETWORK_NAME = os.environ.get("NETWORK_NAME", "k8s public ingress")
|
||||
ROUTER_GROUP = os.environ.get("ROUTER_GROUP_NAME", "k8s-ingress-router")
|
||||
SOURCE_GROUP = os.environ.get("SOURCE_GROUP_NAME", "All")
|
||||
TRAEFIK_NS, TRAEFIK_SVC = os.environ.get("TRAEFIK_SERVICE", "ingress/traefik").split("/", 1)
|
||||
PUBLIC_LABELS = os.environ.get("PUBLIC_LABELS", "dns.renner.uno/public,netbird.renner.uno/public").split(",")
|
||||
PUBLIC_LABELS = os.environ.get("PUBLIC_LABELS", "netbird.renner.uno/public").split(",")
|
||||
LISTEN_PORT = int(os.environ.get("LISTEN_PORT", "443"))
|
||||
INTERVAL = int(os.environ.get("INTERVAL_SECONDS", "60"))
|
||||
HTTP_TIMEOUT = 20
|
||||
|
||||
@@ -70,7 +70,7 @@ spec:
|
||||
mountPath: /ca
|
||||
containers:
|
||||
- name: audiobookshelf
|
||||
image: ghcr.io/advplyr/audiobookshelf:2.37.1 # {"$imagepolicy": "flux-system:audiobookshelf"}
|
||||
image: ghcr.io/advplyr/audiobookshelf:2.37.2 # {"$imagepolicy": "flux-system:audiobookshelf"}
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 80
|
||||
|
||||
@@ -4,9 +4,10 @@ metadata:
|
||||
name: audiobookshelf
|
||||
namespace: audiobookshelf
|
||||
labels:
|
||||
# Registered publicly (Cloudflare wildcard -> NetBird proxy); the UDM
|
||||
# external-dns instance skips it, LAN reaches it via the hairpin NAT.
|
||||
# Registered publicly (explicit CNAME -> NetBird proxy). No
|
||||
# dns.renner.uno/internal label: external-dns-unifi writes no UDM record.
|
||||
dns.renner.uno/public: "true"
|
||||
netbird.renner.uno/public: "true"
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: letsencrypt-cluster
|
||||
spec:
|
||||
|
||||
@@ -23,7 +23,7 @@ spec:
|
||||
retryInterval: 60
|
||||
maxRetries: 1
|
||||
dns:
|
||||
# cluster services have no own record; they resolve through the *.renner.uno wildcard
|
||||
# public CNAME to the NetBird proxy, created by external-dns (dns.renner.uno/public)
|
||||
hostname: audiobooks.renner.uno
|
||||
resolveType: CNAME
|
||||
resolveServer: "2606:4700:4700::1111,1.1.1.1"
|
||||
|
||||
@@ -374,16 +374,10 @@ data:
|
||||
name: lidarr-gate
|
||||
state: absent
|
||||
|
||||
- model: authentik_outposts.outpost
|
||||
identifiers:
|
||||
name: authentik Embedded Outpost
|
||||
state: present
|
||||
attrs:
|
||||
type: proxy
|
||||
service_connection: !KeyOf k8s-conn
|
||||
# No providers attached — each gate outpost serves its own
|
||||
# /outpost.goauthentik.io/* path on the app host.
|
||||
providers: []
|
||||
# The embedded outpost is not declared here: authentik-gate-sync owns its
|
||||
# providers list (every gate) and the hosts in its config, and a
|
||||
# blueprint entry must carry `providers`, which would detach the gates
|
||||
# on every apply.
|
||||
|
||||
# Shared LDAPS cert for the LDAP Outpost. Authentik's data model
|
||||
# owns the cert per-LDAPProvider (no outpost-level cert field), so
|
||||
@@ -1040,9 +1034,19 @@ data:
|
||||
negate: false
|
||||
failure_result: false
|
||||
|
||||
# wiki.renner.uno signs in via OIDC application `wiki`; only this group may sign in.
|
||||
# Members are managed in Authentik.
|
||||
- id: wiki-readers-group
|
||||
model: authentik_core.group
|
||||
identifiers:
|
||||
name: Wiki Readers
|
||||
state: present
|
||||
attrs:
|
||||
is_superuser: false
|
||||
|
||||
# Wiki (apps/wiki): its own OIDC login. Public client + PKCE; RS256
|
||||
# so the service verifies the ID token against the JWKS. No policy
|
||||
# binding: every Authentik user may sign in.
|
||||
# so the service verifies the ID token against the JWKS. Only the
|
||||
# Wiki Readers group passes.
|
||||
- id: wiki-provider
|
||||
model: authentik_providers_oauth2.oauth2provider
|
||||
identifiers:
|
||||
@@ -1078,6 +1082,17 @@ data:
|
||||
meta_launch_url: https://wiki.renner.uno
|
||||
meta_description: "Homelab wiki"
|
||||
|
||||
- model: authentik_policies.policybinding
|
||||
identifiers:
|
||||
target: !Find [authentik_core.application, [slug, wiki]]
|
||||
group: !KeyOf wiki-readers-group
|
||||
order: 0
|
||||
state: present
|
||||
attrs:
|
||||
enabled: true
|
||||
negate: false
|
||||
failure_result: false
|
||||
|
||||
# OpenProject, decommissioned. Application first: Application.provider
|
||||
# is on_delete=PROTECT. Its policy binding cascades with it.
|
||||
- model: authentik_core.application
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
# The authentik-gate ingress class: an Ingress of this class becomes an
|
||||
# Authentik proxy gate (provider, application, outpost, group binding) plus the
|
||||
# Traefik Ingress, ExternalName Service and CiliumNetworkPolicies in front of
|
||||
# its backend. Traefik ignores the class (it only serves classes naming
|
||||
# traefik.io/ingress-controller). Controller: ci/images/authentik-gate-sync.
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: IngressClass
|
||||
metadata:
|
||||
name: authentik-gate
|
||||
spec:
|
||||
controller: renner.uno/authentik-gate
|
||||
---
|
||||
# authentik-gate-sync: for every Ingress that names the gate Middleware
|
||||
# (gate.yaml) it builds the Authentik provider (on the embedded outpost),
|
||||
# application and group binding from the Ingress's auth.renner.uno/*
|
||||
# annotations, and a CiliumNetworkPolicy admitting Traefik to its backend.
|
||||
# Controller: ci/images/authentik-gate-sync.
|
||||
#
|
||||
# API token of the authentik-gate-sync service account. Generated once; the
|
||||
# blueprint (gate-sync.yaml key in blueprints-configmap.yaml) sets it as the
|
||||
# token's key via AUTHENTIK_GATE_SYNC_TOKEN, the controller reads the same Secret.
|
||||
@@ -51,8 +45,9 @@ metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: authentik-gate-sync
|
||||
---
|
||||
# Cluster-wide: gated Ingresses live in any namespace, and so do the route
|
||||
# Ingress, ExternalName Service and backend CNP generated next to them.
|
||||
# Cluster-wide: gated Ingresses live in any namespace, and so do their backend
|
||||
# Services and the CNP generated next to them. Delete on Ingresses and Services
|
||||
# covers objects labelled as this controller's that no gate wants.
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
@@ -60,14 +55,10 @@ metadata:
|
||||
rules:
|
||||
- apiGroups: ["networking.k8s.io"]
|
||||
resources: ["ingresses"]
|
||||
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
|
||||
# The source Ingress's load-balancer status mirrors its generated route.
|
||||
- apiGroups: ["networking.k8s.io"]
|
||||
resources: ["ingresses/status"]
|
||||
verbs: ["get", "patch", "update"]
|
||||
verbs: ["get", "list", "watch", "delete"]
|
||||
- apiGroups: [""]
|
||||
resources: ["services"]
|
||||
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
|
||||
verbs: ["get", "list", "watch", "delete"]
|
||||
- apiGroups: ["cilium.io"]
|
||||
resources: ["ciliumnetworkpolicies"]
|
||||
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
|
||||
@@ -114,7 +105,7 @@ spec:
|
||||
type: RuntimeDefault
|
||||
containers:
|
||||
- name: controller
|
||||
image: gitea.renner.uno/gitea_admin/authentik-gate-sync:2026-10-21-0755 # {"$imagepolicy": "flux-system:authentik-gate-sync"}
|
||||
image: gitea.renner.uno/gitea_admin/authentik-gate-sync:2026-10-25-1458 # {"$imagepolicy": "flux-system:authentik-gate-sync"}
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
readOnlyRootFilesystem: true
|
||||
@@ -125,8 +116,6 @@ spec:
|
||||
value: http://authentik-server.authentik.svc.cluster.local
|
||||
- name: AUTHENTIK_HOST_BROWSER
|
||||
value: https://auth.renner.uno/
|
||||
- name: SERVICE_CONNECTION
|
||||
value: Local Kubernetes Cluster
|
||||
- name: DEFAULT_AUTHORIZATION_FLOW
|
||||
value: default-provider-authorization-implicit-consent
|
||||
- name: INTERVAL_SECONDS
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
# The Authentik gate. An Ingress opts in by naming this Middleware in
|
||||
# traefik.ingress.kubernetes.io/router.middlewares (authentik-gate@kubernetescrd);
|
||||
# its auth.renner.uno/* annotations configure the gate, and authentik-gate-sync
|
||||
# (gate-sync.yaml) builds the Authentik provider and the backend CNP from them.
|
||||
# The embedded outpost picks the provider by Host and rejects hosts it has no
|
||||
# provider for.
|
||||
#
|
||||
# authResponseHeadersRegex makes Traefik delete every client-sent X-authentik-*
|
||||
# header before copying the outpost's, so a gated backend only sees identity
|
||||
# Authentik issued.
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: Middleware
|
||||
metadata:
|
||||
name: gate
|
||||
namespace: authentik
|
||||
spec:
|
||||
forwardAuth:
|
||||
address: http://authentik-server.authentik.svc.cluster.local/outpost.goauthentik.io/auth/traefik
|
||||
authResponseHeadersRegex: "(?i)^x-authentik-"
|
||||
---
|
||||
# The outpost's own paths (sign-in callback, sign-out) on every host. Above the
|
||||
# app routes by priority; on hosts without a gate provider the outpost rejects.
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata:
|
||||
name: gate-outpost
|
||||
namespace: authentik
|
||||
spec:
|
||||
entryPoints:
|
||||
- websecure
|
||||
routes:
|
||||
- kind: Rule
|
||||
match: PathPrefix(`/outpost.goauthentik.io/`)
|
||||
priority: 100000
|
||||
services:
|
||||
- name: authentik-server
|
||||
port: 80
|
||||
tls: {}
|
||||
@@ -161,9 +161,10 @@ spec:
|
||||
enabled: true
|
||||
ingressClassName: traefik
|
||||
labels:
|
||||
# Registered publicly (Cloudflare wildcard -> NetBird proxy); the
|
||||
# UDM external-dns instance skips it, LAN uses the hairpin NAT.
|
||||
# Registered publicly (explicit CNAME -> NetBird proxy). No
|
||||
# dns.renner.uno/internal label: external-dns-unifi writes no UDM record.
|
||||
dns.renner.uno/public: "true"
|
||||
netbird.renner.uno/public: "true"
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: letsencrypt-cluster
|
||||
hosts:
|
||||
|
||||
@@ -23,7 +23,7 @@ spec:
|
||||
retryInterval: 60
|
||||
maxRetries: 1
|
||||
dns:
|
||||
# cluster services have no own record; they resolve through the *.renner.uno wildcard
|
||||
# public CNAME to the NetBird proxy, created by external-dns (dns.renner.uno/public)
|
||||
hostname: auth.renner.uno
|
||||
resolveType: CNAME
|
||||
resolveServer: "2606:4700:4700::1111,1.1.1.1"
|
||||
|
||||
@@ -6,6 +6,7 @@ resources:
|
||||
- blueprints-configmap.yaml
|
||||
- helmrelease.yaml
|
||||
- gate-sync.yaml
|
||||
- gate.yaml
|
||||
- ldap-outpost-cert.yaml
|
||||
- ldap-outpost-lb.yaml
|
||||
- ldap-outpost-cnp.yaml
|
||||
|
||||
@@ -27,6 +27,7 @@ metadata:
|
||||
namespace: authentik
|
||||
labels:
|
||||
lb-pool: bgp
|
||||
dns.renner.uno/internal: "true"
|
||||
annotations:
|
||||
# Pinned to .88 / fd99::88 (next free in the .80-.89 infra range
|
||||
# alongside traefik .86, ha .87, syslog .84, syncthing .85). Pinning
|
||||
|
||||
@@ -30,7 +30,7 @@ spec:
|
||||
type: RuntimeDefault
|
||||
containers:
|
||||
- name: controller
|
||||
image: gitea.renner.uno/gitea_admin/cloudflare-lb-sync:2026-10-22-1904 # {"$imagepolicy": "flux-system:cloudflare-lb-sync"}
|
||||
image: gitea.renner.uno/gitea_admin/cloudflare-lb-sync:2026-10-25-1504 # {"$imagepolicy": "flux-system:cloudflare-lb-sync"}
|
||||
env:
|
||||
- name: CLOUDFLARE_API_TOKEN
|
||||
valueFrom:
|
||||
|
||||
@@ -3,6 +3,8 @@ kind: Ingress
|
||||
metadata:
|
||||
name: evcc
|
||||
namespace: evcc
|
||||
labels:
|
||||
dns.renner.uno/internal: "true"
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: letsencrypt-cluster
|
||||
spec:
|
||||
|
||||
@@ -43,16 +43,16 @@ spec:
|
||||
name: cloudflare-api-token
|
||||
key: api-token
|
||||
extraArgs:
|
||||
- --cloudflare-proxied
|
||||
- --cloudflare-dns-records-per-page=5000
|
||||
- --default-targets=d2386ccd-a665-41e7-8631-603fdafcb006.cfargotunnel.com
|
||||
# Every public host is a DNS-only CNAME to the proxy load balancer (kubernetes/apps/cloudflare-lb-sync).
|
||||
- --default-targets=proxy.renner.uno
|
||||
- --force-default-targets
|
||||
domainFilters:
|
||||
- renner.uno
|
||||
sources:
|
||||
- ingress
|
||||
txtOwnerId: k8s-homelab
|
||||
policy: upsert-only
|
||||
policy: sync
|
||||
# Filter by label, not annotation. external-dns translates annotations
|
||||
# in its prefix namespace into ProviderSpecific properties on desired
|
||||
# endpoints; the UniFi webhook does not implement AdjustEndpoints, so
|
||||
@@ -60,4 +60,4 @@ spec:
|
||||
# records and cause every reconcile to delete-and-recreate the same
|
||||
# values. Labels are not translated, so they are safe to use as a
|
||||
# selector without leaking provider-specific state to the UniFi side.
|
||||
labelFilter: external-dns/cloudflare=true
|
||||
labelFilter: dns.renner.uno/public=true
|
||||
|
||||
@@ -211,7 +211,7 @@ data:
|
||||
# Paperless sits entirely behind the Authentik gate — every path,
|
||||
# including /api/, answers 302 to unauthenticated callers, so there is no
|
||||
# endpoint that proves the app rather than the gate. This check is
|
||||
# therefore reachability only: DNS, TLS, Traefik and the outpost. It
|
||||
# therefore reachability only: DNS, TLS, Traefik and forward auth. It
|
||||
# stays green if paperless itself is dead behind a live gate.
|
||||
#
|
||||
# Closing that blind spot needs an in-cluster probe of the paperless
|
||||
|
||||
@@ -4,9 +4,10 @@ metadata:
|
||||
name: gatus
|
||||
namespace: apps
|
||||
labels:
|
||||
# Registered publicly (Cloudflare wildcard -> NetBird proxy); the UDM
|
||||
# external-dns instance skips it, LAN reaches it via the hairpin NAT.
|
||||
# Registered publicly (explicit CNAME -> NetBird proxy). No
|
||||
# dns.renner.uno/internal label: external-dns-unifi writes no UDM record.
|
||||
dns.renner.uno/public: "true"
|
||||
netbird.renner.uno/public: "true"
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: letsencrypt-cluster
|
||||
spec:
|
||||
|
||||
@@ -23,7 +23,7 @@ spec:
|
||||
retryInterval: 60
|
||||
maxRetries: 1
|
||||
dns:
|
||||
# cluster services have no own record; they resolve through the *.renner.uno wildcard
|
||||
# public CNAME to the NetBird proxy, created by external-dns (dns.renner.uno/public)
|
||||
hostname: status.renner.uno
|
||||
resolveType: CNAME
|
||||
resolveServer: "2606:4700:4700::1111,1.1.1.1"
|
||||
|
||||
@@ -23,7 +23,7 @@ spec:
|
||||
type: RuntimeDefault
|
||||
containers:
|
||||
- name: gitea-mcp
|
||||
image: docker.gitea.com/gitea-mcp-server:1.10.0 # {"$imagepolicy": "flux-system:gitea-mcp"}
|
||||
image: docker.gitea.com/gitea-mcp-server:1.11.0 # {"$imagepolicy": "flux-system:gitea-mcp"}
|
||||
# Image has no ENTRYPOINT (binary is in CMD), so args alone would replace it.
|
||||
command:
|
||||
- /app/gitea-mcp
|
||||
|
||||
@@ -7,6 +7,8 @@ metadata:
|
||||
app.kubernetes.io/name: gitea-mcp
|
||||
# Published on the NetBird proxy; LAN DNS stays on the Traefik VIP.
|
||||
netbird.renner.uno/public: "true"
|
||||
dns.renner.uno/internal: "true"
|
||||
dns.renner.uno/public: "true"
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: letsencrypt-cluster
|
||||
spec:
|
||||
|
||||
@@ -23,7 +23,7 @@ spec:
|
||||
retryInterval: 60
|
||||
maxRetries: 1
|
||||
dns:
|
||||
# cluster services have no own record; they resolve through the *.renner.uno wildcard
|
||||
# public CNAME to the NetBird proxy, created by external-dns (dns.renner.uno/public)
|
||||
hostname: gitea-mcp.renner.uno
|
||||
resolveType: CNAME
|
||||
resolveServer: "2606:4700:4700::1111,1.1.1.1"
|
||||
|
||||
@@ -8,6 +8,8 @@ metadata:
|
||||
# Published on the NetBird proxy; LAN DNS stays on the Traefik VIP so
|
||||
# SSH (gitea-ssh) and node image pulls stay local.
|
||||
netbird.renner.uno/public: "true"
|
||||
dns.renner.uno/internal: "true"
|
||||
dns.renner.uno/public: "true"
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: letsencrypt-cluster
|
||||
# Long-running git fetch/push and container-registry blob uploads:
|
||||
|
||||
@@ -23,7 +23,7 @@ spec:
|
||||
retryInterval: 60
|
||||
maxRetries: 1
|
||||
dns:
|
||||
# cluster services have no own record; they resolve through the *.renner.uno wildcard
|
||||
# public CNAME to the NetBird proxy, created by external-dns (dns.renner.uno/public)
|
||||
hostname: git.renner.uno
|
||||
resolveType: CNAME
|
||||
resolveServer: "2606:4700:4700::1111,1.1.1.1"
|
||||
@@ -90,7 +90,7 @@ spec:
|
||||
retryInterval: 60
|
||||
maxRetries: 1
|
||||
dns:
|
||||
# cluster services have no own record; they resolve through the *.renner.uno wildcard
|
||||
# public CNAME to the NetBird proxy, created by external-dns (dns.renner.uno/public)
|
||||
hostname: gitea.renner.uno
|
||||
resolveType: CNAME
|
||||
resolveServer: "2606:4700:4700::1111,1.1.1.1"
|
||||
|
||||
@@ -32,7 +32,7 @@ spec:
|
||||
type: RuntimeDefault
|
||||
containers:
|
||||
- name: sync
|
||||
image: gitea.renner.uno/konairius/hermes:build.1792569647 # {"$imagepolicy": "flux-system:hermes"}
|
||||
image: gitea.renner.uno/konairius/hermes:build.1792940452 # {"$imagepolicy": "flux-system:hermes"}
|
||||
command:
|
||||
- /opt/hermes/.venv/bin/python
|
||||
- /opt/hermes-skills/gitea-issues/scripts/sync_webhook.py
|
||||
|
||||
@@ -51,7 +51,7 @@ spec:
|
||||
# connects from the pod network. No env equivalent exists, so it is
|
||||
# set in config.yaml on every start (idempotent).
|
||||
- name: config
|
||||
image: gitea.renner.uno/konairius/hermes:build.1792569647 # {"$imagepolicy": "flux-system:hermes"}
|
||||
image: gitea.renner.uno/konairius/hermes:build.1792940452 # {"$imagepolicy": "flux-system:hermes"}
|
||||
command:
|
||||
- /opt/hermes/.venv/bin/hermes
|
||||
- config
|
||||
@@ -75,7 +75,7 @@ spec:
|
||||
mountPath: /opt/data
|
||||
# WebSocket keepalive ping interval in seconds (default 20).
|
||||
- name: config-ws-ping
|
||||
image: gitea.renner.uno/konairius/hermes:build.1792569647 # {"$imagepolicy": "flux-system:hermes"}
|
||||
image: gitea.renner.uno/konairius/hermes:build.1792940452 # {"$imagepolicy": "flux-system:hermes"}
|
||||
command:
|
||||
- /opt/hermes/.venv/bin/hermes
|
||||
- config
|
||||
@@ -99,7 +99,7 @@ spec:
|
||||
mountPath: /opt/data
|
||||
# Skills from git (ConfigMap hermes-skills) beside the PVC's skills/.
|
||||
- name: skills-config
|
||||
image: gitea.renner.uno/konairius/hermes:build.1792569647 # {"$imagepolicy": "flux-system:hermes"}
|
||||
image: gitea.renner.uno/konairius/hermes:build.1792940452 # {"$imagepolicy": "flux-system:hermes"}
|
||||
command:
|
||||
- /opt/hermes/.venv/bin/hermes
|
||||
- config
|
||||
@@ -130,7 +130,7 @@ spec:
|
||||
# - alert-monitor: hourly; the script wakes the agent only for
|
||||
# untriaged alerts.
|
||||
- name: cron-jobs
|
||||
image: gitea.renner.uno/konairius/hermes:build.1792569647 # {"$imagepolicy": "flux-system:hermes"}
|
||||
image: gitea.renner.uno/konairius/hermes:build.1792940452 # {"$imagepolicy": "flux-system:hermes"}
|
||||
# Non-fatal: a broken jobs.json or a changed cron CLI after an image
|
||||
# bump logs a warning instead of keeping Hermes from starting.
|
||||
command:
|
||||
@@ -187,7 +187,7 @@ spec:
|
||||
readOnly: true
|
||||
# Home Assistant MCP server; token resolved from HA_TOKEN at connect, writes need approval.
|
||||
- name: config-mcp-homeassistant
|
||||
image: gitea.renner.uno/konairius/hermes:build.1792569647 # {"$imagepolicy": "flux-system:hermes"}
|
||||
image: gitea.renner.uno/konairius/hermes:build.1792940452 # {"$imagepolicy": "flux-system:hermes"}
|
||||
command:
|
||||
- /opt/hermes/.venv/bin/hermes
|
||||
- config
|
||||
@@ -214,7 +214,7 @@ spec:
|
||||
# skills, the Home Assistant MCP and the tea login are re-applied on
|
||||
# every start. default gets the kanban toolset to hand cards to them.
|
||||
- name: experts
|
||||
image: gitea.renner.uno/konairius/hermes:build.1792569647 # {"$imagepolicy": "flux-system:hermes"}
|
||||
image: gitea.renner.uno/konairius/hermes:build.1792940452 # {"$imagepolicy": "flux-system:hermes"}
|
||||
# Non-fatal like cron-jobs: a broken expert logs a warning.
|
||||
command:
|
||||
- sh
|
||||
@@ -305,7 +305,7 @@ spec:
|
||||
# Gitea issues -> kanban (skills/gitea-issues): route script, webhook route on default,
|
||||
# completion shell hook plus its allowlist entry on every profile.
|
||||
- name: gitea-issues
|
||||
image: gitea.renner.uno/konairius/hermes:build.1792569647 # {"$imagepolicy": "flux-system:hermes"}
|
||||
image: gitea.renner.uno/konairius/hermes:build.1792940452 # {"$imagepolicy": "flux-system:hermes"}
|
||||
# Non-fatal like cron-jobs: a failure logs a warning.
|
||||
command:
|
||||
- sh
|
||||
@@ -368,7 +368,7 @@ spec:
|
||||
readOnly: true
|
||||
# Multiplexed default reads platform credentials only from .env (rationale: commit message).
|
||||
- name: default-env
|
||||
image: gitea.renner.uno/konairius/hermes:build.1792569647 # {"$imagepolicy": "flux-system:hermes"}
|
||||
image: gitea.renner.uno/konairius/hermes:build.1792940452 # {"$imagepolicy": "flux-system:hermes"}
|
||||
# Fatal on a writer failure: without these Matrix and the API server stay down.
|
||||
command:
|
||||
- /opt/hermes/.venv/bin/python
|
||||
@@ -428,7 +428,7 @@ spec:
|
||||
# tea login hermes-bot, written from the mounted token into an
|
||||
# emptyDir at the agent's ~/.config/tea.
|
||||
- name: tea-login
|
||||
image: gitea.renner.uno/konairius/hermes:build.1792569647 # {"$imagepolicy": "flux-system:hermes"}
|
||||
image: gitea.renner.uno/konairius/hermes:build.1792940452 # {"$imagepolicy": "flux-system:hermes"}
|
||||
command:
|
||||
- sh
|
||||
- -ec
|
||||
@@ -457,7 +457,7 @@ spec:
|
||||
readOnly: true
|
||||
containers:
|
||||
- name: hermes
|
||||
image: gitea.renner.uno/konairius/hermes:build.1792569647 # {"$imagepolicy": "flux-system:hermes"}
|
||||
image: gitea.renner.uno/konairius/hermes:build.1792940452 # {"$imagepolicy": "flux-system:hermes"}
|
||||
args: ["gateway", "run"]
|
||||
env:
|
||||
- name: HERMES_DASHBOARD
|
||||
|
||||
@@ -11,6 +11,8 @@ kind: Ingress
|
||||
metadata:
|
||||
name: hermes
|
||||
namespace: hermes
|
||||
labels:
|
||||
dns.renner.uno/internal: "true"
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: letsencrypt-cluster
|
||||
spec:
|
||||
@@ -38,6 +40,8 @@ kind: Ingress
|
||||
metadata:
|
||||
name: hermes-api
|
||||
namespace: hermes
|
||||
labels:
|
||||
dns.renner.uno/internal: "true"
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: letsencrypt-cluster
|
||||
spec:
|
||||
|
||||
@@ -19,8 +19,11 @@ expert's PR goes back to the card that opened it, without a manual step.
|
||||
labels, PR reviews, PR comments, PR open/close) posts to
|
||||
`http://hermes.hermes.svc.cluster.local:8644/webhooks/gitea-issues`.
|
||||
The CronJob `gitea-webhook-sync` (namespace hermes, every 15 min) keeps that hook in
|
||||
place, creates the domain labels and backfills, all only in repos where hermes-bot
|
||||
has issue write (org labels for their orgs, repo labels for user-owned ones): open
|
||||
place, creates the domain labels and backfills, all in every non-archived repo with
|
||||
issues of the orgs hermes-bot belongs to, where an org team grants it issue write
|
||||
(today: all repos of `konairius` through team `Bots`). Labels are org labels only.
|
||||
User-owned repos and repos where hermes-bot is only a direct collaborator get neither
|
||||
labels nor backfill; their new issues still become cards through the system hook. Backfill: open
|
||||
issues without a card comment are replayed to the route as signed `opened`
|
||||
deliveries, at most 10 per run, and the reviews of open hermes-bot PRs are replayed
|
||||
(step 8). Its site-admin PAT lives at OpenBao `apps/gitea-webhook-sync/admin`,
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
active system hook carries the desired name, a new one is created first and every
|
||||
other hook with the prefix is deleted afterwards.
|
||||
2. Domain labels. hestia/atlas/apollo/clio/daedalus are created only where Hermes
|
||||
works issues: repos with an issue tracker in which BOT_LOGIN (hermes-bot) has
|
||||
issue write. They become org labels in each org owning such a repo and repo labels
|
||||
in such user-owned repos (org labels do not reach those). Existing labels are left
|
||||
as they are; only missing ones are created.
|
||||
works issues: the non-archived org repos with an issue tracker in which BOT_LOGIN
|
||||
(hermes-bot) may write issues through an org team (it labels and comments). They
|
||||
are org labels of those orgs, never repo labels; user-owned repos are out of scope.
|
||||
Existing labels are left as they are; only missing ones are created.
|
||||
3. Backfill. Open issues of the same repos without the bridge's card comment are
|
||||
replayed to the Hermes webhook route as signed `opened` deliveries, at most
|
||||
BACKFILL_LIMIT per run and none started after RUN_BUDGET seconds, in random order
|
||||
@@ -60,9 +60,10 @@ BACKFILL_SPACING = float(os.environ.get("BACKFILL_SPACING_SECONDS", "3"))
|
||||
RUN_BUDGET = float(os.environ.get("RUN_BUDGET_SECONDS", "900"))
|
||||
DELIVER_TIMEOUT = 60
|
||||
CARD_MARKER = "<!-- hermes-kanban-card:"
|
||||
# Labels and backfill only where this account may write issues (it labels and comments).
|
||||
# Labels and backfill only in org repos this account may write issues in (it labels and comments).
|
||||
BOT_LOGIN = os.environ.get("BOT_LOGIN", "hermes-bot")
|
||||
BOT_WRITE = ("write", "admin", "owner")
|
||||
ISSUES_UNIT = "repo.issues"
|
||||
STARTED = time.monotonic()
|
||||
# Review replay (step 4): reviews by these accounts on open BOT_LOGIN PRs.
|
||||
REVIEW_BOT_LOGIN = os.environ.get("REVIEW_BOT_LOGIN", "review-bot")
|
||||
@@ -110,13 +111,11 @@ def api(method: str, path: str, token: str, body: dict | None = None):
|
||||
|
||||
|
||||
def paged(path: str, token: str) -> list[dict]:
|
||||
"""All pages of a list endpoint; /repos/search wraps its list in {"data": [...]}."""
|
||||
"""All pages of a list endpoint."""
|
||||
out, page = [], 1
|
||||
sep = "&" if "?" in path else "?"
|
||||
while True:
|
||||
batch = api("GET", f"{path}{sep}page={page}&limit=50", token) or []
|
||||
if isinstance(batch, dict):
|
||||
batch = batch.get("data") or []
|
||||
out.extend(batch)
|
||||
if len(batch) < 50:
|
||||
return out
|
||||
@@ -160,25 +159,56 @@ def reconcile(token: str, secret: str) -> str:
|
||||
|
||||
# --- 2. domain labels --------------------------------------------------------
|
||||
|
||||
def team_writes_issues(team: dict) -> bool:
|
||||
"""Issue write from the team's unit map (Gitea >= 1.20), else its team-wide mode."""
|
||||
if team.get("permission") in ("admin", "owner"):
|
||||
return True
|
||||
units = team.get("units_map") or {}
|
||||
return (units.get(ISSUES_UNIT) if units else team.get("permission")) in BOT_WRITE
|
||||
|
||||
|
||||
def issue_repos(token: str, errors: list[str] | None = None) -> list[dict]:
|
||||
"""Repos whose issues Hermes works: issue tracker on, not archived, and hermes-bot may
|
||||
write issues there (it sets the labels and comments). A site admin sees every repo.
|
||||
A repo whose permission lookup fails is skipped and named in `errors`."""
|
||||
out = []
|
||||
for r in paged("/repos/search", token):
|
||||
if not r.get("has_issues", True) or r.get("archived"):
|
||||
"""Repos whose issues Hermes works: in each org BOT_LOGIN belongs to, the repos of its
|
||||
teams that grant issue write (every org repo for an includes_all_repositories team),
|
||||
issue tracker on, not archived. Not /collaborators/{user}/permission: that reports
|
||||
the repo-wide access mode, which stays "none" when the write comes from a unit-based
|
||||
team. The admin route lists private orgs too and needs only the PAT's admin scope
|
||||
(/users/{u}/orgs also requires read:user). An org or team whose lookup fails is
|
||||
skipped and named in `errors`."""
|
||||
def failed(what: str, exc: RuntimeError) -> None:
|
||||
if errors is None:
|
||||
raise exc
|
||||
errors.append(f"{what}: {exc}")
|
||||
|
||||
found: dict[str, dict] = {}
|
||||
for org in paged(f"/admin/users/{q(BOT_LOGIN)}/orgs", token):
|
||||
name = org.get("username") or org.get("name") or ""
|
||||
if not name:
|
||||
continue
|
||||
owner, _, name = r["full_name"].partition("/")
|
||||
try:
|
||||
perm = api("GET", f"/repos/{q(owner)}/{q(name)}/collaborators/{q(BOT_LOGIN)}/permission", token)
|
||||
teams = paged(f"/orgs/{q(name)}/teams", token)
|
||||
except RuntimeError as exc:
|
||||
if errors is None:
|
||||
raise
|
||||
errors.append(f"{r['full_name']}: {exc}")
|
||||
failed(name, exc)
|
||||
continue
|
||||
if (perm or {}).get("permission") in BOT_WRITE:
|
||||
out.append(r)
|
||||
return out
|
||||
for team in teams:
|
||||
if not team_writes_issues(team):
|
||||
continue
|
||||
try:
|
||||
try:
|
||||
api("GET", f"/teams/{team['id']}/members/{q(BOT_LOGIN)}", token)
|
||||
except RuntimeError as exc:
|
||||
if str(exc).endswith("HTTP 404"):
|
||||
continue # not a member of this team
|
||||
raise
|
||||
repos = paged(f"/orgs/{q(name)}/repos" if team.get("includes_all_repositories")
|
||||
else f"/teams/{team['id']}/repos", token)
|
||||
except RuntimeError as exc:
|
||||
failed(f"{name} team {team.get('name')}", exc)
|
||||
continue
|
||||
for r in repos:
|
||||
if r.get("has_issues", True) and not r.get("archived"):
|
||||
found.setdefault(r["full_name"], r)
|
||||
return [found[k] for k in sorted(found)]
|
||||
|
||||
|
||||
def ensure_labels_at(path: str, token: str) -> list[str]:
|
||||
@@ -192,18 +222,14 @@ def ensure_labels_at(path: str, token: str) -> list[str]:
|
||||
|
||||
|
||||
def ensure_labels(token: str, repos: list[dict]) -> str:
|
||||
"""Org labels in each org that owns one of `repos`, repo labels in the user-owned ones."""
|
||||
orgs = {n for o in paged("/admin/orgs", token) if (n := o.get("username") or o.get("name"))}
|
||||
owners = {(r.get("owner") or {}).get("login") for r in repos}
|
||||
targets = [f"/orgs/{q(org)}/labels" for org in sorted(orgs & owners)]
|
||||
targets += [f"/repos/{q(r['owner']['login'])}/{q(r['name'])}/labels" for r in repos
|
||||
if (r.get("owner") or {}).get("login") not in orgs]
|
||||
"""Org labels in each org that owns one of `repos` (all org repos); never repo labels."""
|
||||
orgs = sorted({o for r in repos if (o := (r.get("owner") or {}).get("login"))})
|
||||
actions = []
|
||||
for path in targets:
|
||||
created = ensure_labels_at(path, token)
|
||||
for org in orgs:
|
||||
created = ensure_labels_at(f"/orgs/{q(org)}/labels", token)
|
||||
if created:
|
||||
actions.append(f"{path.rsplit('/labels', 1)[0]}: created {','.join(created)}")
|
||||
return "; ".join(actions) or f"labels present in {len(targets)} orgs/repos"
|
||||
actions.append(f"/orgs/{org}: created {','.join(created)}")
|
||||
return "; ".join(actions) or f"labels present in {len(orgs)} orgs"
|
||||
|
||||
|
||||
# --- 3. backfill -------------------------------------------------------------
|
||||
@@ -372,9 +398,9 @@ def main() -> int:
|
||||
def load_repos() -> str:
|
||||
errors: list[str] = []
|
||||
repos.extend(issue_repos(token, errors))
|
||||
msg = f"{len(repos)} with issues writable by {BOT_LOGIN}"
|
||||
msg = f"{len(repos)} org repos with issues writable by {BOT_LOGIN}"
|
||||
if errors: # the other repos still get labels and backfill; the Job fails
|
||||
raise RuntimeError(f"{msg}; permission lookup failed, skipped: {'; '.join(errors)}")
|
||||
raise RuntimeError(f"{msg}; team lookup failed, skipped: {'; '.join(errors)}")
|
||||
return msg
|
||||
|
||||
failures = 0
|
||||
|
||||
@@ -5,8 +5,12 @@
|
||||
is a TLS-passthrough service on :443 with a PROXY v2 header, going to Traefik `websecure`.
|
||||
There are no UDM port forwards and no other public L4 path. LB VIPs (`bgp-pool`,
|
||||
`fd99::/64`, `10.2.99.0/24`) are LAN/mesh-only.
|
||||
- DNS labels on an Ingress: `dns.renner.uno/internal` writes the UDM (LAN) record
|
||||
(opt-in), `dns.renner.uno/public` writes the Cloudflare CNAME to `proxy.renner.uno`, and
|
||||
`netbird.renner.uno/public` makes `netbird-service-sync` publish the proxy service. A
|
||||
public host needs both public labels.
|
||||
- `netbird-service-sync` publishes **only hosts on Ingresses** labelled
|
||||
`dns.renner.uno/public` (or `netbird.renner.uno/public`), and it reads no other kind.
|
||||
`netbird.renner.uno/public`, and it reads no other kind.
|
||||
To publish a TLS host served by an `IngressRouteTCP` (TLS terminated by Traefik), put the
|
||||
host on its **own** labelled Ingress annotated
|
||||
`traefik.ingress.kubernetes.io/router.entrypoints: web` with **no** `tls:` section, and
|
||||
|
||||
@@ -16,15 +16,15 @@ monitor, and its history starts over.
|
||||
the KumaMonitor `healthCheckExprs` entry with `current: "true"` (see SKILL.md pitfalls).
|
||||
|
||||
## Which hosts are public
|
||||
The public set is exactly the hosts on Ingresses labelled `dns.renner.uno/public` or
|
||||
`netbird.renner.uno/public`. To confirm it, do a TLS handshake against the proxy-1 and
|
||||
A public host needs both labels on its Ingress: `netbird.renner.uno/public` for the proxy
|
||||
service and `dns.renner.uno/public` for the Cloudflare CNAME. To confirm it, do a TLS handshake against the proxy-1 and
|
||||
proxy-2 addresses (resolved via DoH) with each candidate hostname as the SNI. Only public hosts
|
||||
return a CA-verified certificate. The proxies do not answer for their own names, so a
|
||||
handshake with `proxy-N.renner.uno` as the SNI fails.
|
||||
|
||||
## Checks per host (owner's spec: DNS + HTTP reachability + response validation)
|
||||
- **DNS.** A cluster host has no record of its own and resolves through the `*.renner.uno`
|
||||
wildcard. Check `resolveType: CNAME` with `conditions: [{operator: equals, value:
|
||||
- **DNS.** A cluster host's public record is a CNAME to `proxy.renner.uno` created by
|
||||
external-dns from `dns.renner.uno/public`. Check `resolveType: CNAME` with `conditions: [{operator: equals, value:
|
||||
proxy.renner.uno}]`. An external host checks its own AAAA record, or A when it has no
|
||||
AAAA. Use `resolveServer: "2606:4700:4700::1111,1.1.1.1"` so IPv6 comes first; Kuma
|
||||
fails over through the list in order.
|
||||
@@ -71,7 +71,7 @@ reached Kuma.
|
||||
parent exists and is a group.
|
||||
- Emulate each http/keyword/json-query check the way Kuma does it: axios, Kuma's
|
||||
`evaluateJsonQuery` logic via `jsonata`, and a custom `lookup` that resolves through DoH,
|
||||
because this pod's DNS is split-horizon. Run each wildcard host pinned to proxy-1 and to
|
||||
because this pod's DNS is split-horizon. Run each public host pinned to proxy-1 and to
|
||||
proxy-2.
|
||||
- DNS monitors can't be checked from the cluster, because outbound :53 to external
|
||||
resolvers is blocked. After merge, read `monitor_status` from Prometheus instead
|
||||
|
||||
@@ -701,62 +701,120 @@ def repo(full, has_issues=True, archived=False):
|
||||
"has_issues": has_issues, "archived": archived}
|
||||
|
||||
|
||||
def team(tid, name, issues="write", all_repos=True, permission="write"):
|
||||
return {"id": tid, "name": name, "includes_all_repositories": all_repos,
|
||||
"permission": permission, "units_map": {"repo.issues": issues, "repo.code": "write"}}
|
||||
|
||||
|
||||
def fake_gitea(orgs, teams, members, repos, fail=()):
|
||||
"""api() stand-in: orgs of the bot, teams per org, bot's team ids, repos per org or team."""
|
||||
seen = []
|
||||
|
||||
def fake(method, path, token, body=None):
|
||||
p = path.split("?")[0]
|
||||
seen.append(p)
|
||||
if p in fail:
|
||||
raise RuntimeError(f"GET {p}: HTTP 500")
|
||||
if p == "/admin/users/hermes-bot/orgs":
|
||||
return [{"username": o} for o in orgs]
|
||||
if p.startswith("/orgs/") and p.endswith("/teams"):
|
||||
return teams.get(p.split("/")[2], [])
|
||||
if p.startswith("/teams/") and "/members/" in p:
|
||||
if int(p.split("/")[2]) in members:
|
||||
return {"login": "hermes-bot"}
|
||||
raise RuntimeError(f"GET {p}: HTTP 404")
|
||||
if p.endswith("/repos"):
|
||||
return repos.get(p, [])
|
||||
raise AssertionError(f"unexpected {method} {p}")
|
||||
|
||||
return fake, seen
|
||||
|
||||
|
||||
class DomainLabels(unittest.TestCase):
|
||||
def test_labels_only_for_orgs_and_user_repos_hermes_works(self):
|
||||
def test_org_labels_only_never_repo_labels(self):
|
||||
calls = []
|
||||
|
||||
def fake(method, path, token, body=None):
|
||||
calls.append((method, path, body))
|
||||
if path.startswith("/admin/orgs"):
|
||||
return [{"username": "konairius"}, {"username": "unrelated-org"}]
|
||||
if path.startswith("/orgs/konairius/labels"):
|
||||
return [{"name": "Atlas"}, {"name": "bug"}]
|
||||
return []
|
||||
|
||||
repos = [repo("konairius/homelab"), repo("k.renner/turm1388")]
|
||||
repos = [repo("konairius/homelab"), repo("konairius/shelly-manager")]
|
||||
with mock.patch.object(sync, "api", side_effect=fake):
|
||||
msg = sync.ensure_labels("tok", repos)
|
||||
posts = [(p, b["name"]) for m, p, b in calls if m == "POST"]
|
||||
self.assertEqual(sorted(n for p, n in posts if p == "/orgs/konairius/labels"),
|
||||
["apollo", "clio", "daedalus", "hestia"]) # atlas exists (any case)
|
||||
self.assertEqual(len([p for p, _ in posts if p == "/repos/k.renner/turm1388/labels"]), 5)
|
||||
self.assertFalse([p for p, _ in posts if p.startswith("/repos/konairius/")]) # org labels reach it
|
||||
self.assertFalse([c for c in calls if "unrelated-org" in c[1]]) # no repo of it is worked
|
||||
self.assertFalse([c for c in calls if c[1].startswith("/repos/")]) # org labels reach them
|
||||
self.assertFalse([c for c in calls if c[1].startswith("/admin/")])
|
||||
self.assertIn("created", msg)
|
||||
|
||||
def test_repos_without_issues_archived_or_bot_write_are_skipped(self):
|
||||
perms = {"a/x": "write", "a/w": "admin", "gitea_admin/_cargo-index": "read", "a/n": "none"}
|
||||
seen = []
|
||||
|
||||
def fake(method, path, token, body=None):
|
||||
if path.startswith("/repos/search"):
|
||||
return {"ok": True, "data": [
|
||||
repo("a/x"), repo("a/w"), repo("gitea_admin/_cargo-index"), repo("a/n"),
|
||||
repo("a/y", has_issues=False), repo("a/z", archived=True)]}
|
||||
seen.append(path)
|
||||
full = path.split("/repos/")[1].split("/collaborators/")[0]
|
||||
return {"permission": perms[full]}
|
||||
|
||||
def test_team_write_covers_every_org_repo_without_collaborator(self):
|
||||
# Live 2026-10-21: hermes-bot is only in team Bots (all repos, issues write);
|
||||
# /collaborators/hermes-bot/permission says "none" for 9 of the 10 repos.
|
||||
org_repos = [repo("konairius/homelab"), repo("konairius/shelly-manager"),
|
||||
repo("konairius/ical-proxy"), repo("konairius/off", has_issues=False),
|
||||
repo("konairius/old", archived=True)]
|
||||
fake, seen = fake_gitea(
|
||||
orgs=["konairius"],
|
||||
teams={"konairius": [team(1, "Owners", "owner", permission="owner"), team(2, "Bots"),
|
||||
team(5, "Reviewers", "read", permission="none")]},
|
||||
members={2},
|
||||
repos={"/orgs/konairius/repos": org_repos})
|
||||
with mock.patch.object(sync, "api", side_effect=fake):
|
||||
got = [r["full_name"] for r in sync.issue_repos("tok")]
|
||||
self.assertEqual(got, ["a/x", "a/w"])
|
||||
self.assertIn("/repos/a/x/collaborators/hermes-bot/permission", seen)
|
||||
self.assertFalse([p for p in seen if p.startswith(("/repos/a/y/", "/repos/a/z/"))])
|
||||
self.assertEqual(got, ["konairius/homelab", "konairius/ical-proxy", "konairius/shelly-manager"])
|
||||
self.assertFalse([p for p in seen if "/collaborators/" in p or p.startswith("/repos/")])
|
||||
self.assertNotIn("/teams/5/members/hermes-bot", seen) # read-only team is not even checked
|
||||
|
||||
def test_failed_permission_lookup_skips_only_that_repo(self):
|
||||
def fake(method, path, token, body=None):
|
||||
if path.startswith("/repos/search"):
|
||||
return {"data": [repo("a/x"), repo("a/broken"), repo("a/w")]}
|
||||
if path.startswith("/repos/a/broken/"):
|
||||
raise RuntimeError("GET /repos/a/broken/...: HTTP 500")
|
||||
return {"permission": "write"}
|
||||
def test_team_with_selected_repos_and_no_issue_write(self):
|
||||
fake, seen = fake_gitea(
|
||||
orgs=["a", "b"],
|
||||
teams={"a": [team(3, "Some", all_repos=False)],
|
||||
"b": [team(4, "CodeOnly", issues="read")]},
|
||||
members={3, 4},
|
||||
repos={"/teams/3/repos": [repo("a/x"), repo("a/y")],
|
||||
"/orgs/a/repos": [repo("a/x"), repo("a/y"), repo("a/not-in-team")],
|
||||
"/orgs/b/repos": [repo("b/z")]})
|
||||
with mock.patch.object(sync, "api", side_effect=fake):
|
||||
got = [r["full_name"] for r in sync.issue_repos("tok")]
|
||||
self.assertEqual(got, ["a/x", "a/y"])
|
||||
self.assertNotIn("/orgs/b/repos", seen)
|
||||
|
||||
def test_team_issue_write_from_units_map_or_team_mode(self):
|
||||
self.assertTrue(sync.team_writes_issues(team(2, "Bots")))
|
||||
self.assertFalse(sync.team_writes_issues(team(5, "Reviewers", "read", permission="none")))
|
||||
self.assertTrue(sync.team_writes_issues(team(1, "Owners", "read", permission="owner")))
|
||||
self.assertTrue(sync.team_writes_issues({"permission": "write"})) # no units_map
|
||||
self.assertFalse(sync.team_writes_issues({"permission": "read", "units_map": {}}))
|
||||
|
||||
def test_user_repos_are_out_of_scope(self):
|
||||
fake, seen = fake_gitea(orgs=[], teams={}, members=set(), repos={})
|
||||
with mock.patch.object(sync, "api", side_effect=fake):
|
||||
self.assertEqual(sync.issue_repos("tok"), [])
|
||||
self.assertEqual(seen, ["/admin/users/hermes-bot/orgs"]) # no /repos/search over user repos
|
||||
|
||||
def test_failed_team_lookup_skips_only_that_team(self):
|
||||
fake, _ = fake_gitea(
|
||||
orgs=["a", "broken"],
|
||||
teams={"a": [team(3, "Bots", all_repos=False), team(6, "More", all_repos=False)]},
|
||||
members={3, 6},
|
||||
repos={"/teams/3/repos": [repo("a/x")], "/teams/6/repos": [repo("a/w"), repo("a/x")]},
|
||||
fail={"/orgs/broken/teams", "/teams/6/members/hermes-bot"})
|
||||
errors = []
|
||||
with mock.patch.object(sync, "api", side_effect=fake):
|
||||
got = [r["full_name"] for r in sync.issue_repos("tok", errors)]
|
||||
self.assertEqual(got, ["a/x", "a/w"])
|
||||
self.assertEqual(len(errors), 1)
|
||||
self.assertIn("a/broken", errors[0])
|
||||
self.assertEqual(got, ["a/x"])
|
||||
self.assertEqual(len(errors), 2)
|
||||
self.assertIn("a team More", errors[0])
|
||||
self.assertTrue(errors[1].startswith("broken:"))
|
||||
|
||||
def test_failed_lookup_raises_without_error_list(self):
|
||||
fake, _ = fake_gitea(orgs=["broken"], teams={}, members=set(), repos={},
|
||||
fail={"/orgs/broken/teams"})
|
||||
with mock.patch.object(sync, "api", side_effect=fake), self.assertRaises(RuntimeError):
|
||||
sync.issue_repos("tok")
|
||||
|
||||
|
||||
class Backfill(unittest.TestCase):
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
# /etc/nginx/conf.d/ at start.
|
||||
#
|
||||
# shelly-manager signs in whoever X-authentik-username names when the peer is
|
||||
# in Auth__ReverseProxy__TrustedProxies (the pod CIDR). Only the Authentik
|
||||
# outpost may reach :8080 directly. Other clients reach this :8081 instead,
|
||||
# in Auth__ReverseProxy__TrustedProxies (the pod CIDR). Only Traefik may
|
||||
# reach :8080 directly. Other clients reach this :8081 instead,
|
||||
# which drops the identity header, so every request here falls through
|
||||
# to the API key (or the login cookie) and a forged header gets 401.
|
||||
#
|
||||
|
||||
@@ -75,7 +75,7 @@ spec:
|
||||
# macvlan net1 interface on the IoT VLAN — exposing the
|
||||
# unauthenticated UI to that untrusted segment past the
|
||||
# Authentik gate. POD_IP is the eth0 IPv4 (status.podIP); the
|
||||
# Service, the Authentik outpost, and the kubelet httpGet
|
||||
# Service, Traefik, and the kubelet httpGet
|
||||
# probes all reach the app on that address. mDNS discovery is
|
||||
# unaffected: ZeroconfResolver binds its own multicast sockets
|
||||
# on net1 independently of Kestrel.
|
||||
@@ -90,8 +90,7 @@ spec:
|
||||
# BLE radios: ESP32 esphome bluetooth_proxy nodes (e.g. the M5 Atom
|
||||
# Echo) are AUTO-DISCOVERED on the IoT VLAN via mDNS
|
||||
# (_esphomelib._tcp) over the same net1 macvlan route as the Shellys —
|
||||
# no static hostname/DNS (which the *.renner.uno wildcard would poison
|
||||
# over IPv6). The shared fleet Noise key (= the dashboard's
|
||||
# no static hostname/DNS. The shared fleet Noise key (= the dashboard's
|
||||
# shelly_ble_proxy_api_key) lets shelly-manager complete the encrypted
|
||||
# native-API handshake to each discovered proxy: DeviceInfo on
|
||||
# /ble-radios today, the BLE scan/GATT provisioning path next.
|
||||
@@ -114,11 +113,11 @@ spec:
|
||||
secretKeyRef:
|
||||
name: shelly-manager-auth
|
||||
key: api-key
|
||||
# SSO: the Authentik proxy outpost (authentik-gate class,
|
||||
# which the ingress routes through) injects X-authentik-username;
|
||||
# SSO: Authentik forward auth (authentik-gate class,
|
||||
# via Traefik ForwardAuth) sets X-authentik-username;
|
||||
# the app signs that identity in directly, so the gate login is the
|
||||
# only login. The header is only honored from TrustedProxies — the
|
||||
# outpost pod's address is dynamic, so this trusts the cluster pod
|
||||
# Traefik pod's address is dynamic, so this trusts the cluster pod
|
||||
# CIDR and leans on the namespace CNP to keep other pods off the
|
||||
# app port. ADMIN_PASSWORD (above) stays as break-glass, e.g. for
|
||||
# port-forward access when authentik is down. Never open :8080 to
|
||||
@@ -170,13 +169,13 @@ spec:
|
||||
memory: 128Mi
|
||||
limits:
|
||||
memory: 512Mi
|
||||
# API-key-only listener for clients other than the Authentik outpost
|
||||
# API-key-only listener for clients other than Traefik
|
||||
# (REN-931). nginx on ${POD_IP}:8081 proxies to
|
||||
# :8080 and drops X-authentik-username, so the ProxyHeader sign-in
|
||||
# cannot be reached through it. Config and reasoning:
|
||||
# shelly-manager-api-proxy.conf. Service: shelly-manager-api.
|
||||
# No probes: it only serves the API-key path, and a probe failure would
|
||||
# also pull the outpost's endpoint out of the shelly-manager Service.
|
||||
# also pull the pod out of the shelly-manager Service.
|
||||
- name: api-proxy
|
||||
image: nginxinc/nginx-unprivileged:1.31-alpine@sha256:b9241c6e7b8e9a862f129d8d4199ab64b10390949a78bdd5603379b32c844083
|
||||
env:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# shelly-manager has no authentication of its own: anything reaching it can
|
||||
# rewrite Shelly config, push scripts and read stored device AdminPasswords, so
|
||||
# the Authentik gate (ingress class authentik-gate) is the only thing in front
|
||||
# the Authentik gate (the authentik-gate Middleware) is the only thing in front
|
||||
# of it: Authentik SSO login, Shelly Managers only.
|
||||
#
|
||||
# SignalR/WebSocket: the websecure entrypoint idleTimeout (180s) is kept alive
|
||||
@@ -12,11 +12,14 @@ kind: Ingress
|
||||
metadata:
|
||||
name: shelly-manager
|
||||
namespace: home-assistant
|
||||
labels:
|
||||
dns.renner.uno/internal: "true"
|
||||
annotations:
|
||||
traefik.ingress.kubernetes.io/router.middlewares: authentik-gate@kubernetescrd
|
||||
cert-manager.io/cluster-issuer: letsencrypt-cluster
|
||||
auth.renner.uno/group: Shelly Managers
|
||||
spec:
|
||||
ingressClassName: authentik-gate
|
||||
ingressClassName: traefik
|
||||
rules:
|
||||
- host: shelly-manager.home.renner.uno
|
||||
http:
|
||||
|
||||
@@ -15,7 +15,7 @@ spec:
|
||||
# API-key-only entry for in-cluster clients (REN-931, REN-935): the api-proxy
|
||||
# sidecar, which drops the X-authentik-username header. Clients call
|
||||
# http://shelly-manager-api.home-assistant.svc/api/v1/... with the API key.
|
||||
# :8080 stays outpost-only.
|
||||
# :8080 stays Traefik-only.
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
|
||||
@@ -1,179 +0,0 @@
|
||||
# Proposal: enrol the mosquitto broker credentials in Class-A rotation
|
||||
|
||||
**Status:** proposal, nothing implemented.
|
||||
**Scope:** the 8 MQTT broker users and the credentials behind them.
|
||||
|
||||
## Problem
|
||||
|
||||
Every self-generated secret in this cluster rotates automatically except these.
|
||||
`kubernetes/infrastructure/openbao/rotation/` holds 13 manifests defining 15
|
||||
rotator CronJobs (`home-assistant.yaml` alone defines three). Five are **Class-A**
|
||||
— authentik, crowdsec, paperless, shelly-manager and woodpecker — meaning
|
||||
"self-generated random secret", which is exactly what a broker password is.
|
||||
The mosquitto credentials are the only Class-A-shaped secrets not enrolled.
|
||||
|
||||
They are currently minted once by seven near-identical bootstrap Jobs
|
||||
(`mosquitto-bootstrap.yaml`, 508 lines — the ServiceAccount, Role and RoleBinding
|
||||
are inside that same file) which generate a password, hand-build Secret JSON with
|
||||
`jq` and POST it to the Kubernetes API with `curl`. Once created they never
|
||||
change again.
|
||||
|
||||
Three consequences:
|
||||
|
||||
1. **They never rotate.** Not on a schedule, not on compromise, not ever.
|
||||
2. **They exist only in the Secret object** — not in OpenBao, so not covered by
|
||||
the OpenBao snapshot CronJob, and unrecoverable if lost.
|
||||
3. **The Jobs cannot be modified.** A Job's `spec.template` is immutable, so
|
||||
changing even the container image makes the whole `home-assistant`
|
||||
Kustomization fail to reconcile with `field is immutable`. Any edit requires
|
||||
deleting or renaming the Jobs.
|
||||
|
||||
## Why the obvious fixes do not work
|
||||
|
||||
Recorded because each was tried and rejected on evidence, and the reasons are
|
||||
not obvious from the code.
|
||||
|
||||
| Approach | Why it fails |
|
||||
| --- | --- |
|
||||
| ExternalSecrets reading hand-seeded OpenBao paths | Depends on content copied in by hand. Git cannot recreate it; a fresh OpenBao leaves the paths empty and ESO then overwrites live broker credentials with nothing. |
|
||||
| ESO `Password` generator | **Overwrites pre-existing Secrets.** Verified: a Secret holding `KNOWN-PREEXISTING-VALUE` was replaced with a freshly generated password on first sync. Adopting it rotates the 7 Job-minted credentials at once, uncoordinated (`evcc` is already ESO-extract-backed and so unaffected). |
|
||||
| Keep the Jobs, fix only the image | Blocked by `spec.template` immutability. Renaming the Jobs works but is a hack that recurs on every future edit. |
|
||||
|
||||
The common thread: each treats the credential as something to *place*, when the
|
||||
real requirement is a credential that can be *replaced*.
|
||||
|
||||
## How rotation actually has to work here
|
||||
|
||||
The broker rebuilds its password file from scratch on **every pod start**
|
||||
(`mosquitto-deployment.yaml`): `rm -f /mosquitto/auth/passwd` followed by
|
||||
`mosquitto_passwd -c -b …` for each of the 8 users, sourced from env vars backed
|
||||
by the 8 Secrets.
|
||||
|
||||
Two things follow, and they shape the whole design:
|
||||
|
||||
- **A Secret change has no effect until the broker restarts.** There is no
|
||||
Reloader annotation on the mosquitto Deployment today, unlike the consumers of
|
||||
the existing Class-A rotators.
|
||||
- **There is no make-before-break.** A mosquitto user has exactly one password.
|
||||
The LLAT rotators can mint a second token and revoke the first afterwards; a
|
||||
broker user cannot hold old and new simultaneously. Unless a transitional
|
||||
second user is created, broker and client must cut over together.
|
||||
|
||||
### Who holds each credential
|
||||
|
||||
This is the part that determines cutover cost, and it is not visible from the
|
||||
manifests alone.
|
||||
|
||||
| Broker user | Held by | Cutover |
|
||||
| --- | --- | --- |
|
||||
| `health` | the broker's own liveness/readiness probes | in-cluster, same pod restart |
|
||||
| `zigbee2mqtt` | zigbee2mqtt Deployment (`secretKeyRef`) | in-cluster, pod restart |
|
||||
| `evcc` | evcc app; already OpenBao-backed via ESO | in-cluster, pod restart |
|
||||
| `sml2mqtt` | edge host, from `vault_edge_sml2mqtt_mqtt_password` | re-run the edge-host play |
|
||||
| `open3e` | edge host, from `vault_edge_open3e_mqtt_password` | re-run the edge-host play |
|
||||
| `homeassistant` | HA MQTT integration — a config entry created in the UI | needs an API/WebSocket update, or a manual re-entry |
|
||||
| `shellies` | Shelly device firmware | pushed per-device; `shelly-manager` is deployed and is the natural mechanism |
|
||||
| `admin` | a workstation client, held by a human | read the new value from OpenBao |
|
||||
|
||||
Note `sml2mqtt` and `open3e` currently keep **the same password in two unlinked
|
||||
places** — the Kubernetes Secret for the broker, and `ansible-vault` for the
|
||||
client — synchronised by hand. That duplication, not any client limitation, is
|
||||
what makes rotation feel impossible today.
|
||||
|
||||
## Proposed design
|
||||
|
||||
Follow the existing Class-A pattern exactly (`rotation/paperless.yaml` is the
|
||||
closest model): *generate random bytes → merge-patch into OpenBao → ESO syncs the
|
||||
Secret → restart the consumer*.
|
||||
|
||||
1. **One rotator CronJob per broker user**, running the existing `secret-rotator`
|
||||
binary in random mode, writing `apps/home-assistant/mosquitto-<user>-credentials`
|
||||
in OpenBao. Reuses the established policy/role/SA pattern; no new machinery.
|
||||
2. **ExternalSecrets** project each OpenBao entry to the existing Secret name and
|
||||
key, so `mosquitto-deployment.yaml` and the in-cluster consumers are unchanged.
|
||||
Key names stay as they are (`homeassistant-password` on one, `password` on the
|
||||
rest) — consumers reference them, so normalising is a separate change.
|
||||
3. **Add a Reloader annotation to the mosquitto Deployment** so a Secret change
|
||||
restarts the broker, instead of silently taking effect at some unrelated future
|
||||
restart.
|
||||
4. **Move the edge host off `ansible-vault` for these two values**, reading the
|
||||
same OpenBao entry instead, so there is one source of truth per credential.
|
||||
5. **Rotate one user at a time.** Each rotation then affects exactly one client,
|
||||
not all eight.
|
||||
|
||||
### The cutover window
|
||||
|
||||
With no make-before-break, each rotation has a window where broker and client
|
||||
disagree. Two options:
|
||||
|
||||
- **Accept a brief window** (recommended for most users). Order: rotator writes
|
||||
OpenBao → client picks up the new value → broker restarts. MQTT clients
|
||||
reconnect automatically; the window is seconds. Because rotation is per-user,
|
||||
only that one client is affected.
|
||||
|
||||
One failure mode to expect rather than be alarmed by: the broker rolls with
|
||||
`maxUnavailable: 0` / `maxSurge: 1`, so mid-rollout **two broker pods with
|
||||
different passwd files sit behind the LB**. A client reconnecting during that
|
||||
window can land on the old pod and fail auth until the rollout completes. It is
|
||||
self-healing and lasts seconds to a minute, but it will look alarming in logs
|
||||
during the first `health` / `zigbee2mqtt` rotation, so it is worth knowing in
|
||||
advance.
|
||||
- **Transitional dual user** (`<user>` and `<user>-next` in the passwd file and
|
||||
ACL) for any credential where even a brief outage is unacceptable. More moving
|
||||
parts; probably only worth it for `homeassistant`, which carries everything.
|
||||
|
||||
## Suggested phasing
|
||||
|
||||
Ordered so the risky work happens after the pattern is proven, and so each phase
|
||||
is independently valuable.
|
||||
|
||||
1. **`health` and `zigbee2mqtt` first.** Both are entirely in-cluster and pick up
|
||||
a new password on pod restart with no external coordination. Proves rotator →
|
||||
OpenBao → ESO → Reloader end to end with the smallest blast radius. `health`
|
||||
is the safest possible start: only the broker's own probes consume it.
|
||||
2. **`evcc`.** Already OpenBao-backed via ESO; only the rotator is missing.
|
||||
3. **`sml2mqtt` and `open3e`**, together with switching the edge host to read from
|
||||
OpenBao. This is where the duplicate-source-of-truth problem gets fixed.
|
||||
4. **`shellies`**, via shelly-manager pushing to devices. Needs investigation:
|
||||
shelly-manager has its own Class-A rotator today, but that rotates
|
||||
shelly-manager's own secret and does not touch device MQTT credentials.
|
||||
5. **`homeassistant`** last. Highest blast radius, and the config entry is UI-created,
|
||||
so it needs an API/WebSocket update path — the HA LLAT rotators
|
||||
(`rotation/home-assistant.yaml`) already talk to HA over WebSocket and are the
|
||||
obvious precedent.
|
||||
6. **`admin`** whenever convenient; a human reads the new value from OpenBao.
|
||||
|
||||
Only once a user is enrolled does its bootstrap Job become dead code. Delete the
|
||||
Jobs incrementally as their users migrate, rather than in one step — that also
|
||||
avoids the immutability problem entirely, since the Jobs are deleted, never
|
||||
patched.
|
||||
|
||||
## Open questions
|
||||
|
||||
- **Does `secret-rotator` random mode fit unchanged?** The existing rotators write
|
||||
a field into an OpenBao entry; here the entry holds a single password field, so
|
||||
it should, but this needs confirming against the binary rather than assumed.
|
||||
- **Can shelly-manager push MQTT credentials to devices**, and does it cover both
|
||||
Gen1 (`/settings/mqtt`) and Gen2+ (`Mqtt.SetConfig`) firmwares? If not, the
|
||||
`shellies` user may need a different mechanism or stay manual longest.
|
||||
- **How is the HA MQTT config entry updated programmatically?** Reusing the
|
||||
WebSocket approach from the LLAT rotator is plausible but unverified.
|
||||
- **Rotation cadence.** The existing rotators' schedules should be the reference
|
||||
rather than inventing a new one.
|
||||
- **ESO refresh latency.** Rotator-writes-OpenBao → Secret-updates →
|
||||
Reloader-restarts is delayed by up to one `refreshInterval`; the `evcc`
|
||||
ExternalSecret uses `1h`. That does not widen the outage window — broker and
|
||||
client still move together — but it does stretch how long a rotation takes to
|
||||
land, which matters for verifying one completed and for the cold-rebuild
|
||||
ordering question above. Worth deciding whether these ExternalSecrets want a
|
||||
shorter interval than 1h, or whether the rotator should trigger the sync
|
||||
directly.
|
||||
- **Bootstrap on a cold rebuild.** On a fresh cluster the rotator must create the
|
||||
OpenBao entry before ESO can sync it; check this against
|
||||
`kubernetes/RUNBOOK-cold-rebuild.md` so broker bring-up is not blocked.
|
||||
|
||||
## What this does not change
|
||||
|
||||
- Secret names, key names and every `secretKeyRef` in `mosquitto-deployment.yaml`.
|
||||
- The ACL model and the per-user topic scoping.
|
||||
- The `evcc` ExternalSecret, which already follows the target pattern.
|
||||
@@ -16,6 +16,7 @@ metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: home-assistant
|
||||
lb-pool: bgp
|
||||
dns.renner.uno/internal: "true"
|
||||
annotations:
|
||||
lbipam.cilium.io/ips: "10.2.99.87,fd99::87"
|
||||
external-dns.kubernetes.io/hostname: ha.renner.uno
|
||||
|
||||
@@ -128,7 +128,7 @@ spec:
|
||||
memory: 32Mi
|
||||
containers:
|
||||
- name: home-assistant
|
||||
image: ghcr.io/home-assistant/home-assistant:2026.10.2 # {"$imagepolicy": "flux-system:home-assistant"}
|
||||
image: ghcr.io/home-assistant/home-assistant:2026.10.4 # {"$imagepolicy": "flux-system:home-assistant"}
|
||||
env:
|
||||
- name: TZ
|
||||
value: Europe/Berlin
|
||||
|
||||
@@ -23,7 +23,7 @@ spec:
|
||||
# flashing is done in the browser over USB (ESP Web Tools / Web Serial),
|
||||
# and building/compiling is offline. So the 0.0.0.0:6052 bind stays on the
|
||||
# Cilium-governed pod network only, where the home-assistant CNP admits
|
||||
# ONLY the esphome gate outpost (generated CNP esphome-gate; see
|
||||
# ONLY Traefik (generated CNP esphome-gate; see
|
||||
# esphome-ingress.yaml) — no unauthenticated IoT-VLAN exposure like the
|
||||
# macvlan-on-0.0.0.0 hole shelly-manager had to pin Kestrel around.
|
||||
#
|
||||
|
||||
@@ -3,20 +3,23 @@ kind: Ingress
|
||||
metadata:
|
||||
name: esphome
|
||||
namespace: home-assistant
|
||||
labels:
|
||||
dns.renner.uno/internal: "true"
|
||||
annotations:
|
||||
traefik.ingress.kubernetes.io/router.middlewares: authentik-gate@kubernetescrd
|
||||
cert-manager.io/cluster-issuer: letsencrypt-cluster
|
||||
auth.renner.uno/group: ESPHome Managers
|
||||
spec:
|
||||
# ESPHome Device Builder has no auth of its own: anyone reaching it can edit
|
||||
# device YAML (incl. wifi/api secrets), compile, and flash/OTA firmware, so the
|
||||
# Authentik gate (ingress class authentik-gate) is the only thing in front of
|
||||
# Authentik gate (the authentik-gate Middleware) is the only thing in front of
|
||||
# it: Authentik SSO login, ESPHome Managers only.
|
||||
#
|
||||
# WebSocket: the dashboard streams build/OTA logs over a websocket; Traefik's
|
||||
# websecure entrypoint passes it through. Browser USB flashing uses Web
|
||||
# Serial, which needs a secure context; the serial link never traverses the
|
||||
# proxy.
|
||||
ingressClassName: authentik-gate
|
||||
ingressClassName: traefik
|
||||
rules:
|
||||
- host: esphome.home.renner.uno
|
||||
http:
|
||||
|
||||
@@ -7,6 +7,7 @@ metadata:
|
||||
# Registered publicly (Cloudflare wildcard -> NetBird proxy); the UDM
|
||||
# external-dns instance skips it, LAN reaches it via the hairpin NAT.
|
||||
dns.renner.uno/public: "true"
|
||||
netbird.renner.uno/public: "true"
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: letsencrypt-cluster
|
||||
spec:
|
||||
|
||||
@@ -12,26 +12,20 @@ resources:
|
||||
- config-sync-token-externalsecret.yaml
|
||||
- config-sync-gitea-externalsecret.yaml
|
||||
- matrix-externalsecret.yaml
|
||||
- mosquitto-bootstrap.yaml
|
||||
# Former `health` probe credential. The broker no longer reads it (the
|
||||
# probes use the cert account mosquitto-probe, REN-953); removed with its
|
||||
# rotator in the REN-802 cleanup step.
|
||||
- mosquitto-health-credentials-externalsecret.yaml
|
||||
- mosquitto-admin-password.yaml
|
||||
- mosquitto-config.yaml
|
||||
- mosquitto-certificate.yaml
|
||||
- mosquitto-service.yaml
|
||||
- mosquitto-iot-service.yaml
|
||||
- mosquitto-deployment.yaml
|
||||
- mosquitto-evcc-credentials-externalsecret.yaml
|
||||
# shelly-manager and the mDNS relay sit on the IoT VLAN: ../home-assistant-iot.
|
||||
- esphome-pvc.yaml
|
||||
- esphome-deployment.yaml
|
||||
- esphome-service.yaml
|
||||
- esphome-ingress.yaml
|
||||
# Zigbee2MQTT — ZHA replacement bridge. Ships scaled to 0; the cutover
|
||||
# runbook (zigbee2mqtt-migration-runbook.md) scales it up. The MQTT
|
||||
# `zigbee2mqtt` broker user is provisioned by mosquitto-bootstrap.yaml
|
||||
# (above) and wired into mosquitto-deployment.yaml (passwd + ACL).
|
||||
# runbook (zigbee2mqtt-migration-runbook.md) scales it up. It logs in to
|
||||
# the broker as register account `zigbee2mqtt-bridge` (mqtt-accounts.yaml).
|
||||
- zigbee2mqtt-coordinator-backup-externalsecret.yaml
|
||||
- zigbee2mqtt-config.yaml
|
||||
- zigbee2mqtt-pvc.yaml
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
# Password of the broker's `admin` workstation login (mosquitto-deployment.yaml).
|
||||
# Generated once in-cluster, nothing in OpenBao. Read it with
|
||||
# kubectl -n home-assistant get secret mosquitto-admin-password -o jsonpath='{.data.password}' | base64 -d
|
||||
apiVersion: generators.external-secrets.io/v1alpha1
|
||||
kind: Password
|
||||
metadata:
|
||||
name: mosquitto-admin-password
|
||||
namespace: home-assistant
|
||||
spec:
|
||||
length: 32
|
||||
digits: 8
|
||||
symbols: 0
|
||||
allowRepeat: true
|
||||
noUpper: false
|
||||
secretKeys:
|
||||
- password
|
||||
---
|
||||
apiVersion: external-secrets.io/v1
|
||||
kind: ExternalSecret
|
||||
metadata:
|
||||
name: mosquitto-admin-password
|
||||
namespace: home-assistant
|
||||
spec:
|
||||
refreshPolicy: CreatedOnce
|
||||
target:
|
||||
name: mosquitto-admin-password
|
||||
dataFrom:
|
||||
- sourceRef:
|
||||
generatorRef:
|
||||
apiVersion: generators.external-secrets.io/v1alpha1
|
||||
kind: Password
|
||||
name: mosquitto-admin-password
|
||||
@@ -1,394 +0,0 @@
|
||||
---
|
||||
# Generates mosquitto-credentials on first deploy. The password is created
|
||||
# in-cluster, lives only in the Secret object, and is never written to git
|
||||
# or seen by a human. The Mosquitto broker hashes it via mosquitto_passwd
|
||||
# -U at startup; HA reads the same value from this Secret (configured
|
||||
# manually in the HA MQTT integration UI).
|
||||
#
|
||||
# Idempotent: if the Secret already exists, the Job exits 0 without
|
||||
# regenerating, so subsequent Flux reconciles don't rotate the password.
|
||||
# To rotate, delete both the Secret and this Job; Flux will re-create
|
||||
# the Job and a fresh password.
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: mosquitto-bootstrap
|
||||
namespace: home-assistant
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: mosquitto-bootstrap
|
||||
namespace: home-assistant
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources: ["secrets"]
|
||||
verbs: ["get", "create"]
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: mosquitto-bootstrap
|
||||
namespace: home-assistant
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: mosquitto-bootstrap
|
||||
namespace: home-assistant
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
name: mosquitto-bootstrap
|
||||
---
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: mosquitto-credentials-bootstrap
|
||||
namespace: home-assistant
|
||||
annotations:
|
||||
# Job pod templates are immutable; force-recreate so image bumps
|
||||
# apply on Flux re-reconcile. Safe: the Job is idempotent (see above).
|
||||
kustomize.toolkit.fluxcd.io/force: enabled
|
||||
spec:
|
||||
backoffLimit: 4
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: mosquitto-bootstrap
|
||||
spec:
|
||||
serviceAccountName: mosquitto-bootstrap
|
||||
restartPolicy: OnFailure
|
||||
containers:
|
||||
- name: bootstrap
|
||||
image: alpine:3.24@sha256:294b683cb724975bec92580e1e685676bd4b50bda910ddb8c51d4cabeaec77e6
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
set -eu
|
||||
apk add --no-cache curl jq >/dev/null
|
||||
|
||||
NS=home-assistant
|
||||
NAME=mosquitto-credentials
|
||||
TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
|
||||
CA=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt
|
||||
API=https://kubernetes.default.svc
|
||||
|
||||
if curl -fsSL --cacert "$CA" -H "Authorization: Bearer $TOKEN" \
|
||||
"$API/api/v1/namespaces/$NS/secrets/$NAME" >/dev/null 2>&1; then
|
||||
echo "$NAME already exists; nothing to do."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
PW=$(tr -dc 'A-Za-z0-9' </dev/urandom | head -c 32)
|
||||
PW_B64=$(printf '%s' "$PW" | base64 | tr -d '\n')
|
||||
|
||||
body=$(jq -nc \
|
||||
--arg name "$NAME" \
|
||||
--arg ns "$NS" \
|
||||
--arg pw "$PW_B64" \
|
||||
'{apiVersion: "v1",
|
||||
kind: "Secret",
|
||||
metadata: {name: $name, namespace: $ns},
|
||||
type: "Opaque",
|
||||
data: {"homeassistant-password": $pw}}')
|
||||
|
||||
curl -fsSL --cacert "$CA" -H "Authorization: Bearer $TOKEN" \
|
||||
-H "Content-Type: application/json" -X POST \
|
||||
--data "$body" \
|
||||
"$API/api/v1/namespaces/$NS/secrets" >/dev/null
|
||||
|
||||
echo "generated $NAME"
|
||||
resources:
|
||||
requests:
|
||||
cpu: 10m
|
||||
memory: 32Mi
|
||||
limits:
|
||||
memory: 64Mi
|
||||
---
|
||||
# Third broker user: `admin`. Full readwrite (same as HA) but kept on
|
||||
# its own credential so a workstation client can hold a password the
|
||||
# in-cluster HA config never sees, and rotating one doesn't affect the
|
||||
# other. Retrieve with:
|
||||
# kubectl -n home-assistant get secret mosquitto-admin-credentials \
|
||||
# -o jsonpath='{.data.password}' | base64 -d
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: mosquitto-admin-credentials-bootstrap
|
||||
namespace: home-assistant
|
||||
annotations:
|
||||
# Job pod templates are immutable; force-recreate so image bumps
|
||||
# apply on Flux re-reconcile. Safe: the Job is idempotent (see above).
|
||||
kustomize.toolkit.fluxcd.io/force: enabled
|
||||
spec:
|
||||
backoffLimit: 4
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: mosquitto-bootstrap
|
||||
spec:
|
||||
serviceAccountName: mosquitto-bootstrap
|
||||
restartPolicy: OnFailure
|
||||
containers:
|
||||
- name: bootstrap
|
||||
image: alpine:3.24@sha256:294b683cb724975bec92580e1e685676bd4b50bda910ddb8c51d4cabeaec77e6
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
set -eu
|
||||
apk add --no-cache curl jq >/dev/null
|
||||
|
||||
NS=home-assistant
|
||||
NAME=mosquitto-admin-credentials
|
||||
TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
|
||||
CA=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt
|
||||
API=https://kubernetes.default.svc
|
||||
|
||||
if curl -fsSL --cacert "$CA" -H "Authorization: Bearer $TOKEN" \
|
||||
"$API/api/v1/namespaces/$NS/secrets/$NAME" >/dev/null 2>&1; then
|
||||
echo "$NAME already exists; nothing to do."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
PW=$(tr -dc 'A-Za-z0-9' </dev/urandom | head -c 32)
|
||||
PW_B64=$(printf '%s' "$PW" | base64 | tr -d '\n')
|
||||
|
||||
body=$(jq -nc \
|
||||
--arg name "$NAME" \
|
||||
--arg ns "$NS" \
|
||||
--arg pw "$PW_B64" \
|
||||
'{apiVersion: "v1",
|
||||
kind: "Secret",
|
||||
metadata: {name: $name, namespace: $ns},
|
||||
type: "Opaque",
|
||||
data: {password: $pw}}')
|
||||
|
||||
curl -fsSL --cacert "$CA" -H "Authorization: Bearer $TOKEN" \
|
||||
-H "Content-Type: application/json" -X POST \
|
||||
--data "$body" \
|
||||
"$API/api/v1/namespaces/$NS/secrets" >/dev/null
|
||||
|
||||
echo "generated $NAME"
|
||||
resources:
|
||||
requests:
|
||||
cpu: 10m
|
||||
memory: 32Mi
|
||||
limits:
|
||||
memory: 64Mi
|
||||
---
|
||||
# Fourth broker user: `sml2mqtt` — the power-meter bridge. Publish-only
|
||||
# under `sml2mqtt/#` (ACL in mosquitto-deployment.yaml). Own credential so
|
||||
# its lifecycle is independent of the others. The sml2mqtt pod reads this
|
||||
# password via its init container and renders it into config.yml.
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: mosquitto-sml2mqtt-credentials-bootstrap
|
||||
namespace: home-assistant
|
||||
annotations:
|
||||
# Job pod templates are immutable; force-recreate so image bumps
|
||||
# apply on Flux re-reconcile. Safe: the Job is idempotent (see above).
|
||||
kustomize.toolkit.fluxcd.io/force: enabled
|
||||
spec:
|
||||
backoffLimit: 4
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: mosquitto-bootstrap
|
||||
spec:
|
||||
serviceAccountName: mosquitto-bootstrap
|
||||
restartPolicy: OnFailure
|
||||
containers:
|
||||
- name: bootstrap
|
||||
image: alpine:3.24@sha256:294b683cb724975bec92580e1e685676bd4b50bda910ddb8c51d4cabeaec77e6
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
set -eu
|
||||
apk add --no-cache curl jq >/dev/null
|
||||
|
||||
NS=home-assistant
|
||||
NAME=mosquitto-sml2mqtt-credentials
|
||||
TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
|
||||
CA=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt
|
||||
API=https://kubernetes.default.svc
|
||||
|
||||
if curl -fsSL --cacert "$CA" -H "Authorization: Bearer $TOKEN" \
|
||||
"$API/api/v1/namespaces/$NS/secrets/$NAME" >/dev/null 2>&1; then
|
||||
echo "$NAME already exists; nothing to do."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
PW=$(tr -dc 'A-Za-z0-9' </dev/urandom | head -c 32)
|
||||
PW_B64=$(printf '%s' "$PW" | base64 | tr -d '\n')
|
||||
|
||||
body=$(jq -nc \
|
||||
--arg name "$NAME" \
|
||||
--arg ns "$NS" \
|
||||
--arg pw "$PW_B64" \
|
||||
'{apiVersion: "v1",
|
||||
kind: "Secret",
|
||||
metadata: {name: $name, namespace: $ns},
|
||||
type: "Opaque",
|
||||
data: {password: $pw}}')
|
||||
|
||||
curl -fsSL --cacert "$CA" -H "Authorization: Bearer $TOKEN" \
|
||||
-H "Content-Type: application/json" -X POST \
|
||||
--data "$body" \
|
||||
"$API/api/v1/namespaces/$NS/secrets" >/dev/null
|
||||
|
||||
echo "generated $NAME"
|
||||
resources:
|
||||
requests:
|
||||
cpu: 10m
|
||||
memory: 32Mi
|
||||
limits:
|
||||
memory: 64Mi
|
||||
---
|
||||
# Fifth broker user: `open3e` — the Viessmann E3 CAN bridge (Vitocal 250-A
|
||||
# + Vitocharge VX3 via open3e). Scoped to `open3e/#` (ACL in
|
||||
# mosquitto-deployment.yaml). Own credential so its lifecycle is
|
||||
# independent of the others. Retrieve with:
|
||||
# kubectl -n home-assistant get secret mosquitto-open3e-credentials \
|
||||
# -o jsonpath='{.data.password}' | base64 -d
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: mosquitto-open3e-credentials-bootstrap
|
||||
namespace: home-assistant
|
||||
annotations:
|
||||
# Job pod templates are immutable; force-recreate so image bumps
|
||||
# apply on Flux re-reconcile. Safe: the Job is idempotent (see above).
|
||||
kustomize.toolkit.fluxcd.io/force: enabled
|
||||
spec:
|
||||
backoffLimit: 4
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: mosquitto-bootstrap
|
||||
spec:
|
||||
serviceAccountName: mosquitto-bootstrap
|
||||
restartPolicy: OnFailure
|
||||
containers:
|
||||
- name: bootstrap
|
||||
image: alpine:3.24@sha256:294b683cb724975bec92580e1e685676bd4b50bda910ddb8c51d4cabeaec77e6
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
set -eu
|
||||
apk add --no-cache curl jq >/dev/null
|
||||
|
||||
NS=home-assistant
|
||||
NAME=mosquitto-open3e-credentials
|
||||
TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
|
||||
CA=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt
|
||||
API=https://kubernetes.default.svc
|
||||
|
||||
if curl -fsSL --cacert "$CA" -H "Authorization: Bearer $TOKEN" \
|
||||
"$API/api/v1/namespaces/$NS/secrets/$NAME" >/dev/null 2>&1; then
|
||||
echo "$NAME already exists; nothing to do."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
PW=$(tr -dc 'A-Za-z0-9' </dev/urandom | head -c 32)
|
||||
PW_B64=$(printf '%s' "$PW" | base64 | tr -d '\n')
|
||||
|
||||
body=$(jq -nc \
|
||||
--arg name "$NAME" \
|
||||
--arg ns "$NS" \
|
||||
--arg pw "$PW_B64" \
|
||||
'{apiVersion: "v1",
|
||||
kind: "Secret",
|
||||
metadata: {name: $name, namespace: $ns},
|
||||
type: "Opaque",
|
||||
data: {password: $pw}}')
|
||||
|
||||
curl -fsSL --cacert "$CA" -H "Authorization: Bearer $TOKEN" \
|
||||
-H "Content-Type: application/json" -X POST \
|
||||
--data "$body" \
|
||||
"$API/api/v1/namespaces/$NS/secrets" >/dev/null
|
||||
|
||||
echo "generated $NAME"
|
||||
resources:
|
||||
requests:
|
||||
cpu: 10m
|
||||
memory: 32Mi
|
||||
limits:
|
||||
memory: 64Mi
|
||||
---
|
||||
# Broker user `zigbee2mqtt` — the Zigbee2MQTT bridge (ZHA replacement). Scoped
|
||||
# to its own `zigbee2mqtt/#` subtree plus `write homeassistant/#` (so it can
|
||||
# publish HA MQTT-discovery configs) and
|
||||
# `read homeassistant/status` (HA's birth/will topic; on `online` Z2M
|
||||
# republishes cached device states, NOT discovery configs — ACL and the full
|
||||
# reasoning in mosquitto-deployment.yaml). Own credential so its lifecycle is
|
||||
# independent of the others. The Z2M init container reads this password and
|
||||
# renders it into /app/data/secret.yaml.
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: mosquitto-zigbee2mqtt-credentials-bootstrap
|
||||
namespace: home-assistant
|
||||
annotations:
|
||||
# Job pod templates are immutable; force-recreate so image bumps
|
||||
# apply on Flux re-reconcile. Safe: the Job is idempotent (see above).
|
||||
kustomize.toolkit.fluxcd.io/force: enabled
|
||||
spec:
|
||||
backoffLimit: 4
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: mosquitto-bootstrap
|
||||
spec:
|
||||
serviceAccountName: mosquitto-bootstrap
|
||||
restartPolicy: OnFailure
|
||||
containers:
|
||||
- name: bootstrap
|
||||
image: alpine:3.24@sha256:294b683cb724975bec92580e1e685676bd4b50bda910ddb8c51d4cabeaec77e6
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
set -eu
|
||||
apk add --no-cache curl jq >/dev/null
|
||||
|
||||
NS=home-assistant
|
||||
NAME=mosquitto-zigbee2mqtt-credentials
|
||||
TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
|
||||
CA=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt
|
||||
API=https://kubernetes.default.svc
|
||||
|
||||
if curl -fsSL --cacert "$CA" -H "Authorization: Bearer $TOKEN" \
|
||||
"$API/api/v1/namespaces/$NS/secrets/$NAME" >/dev/null 2>&1; then
|
||||
echo "$NAME already exists; nothing to do."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
PW=$(tr -dc 'A-Za-z0-9' </dev/urandom | head -c 32)
|
||||
PW_B64=$(printf '%s' "$PW" | base64 | tr -d '\n')
|
||||
|
||||
body=$(jq -nc \
|
||||
--arg name "$NAME" \
|
||||
--arg ns "$NS" \
|
||||
--arg pw "$PW_B64" \
|
||||
'{apiVersion: "v1",
|
||||
kind: "Secret",
|
||||
metadata: {name: $name, namespace: $ns},
|
||||
type: "Opaque",
|
||||
data: {password: $pw}}')
|
||||
|
||||
curl -fsSL --cacert "$CA" -H "Authorization: Bearer $TOKEN" \
|
||||
-H "Content-Type: application/json" -X POST \
|
||||
--data "$body" \
|
||||
"$API/api/v1/namespaces/$NS/secrets" >/dev/null
|
||||
|
||||
echo "generated $NAME"
|
||||
resources:
|
||||
requests:
|
||||
cpu: 10m
|
||||
memory: 32Mi
|
||||
limits:
|
||||
memory: 64Mi
|
||||
@@ -77,18 +77,15 @@ data:
|
||||
|
||||
allow_anonymous false
|
||||
|
||||
# Two account sources side by side (REN-802 step 2, tested on 2.0.22 in
|
||||
# REN-900, document `coexistence`):
|
||||
# Dynamic Security: accounts from the register mqtt-accounts.yaml,
|
||||
# managed live by mqtt-account-controller over $CONTROL.
|
||||
# password_file/acl_file: the legacy users, unchanged until each client
|
||||
# moves to the register (step 3).
|
||||
# Accounts (tested on 2.0.22 in REN-900, document `coexistence`):
|
||||
# Dynamic Security: every client account, from the register
|
||||
# mqtt-accounts.yaml, managed live by mqtt-account-controller over
|
||||
# $CONTROL. Applies to all listeners (per_listener_settings false).
|
||||
# password_file/acl_file: the owner's workstation login `admin` only
|
||||
# (mosquitto-deployment.yaml).
|
||||
# Dynamic Security is asked first. For a username it does not know, and
|
||||
# for a request none of its roles match, it defers to the files. A
|
||||
# register entry with the same name as a legacy user therefore replaces
|
||||
# that user's password, while its acl_file block still applies to
|
||||
# whatever the entry's roles do not cover. Delete the legacy user when
|
||||
# its client moves.
|
||||
# register entry named `admin` therefore replaces the file login.
|
||||
#
|
||||
# The acl_file check of 2.0 allows every SUBSCRIBE and checks only on
|
||||
# delivery, so the Dynamic Security default must deny publishClientReceive.
|
||||
|
||||
@@ -64,67 +64,15 @@ spec:
|
||||
- -c
|
||||
- |
|
||||
set -eu
|
||||
# `admin` is the owner's workstation login over the LoadBalancer
|
||||
# (1883/8883), full readwrite. The only password_file user: the
|
||||
# controller cannot deliver a password account to a Secret, and
|
||||
# the cert listener :8884 is in-cluster only.
|
||||
rm -f /mosquitto/auth/passwd
|
||||
mosquitto_passwd -c -b /mosquitto/auth/passwd homeassistant "$HA_PASSWORD"
|
||||
mosquitto_passwd -b /mosquitto/auth/passwd admin "$ADMIN_PASSWORD"
|
||||
mosquitto_passwd -b /mosquitto/auth/passwd sml2mqtt "$SML2MQTT_PASSWORD"
|
||||
mosquitto_passwd -b /mosquitto/auth/passwd open3e "$OPEN3E_PASSWORD"
|
||||
mosquitto_passwd -b /mosquitto/auth/passwd evcc "$EVCC_PASSWORD"
|
||||
mosquitto_passwd -b /mosquitto/auth/passwd zigbee2mqtt "$ZIGBEE2MQTT_PASSWORD"
|
||||
# ACL: HA keeps full access (subscribes to everything). Shellies
|
||||
# are not legacy users any more: each has its own Dynamic Security
|
||||
# account from mqtt-accounts.yaml (REN-802, REN-1017).
|
||||
# `admin` is a workstation/debugging credential — full
|
||||
# readwrite, kept on its own credential so its password can
|
||||
# be rotated independently of the HA session.
|
||||
# `sml2mqtt` is the power-meter bridge — WRITE-only under its own
|
||||
# `sml2mqtt/#` subtree (it only publishes; HA reads it via the
|
||||
# full-access homeassistant user).
|
||||
# `open3e` is the Viessmann E3 CAN bridge (Vitocal/VX3) —
|
||||
# scoped to its own `open3e/#` subtree: publishes datapoints
|
||||
# and later subscribes to `open3e/cmnd` in listener mode (HA
|
||||
# reads via the full-access homeassistant user).
|
||||
# `evcc` is the (cross-namespace) EV charge controller — reads
|
||||
# `open3e/#` (VX3 grid/PV/battery/SoC datapoints), publishes its
|
||||
# own state under `evcc/#`, and reads the grid price from
|
||||
# `energy/#` (HA republishes input_number.strompreis to
|
||||
# energy/tariff/grid; kept OUTSIDE evcc/# so evcc's own retained-
|
||||
# topic management can't wipe it).
|
||||
mosquitto_passwd -c -b /mosquitto/auth/passwd admin "$ADMIN_PASSWORD"
|
||||
cat > /mosquitto/auth/acl <<'EOF'
|
||||
user homeassistant
|
||||
topic readwrite #
|
||||
|
||||
user admin
|
||||
topic readwrite #
|
||||
|
||||
user sml2mqtt
|
||||
topic write sml2mqtt/#
|
||||
|
||||
user open3e
|
||||
topic readwrite open3e/#
|
||||
|
||||
user evcc
|
||||
topic read open3e/#
|
||||
topic readwrite evcc/#
|
||||
topic read energy/#
|
||||
|
||||
# `zigbee2mqtt` is the Zigbee2MQTT bridge (the ZHA replacement).
|
||||
# Owns its own `zigbee2mqtt/#` subtree; may WRITE `homeassistant/#`
|
||||
# to publish HA MQTT-discovery configs (write-only there, to deny
|
||||
# discovery-tree recon from a compromised bridge); and READs `homeassistant/status`, HA's birth/will topic.
|
||||
#
|
||||
# That read grant does NOT buy a discovery re-publish: on
|
||||
# `online`, Z2M 2.12.1 republishes bridge/state and cached device
|
||||
# states only (lib/extension/homeassistant.ts onMQTTMessage) —
|
||||
# discover() runs solely from start(). The grant is still correct,
|
||||
# because the cached-state republish is what makes HA show current
|
||||
# values right after an HA restart. Restoring discovery after a
|
||||
# BROKER restart is handled by the discovery-guard sidecar in
|
||||
# zigbee2mqtt-deployment.yaml.
|
||||
user zigbee2mqtt
|
||||
topic readwrite zigbee2mqtt/#
|
||||
topic write homeassistant/#
|
||||
topic read homeassistant/status
|
||||
EOF
|
||||
# Dynamic Security start file (REN-802): the controller's seed
|
||||
# if it exists, else the static base file. The seed carries
|
||||
@@ -143,38 +91,11 @@ spec:
|
||||
chmod 0600 /mosquitto/auth/passwd /mosquitto/auth/acl /mosquitto/auth/dynamic-security.json
|
||||
exec mosquitto -c /mosquitto/config/mosquitto.conf
|
||||
env:
|
||||
- name: HA_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: mosquitto-credentials
|
||||
key: homeassistant-password
|
||||
# mosquitto-admin-password.yaml
|
||||
- name: ADMIN_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: mosquitto-admin-credentials
|
||||
key: password
|
||||
- name: SML2MQTT_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: mosquitto-sml2mqtt-credentials
|
||||
key: password
|
||||
- name: OPEN3E_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: mosquitto-open3e-credentials
|
||||
key: password
|
||||
- name: EVCC_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: mosquitto-evcc-credentials
|
||||
key: password
|
||||
# Zigbee2MQTT bridge credential (mosquitto-zigbee2mqtt-credentials-
|
||||
# bootstrap). Hashed into the passwd file here; Z2M reads the same
|
||||
# Secret via its init container to authenticate to the broker.
|
||||
- name: ZIGBEE2MQTT_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: mosquitto-zigbee2mqtt-credentials
|
||||
name: mosquitto-admin-password
|
||||
key: password
|
||||
ports:
|
||||
- name: mqtt
|
||||
@@ -231,12 +152,12 @@ spec:
|
||||
# Service and the probe dials 127.0.0.1; the chain is still checked
|
||||
# against mqtt-ca.
|
||||
#
|
||||
# mosquitto is a single-replica SPOF (HA, Shelly, sml2mqtt, open3e,
|
||||
# evcc). Liveness is deliberately slow to fire — failureThreshold 6
|
||||
# x 30s = 3 min of sustained failure before a restart — so a
|
||||
# transient hiccup never bounces the broker every client depends
|
||||
# on. The startupProbe (tcpSocket) suspends both while the
|
||||
# container builds the passwd/acl files and mosquitto binds :1883.
|
||||
# mosquitto is a single-replica SPOF (HA, Shelly, Zigbee2MQTT,
|
||||
# edge-1, evcc). Liveness is deliberately slow to fire —
|
||||
# failureThreshold 6 x 30s = 3 min of sustained failure before a
|
||||
# restart — so a transient hiccup never bounces the broker every
|
||||
# client depends on. The startupProbe (tcpSocket) suspends both while
|
||||
# the container prepares /mosquitto/auth and mosquitto binds :1883.
|
||||
startupProbe:
|
||||
tcpSocket:
|
||||
port: mqtt
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
apiVersion: external-secrets.io/v1
|
||||
kind: ExternalSecret
|
||||
metadata:
|
||||
name: mosquitto-evcc-credentials
|
||||
namespace: home-assistant
|
||||
spec:
|
||||
refreshInterval: 1h
|
||||
secretStoreRef:
|
||||
kind: ClusterSecretStore
|
||||
name: openbao
|
||||
target:
|
||||
name: mosquitto-evcc-credentials # keeps the old Secret's name — consumers unchanged
|
||||
dataFrom:
|
||||
- extract:
|
||||
key: apps/home-assistant/mosquitto-evcc-credentials
|
||||
@@ -1,36 +0,0 @@
|
||||
# Projects the mosquitto `health` broker credential from OpenBao into the Secret
|
||||
# the broker already consumes. FIRST of the eight broker users to move off the
|
||||
# bootstrap Jobs and onto Class-A rotation (see
|
||||
# PROPOSAL-mosquitto-credential-rotation.md (PR #453 — not yet merged; this
|
||||
# file lands with it)); the rotator lives at
|
||||
# kubernetes/infrastructure/openbao/rotation/mosquitto-health.yaml.
|
||||
#
|
||||
# Secret name and key are UNCHANGED (`password`), so mosquitto-deployment.yaml's
|
||||
# secretKeyRef and the exec probes that read $HEALTH_PASSWORD need no edit.
|
||||
#
|
||||
# refreshInterval is 10m rather than the 1h used by mosquitto-evcc-credentials:
|
||||
# a rotation only lands once ESO re-reads, so 1h would mean up to an hour between
|
||||
# the rotator running and the broker actually using the new password, with the
|
||||
# old one still valid in the meantime. 10m keeps that window short without
|
||||
# polling OpenBao pointlessly hard.
|
||||
#
|
||||
# ⚠️ OWNERSHIP: creationPolicy is implicitly Owner, so ESO sets an ownerReference
|
||||
# on the Secret. Deleting this ExternalSecret therefore DELETES the live Secret
|
||||
# and with it the broker's probe credential — the bootstrap Job it replaces had
|
||||
# no such coupling. To detach without destroying, set creationPolicy: Orphan
|
||||
# before removing it.
|
||||
apiVersion: external-secrets.io/v1
|
||||
kind: ExternalSecret
|
||||
metadata:
|
||||
name: mosquitto-health-credentials
|
||||
namespace: home-assistant
|
||||
spec:
|
||||
refreshInterval: 10m
|
||||
secretStoreRef:
|
||||
kind: ClusterSecretStore
|
||||
name: openbao
|
||||
target:
|
||||
name: mosquitto-health-credentials
|
||||
dataFrom:
|
||||
- extract:
|
||||
key: apps/home-assistant/mosquitto-health-credentials
|
||||
@@ -13,6 +13,7 @@ metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: mosquitto
|
||||
lb-pool: bgp
|
||||
dns.renner.uno/internal: "true"
|
||||
annotations:
|
||||
lbipam.cilium.io/ips: "10.2.99.81,fd99::81"
|
||||
# Publish an internal A record to UniFi DNS so workstations on the
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
# mqtt-accounts.yaml, every INTERVAL (2m).
|
||||
#
|
||||
# Manages the production broker `mosquitto` over its mTLS listener :8884
|
||||
# (REN-802 step 2, REN-900). The legacy users in that broker's password_file
|
||||
# are not Dynamic Security clients, so the controller never sees or touches
|
||||
# them.
|
||||
# (REN-802 step 2, REN-900). The broker's one password_file login, `admin`
|
||||
# (mosquitto-deployment.yaml), is not a Dynamic Security client, so the
|
||||
# controller never sees or touches it.
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
|
||||
@@ -7,10 +7,13 @@
|
||||
# configMapGenerator in kustomization.yaml). An empty list is refused, so it
|
||||
# never revokes everyone.
|
||||
#
|
||||
# The controller manages the production broker `mosquitto` (REN-900). Its
|
||||
# legacy users (password_file in mosquitto-deployment.yaml) are not listed
|
||||
# here; each moves here with its client (REN-802 step 3). `test-cert` is the
|
||||
# certificate test account from REN-888.
|
||||
# The controller manages the production broker `mosquitto` (REN-900). Every
|
||||
# client account is listed here except `admin`, the owner's workstation login
|
||||
# in the broker's password_file (mosquitto-deployment.yaml): a password
|
||||
# account can only be delivered to shelly-manager or an esp32 API, and a cert
|
||||
# account only works on the in-cluster listener :8884. An entry named `admin`
|
||||
# would replace that login. `test-cert` is the certificate test account from
|
||||
# REN-888.
|
||||
#
|
||||
# A cert account needs its Secret `mqtt-<name>-tls` added to the
|
||||
# `mqtt-account-controller-secrets-<namespace>` Role in
|
||||
@@ -20,38 +23,31 @@
|
||||
deliver: {namespace: home-assistant}
|
||||
acl: ["readwrite test/cert/#"]
|
||||
# The broker's own liveness/readiness probe (mosquitto-deployment.yaml).
|
||||
# Not named `health`: a Dynamic Security client of that name would shadow the
|
||||
# legacy password user while the old broker pod still probes with it.
|
||||
- name: mosquitto-probe
|
||||
auth: cert
|
||||
deliver: {namespace: home-assistant}
|
||||
acl: ["readwrite health/#"]
|
||||
# Zigbee2MQTT and its two sidecars (discovery-guard, interview-watch), one
|
||||
# certificate for the pod. Same ACL as the legacy user `zigbee2mqtt`; not
|
||||
# named like it, so this entry cannot shadow the password login of a running
|
||||
# Z2M (REN-953).
|
||||
# certificate for the pod (REN-953).
|
||||
- name: zigbee2mqtt-bridge
|
||||
auth: cert
|
||||
deliver: {namespace: home-assistant}
|
||||
acl: ["readwrite zigbee2mqtt/#", "write homeassistant/#", "read homeassistant/status"]
|
||||
# evcc (evcc namespace). Same ACL as the legacy user `evcc`, different name
|
||||
# so it cannot shadow the running password login (REN-953). evcc takes the
|
||||
# certificate PEMs by env (EVCC_MQTT_*), see apps/evcc/deployment.yaml.
|
||||
# evcc (evcc namespace, REN-953). evcc takes the certificate PEMs by env
|
||||
# (EVCC_MQTT_*), see apps/evcc/deployment.yaml.
|
||||
- name: evcc-client
|
||||
auth: cert
|
||||
deliver: {namespace: evcc}
|
||||
acl: ["read open3e/#", "readwrite evcc/#", "read energy/#"]
|
||||
# Home Assistant, via the ghostunnel sidecar `mqtt-tls` in its pod (HA keeps
|
||||
# client certificates only as uploaded PEMs in its config entry, so a renewal
|
||||
# could not reach it without a reconfigure). Same ACL as the legacy user
|
||||
# `homeassistant`; not named like it, so it cannot shadow that login (REN-953).
|
||||
# could not reach it without a reconfigure, REN-953).
|
||||
- name: home-assistant
|
||||
auth: cert
|
||||
deliver: {namespace: home-assistant}
|
||||
acl: ["readwrite #"]
|
||||
# edge-1's local mosquitto bridge (REN-1307): one bridge for open3e/e3oncan
|
||||
# and sml2mqtt, replacing the legacy password users `open3e` and `sml2mqtt`
|
||||
# (different name, so it cannot shadow their logins). The controller pushes
|
||||
# edge-1's local mosquitto bridge (REN-1307): one bridge for open3e/e3oncan.
|
||||
# The controller pushes
|
||||
# the password to edge-mqtt-cred on edge-1 (ansible role mqtt-bridge) over
|
||||
# HTTPS with its own client certificate, and pins edge-1's self-generated
|
||||
# server certificate on first contact (key edge-1.pin in mqtt-account-hashes;
|
||||
|
||||
@@ -3,21 +3,24 @@
|
||||
#
|
||||
# code-server runs with --auth=none as root and mounts the entire /config
|
||||
# (plaintext secrets.yaml, .storage, the git PAT in the PVC remote URL), so the
|
||||
# Authentik gate (ingress class authentik-gate) is the only thing in front of
|
||||
# Authentik gate (the authentik-gate Middleware) is the only thing in front of
|
||||
# it: Authentik SSO login, Home Assistant Config Editors only.
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: home-assistant-vscode
|
||||
namespace: home-assistant
|
||||
labels:
|
||||
dns.renner.uno/internal: "true"
|
||||
annotations:
|
||||
traefik.ingress.kubernetes.io/router.middlewares: authentik-gate@kubernetescrd
|
||||
cert-manager.io/cluster-issuer: letsencrypt-cluster
|
||||
auth.renner.uno/group: Home Assistant Config Editors
|
||||
# code-server's manifest and service worker are fetched without
|
||||
# credentials. Version-specific: re-check after a code-server bump.
|
||||
auth.renner.uno/skip-path: ^/(_static/|manifest\.json|.*\.webmanifest|.*serviceWorker\.js).*
|
||||
spec:
|
||||
ingressClassName: authentik-gate
|
||||
ingressClassName: traefik
|
||||
rules:
|
||||
- host: vscode.home.renner.uno
|
||||
http:
|
||||
|
||||
@@ -3,18 +3,21 @@ kind: Ingress
|
||||
metadata:
|
||||
name: zigbee2mqtt
|
||||
namespace: home-assistant
|
||||
labels:
|
||||
dns.renner.uno/internal: "true"
|
||||
annotations:
|
||||
traefik.ingress.kubernetes.io/router.middlewares: authentik-gate@kubernetescrd
|
||||
cert-manager.io/cluster-issuer: letsencrypt-cluster
|
||||
auth.renner.uno/group: Zigbee2MQTT Managers
|
||||
spec:
|
||||
# The Z2M frontend has no auth of its own: anyone reaching it can rename
|
||||
# devices, toggle permit_join, trigger OTA, and control the whole Zigbee
|
||||
# network, so the Authentik gate (ingress class authentik-gate) is the only
|
||||
# network, so the Authentik gate (the authentik-gate Middleware) is the only
|
||||
# thing in front of it: Authentik SSO login, Zigbee2MQTT Managers only.
|
||||
#
|
||||
# WebSocket: the frontend streams live device state / logs over a websocket;
|
||||
# Traefik's websecure entrypoint passes it through.
|
||||
ingressClassName: authentik-gate
|
||||
ingressClassName: traefik
|
||||
rules:
|
||||
- host: zigbee2mqtt.home.renner.uno
|
||||
http:
|
||||
|
||||
@@ -50,13 +50,13 @@ release it before Z2M connects (step 3).
|
||||
Confirm the standing pieces are in place (nothing is running yet):
|
||||
|
||||
```
|
||||
kubectl -n home-assistant get secret mosquitto-zigbee2mqtt-credentials # exists (bootstrap Job ran)
|
||||
kubectl -n home-assistant get secret mqtt-zigbee2mqtt-bridge-tls # exists (register account zigbee2mqtt-bridge)
|
||||
kubectl -n home-assistant get externalsecret zigbee2mqtt-coordinator-backup # SecretSyncedError / NotReady — EXPECTED
|
||||
kubectl -n home-assistant get deploy zigbee2mqtt # 0/0 — EXPECTED
|
||||
```
|
||||
|
||||
The `mosquitto` pod will have rolled to pick up the new `zigbee2mqtt` passwd/ACL
|
||||
entry. Verify the broker still serves HA (it will — the change is additive).
|
||||
Z2M logs in to the broker by certificate on `:8884` as the register account
|
||||
`zigbee2mqtt-bridge` (`mqtt-accounts.yaml`).
|
||||
|
||||
## Step 1 — export the Open Coordinator Backup (non-disruptive)
|
||||
|
||||
|
||||
@@ -104,6 +104,8 @@ kind: Ingress
|
||||
metadata:
|
||||
name: ical-proxy
|
||||
namespace: apps
|
||||
labels:
|
||||
dns.renner.uno/internal: "true"
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: letsencrypt-cluster
|
||||
spec:
|
||||
|
||||
@@ -4,9 +4,10 @@ metadata:
|
||||
name: immich
|
||||
namespace: immich
|
||||
labels:
|
||||
# Registered publicly (Cloudflare wildcard -> NetBird proxy); the UDM
|
||||
# external-dns instance skips it, LAN reaches it via the hairpin NAT.
|
||||
# Registered publicly (explicit CNAME -> NetBird proxy). No
|
||||
# dns.renner.uno/internal label: external-dns-unifi writes no UDM record.
|
||||
dns.renner.uno/public: "true"
|
||||
netbird.renner.uno/public: "true"
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: letsencrypt-cluster
|
||||
spec:
|
||||
@@ -27,9 +28,8 @@ spec:
|
||||
hosts:
|
||||
- immich.renner.uno
|
||||
---
|
||||
# photos.renner.uno is LAN-registered (no proxy tunnel), so it lives on its
|
||||
# own unlabeled Ingress: the dns.renner.uno/public label-filter is
|
||||
# per-resource, and this name must keep its UDM record. It was the LXC alias
|
||||
# photos.renner.uno is LAN-only (UDM record, no proxy), so it lives on its
|
||||
# own Ingress: DNS label filters are per-resource. It was the LXC alias
|
||||
# served by Caddy; preserved so external-dns-unifi can take over once the
|
||||
# tofu CNAME on lxc_225 is removed.
|
||||
apiVersion: networking.k8s.io/v1
|
||||
@@ -37,6 +37,8 @@ kind: Ingress
|
||||
metadata:
|
||||
name: immich-photos
|
||||
namespace: immich
|
||||
labels:
|
||||
dns.renner.uno/internal: "true"
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: letsencrypt-cluster
|
||||
spec:
|
||||
|
||||
@@ -23,7 +23,7 @@ spec:
|
||||
retryInterval: 60
|
||||
maxRetries: 1
|
||||
dns:
|
||||
# cluster services have no own record; they resolve through the *.renner.uno wildcard
|
||||
# public CNAME to the NetBird proxy, created by external-dns (dns.renner.uno/public)
|
||||
hostname: immich.renner.uno
|
||||
resolveType: CNAME
|
||||
resolveServer: "2606:4700:4700::1111,1.1.1.1"
|
||||
|
||||
@@ -30,7 +30,7 @@ spec:
|
||||
type: RuntimeDefault
|
||||
containers:
|
||||
- name: controller
|
||||
image: gitea.renner.uno/gitea_admin/kuma-sync:2026-10-21-0756 # {"$imagepolicy": "flux-system:kuma-sync"}
|
||||
image: gitea.renner.uno/gitea_admin/kuma-sync:2026-10-25-1459 # {"$imagepolicy": "flux-system:kuma-sync"}
|
||||
env:
|
||||
- name: KUMA_URL
|
||||
value: https://kuma.renner.uno
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
# llm.renner.uno — the chat WebUI, public and behind an Authentik gate
|
||||
# (ingress class authentik-gate, kubernetes/apps/authentik/gate-sync.yaml).
|
||||
# (the authentik-gate Middleware, kubernetes/apps/authentik/gate.yaml).
|
||||
#
|
||||
# The gate is the entire access control here: llama-server has no
|
||||
# authentication of its own and serves a full OpenAI-compatible API on the same
|
||||
@@ -8,24 +8,25 @@
|
||||
#
|
||||
# In-cluster consumers — Home Assistant, Paperless, CI — address
|
||||
# llama-server.ai.svc.cluster.local:8080 directly and never pass through
|
||||
# Traefik or the outpost.
|
||||
# Traefik or Authentik.
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: llama-server
|
||||
namespace: ai
|
||||
labels:
|
||||
# Public: Cloudflare wildcard → tunnel → NetBird proxy → Traefik. The UDM
|
||||
# external-dns instance skips anything carrying this, and LAN clients reach
|
||||
# the same hostname through the hairpin NAT.
|
||||
# Public: Cloudflare CNAME → NetBird proxy → Traefik. No
|
||||
# dns.renner.uno/internal label: external-dns-unifi writes no UDM record.
|
||||
dns.renner.uno/public: "true"
|
||||
netbird.renner.uno/public: "true"
|
||||
annotations:
|
||||
traefik.ingress.kubernetes.io/router.middlewares: authentik-gate@kubernetescrd
|
||||
cert-manager.io/cluster-issuer: letsencrypt-cluster
|
||||
# Manifest and service worker are fetched without credentials; neither
|
||||
# serves authenticated content.
|
||||
auth.renner.uno/skip-path: ^/(manifest\.webmanifest|sw\.js)$
|
||||
spec:
|
||||
ingressClassName: authentik-gate
|
||||
ingressClassName: traefik
|
||||
tls:
|
||||
- hosts:
|
||||
- llm.renner.uno
|
||||
|
||||
@@ -23,7 +23,7 @@ spec:
|
||||
retryInterval: 60
|
||||
maxRetries: 1
|
||||
dns:
|
||||
# cluster services have no own record; they resolve through the *.renner.uno wildcard
|
||||
# public CNAME to the NetBird proxy, created by external-dns (dns.renner.uno/public)
|
||||
hostname: llm.renner.uno
|
||||
resolveType: CNAME
|
||||
resolveServer: "2606:4700:4700::1111,1.1.1.1"
|
||||
|
||||
@@ -35,6 +35,8 @@ kind: Ingress
|
||||
metadata:
|
||||
name: wiki-embed
|
||||
namespace: ai
|
||||
labels:
|
||||
dns.renner.uno/internal: "true"
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: letsencrypt-cluster
|
||||
traefik.ingress.kubernetes.io/router.middlewares: ai-wiki-embed-basic-auth@kubernetescrd
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
# Public (REN-663): each Ingress carries dns.renner.uno/public, so
|
||||
# netbird-service-sync publishes its host through the NetBird proxy
|
||||
# (Cloudflare wildcard -> proxy.renner.uno -> TLS passthrough to Traefik) and
|
||||
# external-dns-unifi skips it; LAN clients follow the public answer and the UDM
|
||||
# hairpins back in. Same path as audiobooks/immich. Federation stays off.
|
||||
# (explicit Cloudflare CNAME -> proxy.renner.uno -> TLS passthrough to Traefik)
|
||||
# and there is no dns.renner.uno/internal label, so external-dns-unifi writes
|
||||
# no UDM record; LAN clients follow the public answer and the UDM hairpins
|
||||
# back in. Same path as audiobooks/immich. Federation stays off.
|
||||
#
|
||||
# Synapse: only the client-facing paths. /_synapse/admin stays off the
|
||||
# Ingress (in-cluster only); /_matrix/federation and /_matrix/key are not
|
||||
@@ -13,9 +14,10 @@ metadata:
|
||||
name: synapse
|
||||
namespace: matrix
|
||||
labels:
|
||||
# Registered publicly (Cloudflare wildcard -> NetBird proxy); the UDM
|
||||
# external-dns instance skips it, LAN reaches it via the hairpin NAT.
|
||||
# Registered publicly (explicit CNAME -> NetBird proxy). No
|
||||
# dns.renner.uno/internal label: external-dns-unifi writes no UDM record.
|
||||
dns.renner.uno/public: "true"
|
||||
netbird.renner.uno/public: "true"
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: letsencrypt-cluster
|
||||
spec:
|
||||
@@ -122,9 +124,10 @@ metadata:
|
||||
name: element-web
|
||||
namespace: matrix
|
||||
labels:
|
||||
# Registered publicly (Cloudflare wildcard -> NetBird proxy); the UDM
|
||||
# external-dns instance skips it, LAN reaches it via the hairpin NAT.
|
||||
# Registered publicly (explicit CNAME -> NetBird proxy). No
|
||||
# dns.renner.uno/internal label: external-dns-unifi writes no UDM record.
|
||||
dns.renner.uno/public: "true"
|
||||
netbird.renner.uno/public: "true"
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: letsencrypt-cluster
|
||||
spec:
|
||||
@@ -152,9 +155,10 @@ metadata:
|
||||
name: mas
|
||||
namespace: matrix
|
||||
labels:
|
||||
# Registered publicly (Cloudflare wildcard -> NetBird proxy); the UDM
|
||||
# external-dns instance skips it, LAN reaches it via the hairpin NAT.
|
||||
# Registered publicly (explicit CNAME -> NetBird proxy). No
|
||||
# dns.renner.uno/internal label: external-dns-unifi writes no UDM record.
|
||||
dns.renner.uno/public: "true"
|
||||
netbird.renner.uno/public: "true"
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: letsencrypt-cluster
|
||||
spec:
|
||||
|
||||
@@ -23,7 +23,7 @@ spec:
|
||||
retryInterval: 60
|
||||
maxRetries: 1
|
||||
dns:
|
||||
# cluster services have no own record; they resolve through the *.renner.uno wildcard
|
||||
# public CNAME to the NetBird proxy, created by external-dns (dns.renner.uno/public)
|
||||
hostname: matrix.renner.uno
|
||||
resolveType: CNAME
|
||||
resolveServer: "2606:4700:4700::1111,1.1.1.1"
|
||||
@@ -136,7 +136,7 @@ spec:
|
||||
retryInterval: 60
|
||||
maxRetries: 1
|
||||
dns:
|
||||
# cluster services have no own record; they resolve through the *.renner.uno wildcard
|
||||
# public CNAME to the NetBird proxy, created by external-dns (dns.renner.uno/public)
|
||||
hostname: account.matrix.renner.uno
|
||||
resolveType: CNAME
|
||||
resolveServer: "2606:4700:4700::1111,1.1.1.1"
|
||||
@@ -202,7 +202,7 @@ spec:
|
||||
retryInterval: 60
|
||||
maxRetries: 1
|
||||
dns:
|
||||
# cluster services have no own record; they resolve through the *.renner.uno wildcard
|
||||
# public CNAME to the NetBird proxy, created by external-dns (dns.renner.uno/public)
|
||||
hostname: element.renner.uno
|
||||
resolveType: CNAME
|
||||
resolveServer: "2606:4700:4700::1111,1.1.1.1"
|
||||
@@ -289,7 +289,7 @@ spec:
|
||||
retryInterval: 60
|
||||
maxRetries: 1
|
||||
dns:
|
||||
# cluster services have no own record; they resolve through the *.renner.uno wildcard
|
||||
# public CNAME to the NetBird proxy, created by external-dns (dns.renner.uno/public)
|
||||
hostname: rtc.matrix.renner.uno
|
||||
resolveType: CNAME
|
||||
resolveServer: "2606:4700:4700::1111,1.1.1.1"
|
||||
@@ -354,7 +354,7 @@ spec:
|
||||
retryInterval: 60
|
||||
maxRetries: 1
|
||||
dns:
|
||||
# cluster services have no own record; they resolve through the *.renner.uno wildcard
|
||||
# public CNAME to the NetBird proxy, created by external-dns (dns.renner.uno/public)
|
||||
hostname: turn.matrix.renner.uno
|
||||
resolveType: CNAME
|
||||
resolveServer: "2606:4700:4700::1111,1.1.1.1"
|
||||
|
||||
@@ -317,6 +317,7 @@ metadata:
|
||||
namespace: matrix
|
||||
labels:
|
||||
dns.renner.uno/public: "true"
|
||||
netbird.renner.uno/public: "true"
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: letsencrypt-cluster
|
||||
traefik.ingress.kubernetes.io/router.middlewares: matrix-lk-jwt-strip@kubernetescrd
|
||||
@@ -369,6 +370,7 @@ metadata:
|
||||
namespace: matrix
|
||||
labels:
|
||||
dns.renner.uno/public: "true"
|
||||
netbird.renner.uno/public: "true"
|
||||
annotations:
|
||||
traefik.ingress.kubernetes.io/router.entrypoints: web
|
||||
spec:
|
||||
|
||||
@@ -27,7 +27,7 @@ spec:
|
||||
- https://home.renner.uno
|
||||
# prometheus.renner.uno and alerts.renner.uno are Authentik-gated
|
||||
# (PR #147 / #146). These EXTERNAL probes now measure the full
|
||||
# gated path — DNS, TLS, Traefik, the gate outpost — following the
|
||||
# gated path — DNS, TLS, Traefik, Authentik forward auth — following the
|
||||
# 302 to the Authentik login (200). They are REACHABILITY checks,
|
||||
# not app health: with the gate up, they stay green even if the app
|
||||
# behind it is dead (the probe never reaches the app). Real app
|
||||
@@ -98,7 +98,7 @@ spec:
|
||||
# rule as the block above (monitoring-vantage-point-rule), but these
|
||||
# are the first targets here that leave the monitoring namespace.
|
||||
#
|
||||
# Both sit entirely behind an Authentik gate outpost (ingress class
|
||||
# Both sit entirely behind Authentik forward auth (ingress class
|
||||
# authentik-gate; ../navidrome/ingress.yaml, ../navidrome/lidarr.yaml) — so an
|
||||
# EXTERNAL probe of either name measures the gate, not the app, and
|
||||
# stays green while the app behind
|
||||
@@ -219,7 +219,7 @@ spec:
|
||||
# (monitoring-vantage-point-rule); the blind spot it closes is the one
|
||||
# gatus already documents in its Web Service 11 comment
|
||||
# (../gatus/configmap.yaml#gatus-endpoints) — through the
|
||||
# gate outpost EVERY path, /api/ included,
|
||||
# gate EVERY path, /api/ included,
|
||||
# answers 302 to an unauthenticated caller, so no external probe of
|
||||
# paperless.renner.uno can tell a live app from a live gate. That
|
||||
# external signal is still wanted, and REN-2 adds it from UptimeRobot;
|
||||
@@ -268,7 +268,7 @@ spec:
|
||||
# anchor: shelly-manager-app-health
|
||||
# APP-HEALTH probe for shelly-manager (REN-531/REN-533). Same rule as
|
||||
# the blocks above (monitoring-vantage-point-rule): shelly.renner.uno
|
||||
# sits behind a gate outpost, so only the in-cluster
|
||||
# sits behind an Authentik gate, so only the in-cluster
|
||||
# Service can tell a dead app from a live gate.
|
||||
#
|
||||
# /health is unauthenticated and answers a plain 200 — not a 3xx —
|
||||
|
||||
@@ -42,7 +42,7 @@ spec:
|
||||
description: >-
|
||||
The endpoint is not answering as expected. For the Authentik-gated
|
||||
hostnames this is a reachability check covering DNS, TLS, Traefik
|
||||
and the gate outpost — it says nothing about the app behind the
|
||||
and Authentik forward auth — it says nothing about the app behind the
|
||||
gate, which the internal /-/healthy probes cover separately.
|
||||
labels:
|
||||
severity: warning
|
||||
|
||||
@@ -25,8 +25,8 @@ spec:
|
||||
summary: "{{ $labels.dns_name }} no longer resolves to its LAN address"
|
||||
description: >-
|
||||
The UDM stopped answering for a name external-dns publishes from
|
||||
a LoadBalancer Service, or answered with the public
|
||||
*.renner.uno wildcard instead of the record. Clients that use
|
||||
a LoadBalancer Service, or answered without the
|
||||
record (no answer, or a public CNAME). Clients that use
|
||||
the name rather than the address lose the service while
|
||||
everything in the cluster stays healthy — nothing else in the
|
||||
stack reports this. Check the external-dns alerts first, then
|
||||
|
||||
@@ -82,9 +82,9 @@ spec:
|
||||
#
|
||||
# The pod regex is the Deployment's name shape
|
||||
# (mosquitto-<replicaset hash>-<suffix>) and not `mosquitto-.*` on
|
||||
# purpose: mosquitto-bootstrap.yaml runs six Jobs named
|
||||
# mosquitto-*-credentials-bootstrap, and a bootstrap pod that is
|
||||
# briefly Ready must not hide a broker that is down.
|
||||
# purpose: other pods in the namespace start with `mosquitto-`
|
||||
# (mosquitto-dynsec-test), and a Ready one must not hide a broker
|
||||
# that is down.
|
||||
expr: |
|
||||
absent(kube_pod_status_ready{namespace="home-assistant", pod=~"mosquitto-[a-z0-9]{6,10}-[a-z0-9]{5}", condition="true"} == 1)
|
||||
for: 5m
|
||||
|
||||
@@ -31,8 +31,9 @@ spec:
|
||||
{{ $value | humanizePercentage }} of probes in the last 10m got
|
||||
the Ingress address for {{ $labels.dns_name }} ({{ $labels.record }})
|
||||
from k8s-gateway. Pods then resolve Ingress names through the UDM
|
||||
and the public wildcard (CNAME proxy.renner.uno) and leave the
|
||||
cluster. Check the rendered Corefile in the k8s-gateway ConfigMap
|
||||
and the public zone (CNAME proxy.renner.uno for public hosts)
|
||||
and leave the cluster. Check the rendered Corefile in the
|
||||
k8s-gateway ConfigMap
|
||||
(kube-system) for the renner.uno zone, the k8s-gateway logs, and
|
||||
whether the Traefik VIP in infrastructure/traefik/helmrelease.yaml
|
||||
still matches the dns_k8s_gateway_auth_* modules in
|
||||
|
||||
@@ -137,13 +137,13 @@ tests:
|
||||
exp_alerts: []
|
||||
|
||||
# --- MosquittoDown ------------------------------------------------------
|
||||
# The broker goes not-Ready at t=10m while a credentials-bootstrap Job pod is
|
||||
# Ready. The Job pod must not mask the broker.
|
||||
# The broker goes not-Ready at t=10m while the mosquitto-dynsec-test pod is
|
||||
# Ready. That pod must not mask the broker.
|
||||
- interval: 1m
|
||||
input_series:
|
||||
- series: 'kube_pod_status_ready{namespace="home-assistant",pod="mosquitto-7f8b9c6d5-x2k9q",condition="true"}'
|
||||
values: '1x9 0x20'
|
||||
- series: 'kube_pod_status_ready{namespace="home-assistant",pod="mosquitto-credentials-bootstrap-q7w2e",condition="true"}'
|
||||
- series: 'kube_pod_status_ready{namespace="home-assistant",pod="mosquitto-dynsec-test-6d9f8b7c5-r4t8w",condition="true"}'
|
||||
values: '1x30'
|
||||
alert_rule_test:
|
||||
- eval_time: 14m
|
||||
|
||||
@@ -30,7 +30,7 @@ tests:
|
||||
record: A
|
||||
exp_annotations:
|
||||
summary: "k8s-gateway does not answer auth.renner.uno A with the Traefik VIP"
|
||||
description: "20% of probes in the last 10m got the Ingress address for auth.renner.uno (A) from k8s-gateway. Pods then resolve Ingress names through the UDM and the public wildcard (CNAME proxy.renner.uno) and leave the cluster. Check the rendered Corefile in the k8s-gateway ConfigMap (kube-system) for the renner.uno zone, the k8s-gateway logs, and whether the Traefik VIP in infrastructure/traefik/helmrelease.yaml still matches the dns_k8s_gateway_auth_* modules in apps/monitoring/helmrelease-blackbox-exporter.yaml. It also fails when the auth.renner.uno Ingress (authentik) is gone."
|
||||
description: "20% of probes in the last 10m got the Ingress address for auth.renner.uno (A) from k8s-gateway. Pods then resolve Ingress names through the UDM and the public zone (CNAME proxy.renner.uno for public hosts) and leave the cluster. Check the rendered Corefile in the k8s-gateway ConfigMap (kube-system) for the renner.uno zone, the k8s-gateway logs, and whether the Traefik VIP in infrastructure/traefik/helmrelease.yaml still matches the dns_k8s_gateway_auth_* modules in apps/monitoring/helmrelease-blackbox-exporter.yaml. It also fails when the auth.renner.uno Ingress (authentik) is gone."
|
||||
- eval_time: 17m
|
||||
alertname: K8sGatewayProbesAbsent
|
||||
exp_alerts: []
|
||||
@@ -53,7 +53,7 @@ tests:
|
||||
record: AAAA
|
||||
exp_annotations:
|
||||
summary: "k8s-gateway does not answer auth.renner.uno AAAA with the Traefik VIP"
|
||||
description: "50% of probes in the last 10m got the Ingress address for auth.renner.uno (AAAA) from k8s-gateway. Pods then resolve Ingress names through the UDM and the public wildcard (CNAME proxy.renner.uno) and leave the cluster. Check the rendered Corefile in the k8s-gateway ConfigMap (kube-system) for the renner.uno zone, the k8s-gateway logs, and whether the Traefik VIP in infrastructure/traefik/helmrelease.yaml still matches the dns_k8s_gateway_auth_* modules in apps/monitoring/helmrelease-blackbox-exporter.yaml. It also fails when the auth.renner.uno Ingress (authentik) is gone."
|
||||
description: "50% of probes in the last 10m got the Ingress address for auth.renner.uno (AAAA) from k8s-gateway. Pods then resolve Ingress names through the UDM and the public zone (CNAME proxy.renner.uno for public hosts) and leave the cluster. Check the rendered Corefile in the k8s-gateway ConfigMap (kube-system) for the renner.uno zone, the k8s-gateway logs, and whether the Traefik VIP in infrastructure/traefik/helmrelease.yaml still matches the dns_k8s_gateway_auth_* modules in apps/monitoring/helmrelease-blackbox-exporter.yaml. It also fails when the auth.renner.uno Ingress (authentik) is gone."
|
||||
|
||||
# Two consecutive failures in an otherwise healthy hour stay silent
|
||||
# (average exactly 0.8).
|
||||
|
||||
@@ -97,7 +97,7 @@ tests:
|
||||
instance: https://other.renner.uno
|
||||
exp_annotations:
|
||||
summary: "Blackbox probe of https://other.renner.uno has been failing for 10 minutes"
|
||||
description: "The endpoint is not answering as expected. For the Authentik-gated hostnames this is a reachability check covering DNS, TLS, Traefik and the gate outpost — it says nothing about the app behind the gate, which the internal /-/healthy probes cover separately."
|
||||
description: "The endpoint is not answering as expected. For the Authentik-gated hostnames this is a reachability check covering DNS, TLS, Traefik and Authentik forward auth — it says nothing about the app behind the gate, which the internal /-/healthy probes cover separately."
|
||||
|
||||
# Healthy probe stays silent.
|
||||
- interval: 1m
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
# alerts.renner.uno — Alertmanager. Its v2 API is writable (POST
|
||||
# /api/v2/silences can suppress all alerting) and it has no auth of its own, so
|
||||
# the Authentik gate (ingress class authentik-gate) is the only thing in front
|
||||
# the Authentik gate (the authentik-gate Middleware) is the only thing in front
|
||||
# of it: Monitoring Access only. Replaces the chart-generated Ingress
|
||||
# (alertmanager.ingress.enabled=false in helmrelease-prometheus.yaml).
|
||||
apiVersion: networking.k8s.io/v1
|
||||
@@ -9,11 +9,14 @@ kind: Ingress
|
||||
metadata:
|
||||
name: alertmanager
|
||||
namespace: monitoring
|
||||
labels:
|
||||
dns.renner.uno/internal: "true"
|
||||
annotations:
|
||||
traefik.ingress.kubernetes.io/router.middlewares: authentik-gate@kubernetescrd
|
||||
cert-manager.io/cluster-issuer: letsencrypt-cluster
|
||||
auth.renner.uno/group: Monitoring Access
|
||||
spec:
|
||||
ingressClassName: authentik-gate
|
||||
ingressClassName: traefik
|
||||
rules:
|
||||
- host: alerts.renner.uno
|
||||
http:
|
||||
|
||||
@@ -229,6 +229,7 @@ metadata:
|
||||
namespace: monitoring
|
||||
labels:
|
||||
lb-pool: bgp
|
||||
dns.renner.uno/internal: "true"
|
||||
annotations:
|
||||
io.cilium/lb-ipam-ips: "10.2.99.84,fd99::84"
|
||||
external-dns.kubernetes.io/hostname: syslog.renner.uno
|
||||
|
||||
@@ -78,11 +78,10 @@ spec:
|
||||
# passed per scrape. The Probes in monitoring-rules/probes-dns.yaml
|
||||
# point these at the UDM.
|
||||
#
|
||||
# Both answer checks are load-bearing. valid_rcodes alone passes a
|
||||
# deleted record two labels deep (NOERROR, no answer), and the public
|
||||
# *.renner.uno wildcard answers one label deep with a CNAME to
|
||||
# proxy.renner.uno — NOERROR with the WAN proxy behind it. Requiring
|
||||
# an A and rejecting a CNAME separates a real record from both.
|
||||
# Both answer checks are load-bearing: valid_rcodes alone passes a
|
||||
# deleted record (NOERROR, no answer, any depth). Requiring an A
|
||||
# separates a real record from that; a CNAME means the UDM answered with a
|
||||
# public-zone target instead of the LAN address.
|
||||
dns_lan_ha:
|
||||
prober: dns
|
||||
timeout: 5s
|
||||
|
||||
@@ -132,6 +132,8 @@ spec:
|
||||
ingress:
|
||||
enabled: true
|
||||
ingressClassName: traefik
|
||||
labels:
|
||||
dns.renner.uno/internal: "true"
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: letsencrypt-cluster
|
||||
hosts:
|
||||
|
||||
@@ -23,7 +23,7 @@ spec:
|
||||
retryInterval: 60
|
||||
maxRetries: 1
|
||||
dns:
|
||||
# target of the *.renner.uno wildcard
|
||||
# target of every public CNAME (NetBird proxy load balancer)
|
||||
hostname: proxy.renner.uno
|
||||
resolveType: AAAA
|
||||
resolveServer: "2606:4700:4700::1111,1.1.1.1"
|
||||
@@ -228,7 +228,7 @@ spec:
|
||||
retryInterval: 60
|
||||
maxRetries: 1
|
||||
dns:
|
||||
# Cloudflare-proxied apex, not the wildcard
|
||||
# Cloudflare-proxied apex
|
||||
hostname: renner.uno
|
||||
resolveType: AAAA
|
||||
resolveServer: "2606:4700:4700::1111,1.1.1.1"
|
||||
|
||||
@@ -3,6 +3,8 @@ kind: Ingress
|
||||
metadata:
|
||||
name: loki
|
||||
namespace: monitoring
|
||||
labels:
|
||||
dns.renner.uno/internal: "true"
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: letsencrypt-cluster
|
||||
# nginx's auth-type/auth-secret/auth-realm annotation triple becomes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
# prometheus.renner.uno — Prometheus. It has no auth of its own and its metrics
|
||||
# DB exposes hostnames, IPs and service inventory, so the Authentik gate
|
||||
# (ingress class authentik-gate) is the only thing in front of it: Monitoring
|
||||
# (the authentik-gate Middleware) is the only thing in front of it: Monitoring
|
||||
# Access only. Replaces the chart-generated Ingress
|
||||
# (prometheus.ingress.enabled=false in helmrelease-prometheus.yaml).
|
||||
apiVersion: networking.k8s.io/v1
|
||||
@@ -9,11 +9,14 @@ kind: Ingress
|
||||
metadata:
|
||||
name: prometheus
|
||||
namespace: monitoring
|
||||
labels:
|
||||
dns.renner.uno/internal: "true"
|
||||
annotations:
|
||||
traefik.ingress.kubernetes.io/router.middlewares: authentik-gate@kubernetescrd
|
||||
cert-manager.io/cluster-issuer: letsencrypt-cluster
|
||||
auth.renner.uno/group: Monitoring Access
|
||||
spec:
|
||||
ingressClassName: authentik-gate
|
||||
ingressClassName: traefik
|
||||
rules:
|
||||
- host: prometheus.renner.uno
|
||||
http:
|
||||
|
||||
@@ -52,7 +52,7 @@ spec:
|
||||
# stdlib only; Flux keeps the tag in lockstep via the shared image
|
||||
# policy) — no extra dependency.
|
||||
- name: reconcile-publish-ip
|
||||
image: ghcr.io/music-assistant/server:2.10.7 # {"$imagepolicy": "flux-system:music-assistant"}
|
||||
image: ghcr.io/music-assistant/server:2.10.8 # {"$imagepolicy": "flux-system:music-assistant"}
|
||||
command: ["/app/venv/bin/python", "/scripts/reconcile.py"]
|
||||
volumeMounts:
|
||||
- name: data
|
||||
@@ -62,7 +62,7 @@ spec:
|
||||
readOnly: true
|
||||
containers:
|
||||
- name: music-assistant
|
||||
image: ghcr.io/music-assistant/server:2.10.7 # {"$imagepolicy": "flux-system:music-assistant"}
|
||||
image: ghcr.io/music-assistant/server:2.10.8 # {"$imagepolicy": "flux-system:music-assistant"}
|
||||
env:
|
||||
- name: LOG_LEVEL
|
||||
value: info
|
||||
|
||||
@@ -4,9 +4,10 @@ metadata:
|
||||
name: music-assistant
|
||||
namespace: music-assistant
|
||||
labels:
|
||||
# Registered publicly (Cloudflare wildcard -> NetBird proxy); the UDM
|
||||
# external-dns instance skips it, LAN reaches it via the hairpin NAT.
|
||||
# Registered publicly (explicit CNAME -> NetBird proxy). No
|
||||
# dns.renner.uno/internal label: external-dns-unifi writes no UDM record.
|
||||
dns.renner.uno/public: "true"
|
||||
netbird.renner.uno/public: "true"
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: letsencrypt-cluster
|
||||
spec:
|
||||
|
||||
@@ -23,7 +23,7 @@ spec:
|
||||
retryInterval: 60
|
||||
maxRetries: 1
|
||||
dns:
|
||||
# cluster services have no own record; they resolve through the *.renner.uno wildcard
|
||||
# public CNAME to the NetBird proxy, created by external-dns (dns.renner.uno/public)
|
||||
hostname: music.renner.uno
|
||||
resolveType: CNAME
|
||||
resolveServer: "2606:4700:4700::1111,1.1.1.1"
|
||||
|
||||
@@ -8,14 +8,15 @@ data:
|
||||
ND_LOGLEVEL: "info"
|
||||
ND_SCANNER_SCHEDULE: "0 * * * *"
|
||||
ND_ENABLEINSIGHTSCOLLECTOR: "false"
|
||||
# Identity from the gate outpost (ingress class authentik-gate). Traefik strips this header on
|
||||
# the ungated /rest and /share routes.
|
||||
# Identity from Authentik forward auth (ingress class authentik-gate),
|
||||
# set by Traefik. Traefik strips this header on the ungated /rest and
|
||||
# /share routes.
|
||||
#
|
||||
# ND_EXTAUTH_TRUSTEDSOURCES BELOW IS NOT A NARROWING. fd10:244::/48 plus
|
||||
# 10.244.0.0/16 is the entire cluster pod CIDR, so navidrome's own
|
||||
# reverse-proxy trust check accepts X-Authentik-Username from ANY pod.
|
||||
# The CiliumNetworkPolicy is the only real boundary, and it is wider than
|
||||
# "the outpost and Traefik" — default-deny-ingress in
|
||||
# Traefik alone — default-deny-ingress in
|
||||
# kubernetes/infrastructure/network-policies/navidrome-ns.yaml uses
|
||||
# `endpointSelector: {}` and admits, on every port:
|
||||
# - the navidrome namespace, every port
|
||||
@@ -29,7 +30,7 @@ data:
|
||||
# cited by what they admit, not by line number, so this list cannot go
|
||||
# stale the next time that file is edited.
|
||||
# The value stays at the pod CIDR ON PURPOSE - see REN-28. The address
|
||||
# navidrome sees is the outpost's POD IP, which is not stable across
|
||||
# navidrome sees is the Traefik POD IP, which is not stable across
|
||||
# reschedules, so a narrower literal here fails open-ended and silently
|
||||
# the next time that pod moves. Tightening the CNP is the control that
|
||||
# would actually do work.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Web UI gated by authentik-gate-sync (ingress class authentik-gate).
|
||||
# Web UI gated by authentik-gate-sync (the authentik-gate Middleware).
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
@@ -6,10 +6,12 @@ metadata:
|
||||
namespace: navidrome
|
||||
labels:
|
||||
dns.renner.uno/public: "true"
|
||||
netbird.renner.uno/public: "true"
|
||||
annotations:
|
||||
traefik.ingress.kubernetes.io/router.middlewares: authentik-gate@kubernetescrd
|
||||
cert-manager.io/cluster-issuer: letsencrypt-cluster
|
||||
spec:
|
||||
ingressClassName: authentik-gate
|
||||
ingressClassName: traefik
|
||||
rules:
|
||||
- host: navidrome.renner.uno
|
||||
http:
|
||||
@@ -45,6 +47,7 @@ metadata:
|
||||
namespace: navidrome
|
||||
labels:
|
||||
dns.renner.uno/public: "true"
|
||||
netbird.renner.uno/public: "true"
|
||||
annotations:
|
||||
traefik.ingress.kubernetes.io/router.middlewares: navidrome-navidrome-strip-identity@kubernetescrd
|
||||
spec:
|
||||
|
||||
@@ -23,7 +23,7 @@ spec:
|
||||
retryInterval: 60
|
||||
maxRetries: 1
|
||||
dns:
|
||||
# cluster services have no own record; they resolve through the *.renner.uno wildcard
|
||||
# public CNAME to the NetBird proxy, created by external-dns (dns.renner.uno/public)
|
||||
hostname: navidrome.renner.uno
|
||||
resolveType: CNAME
|
||||
resolveServer: "2606:4700:4700::1111,1.1.1.1"
|
||||
@@ -101,7 +101,7 @@ spec:
|
||||
retryInterval: 60
|
||||
maxRetries: 1
|
||||
dns:
|
||||
# cluster services have no own record; they resolve through the *.renner.uno wildcard
|
||||
# public CNAME to the NetBird proxy, created by external-dns (dns.renner.uno/public)
|
||||
hostname: lidarr.renner.uno
|
||||
resolveType: CNAME
|
||||
resolveServer: "2606:4700:4700::1111,1.1.1.1"
|
||||
|
||||
@@ -101,7 +101,7 @@ spec:
|
||||
value: "1000"
|
||||
- name: TZ
|
||||
value: Europe/Berlin
|
||||
# Identity is enforced by the gate outpost (ingress class authentik-gate).
|
||||
# Identity is enforced by Authentik forward auth (the authentik-gate Middleware).
|
||||
- name: LIDARR__AUTH__METHOD
|
||||
value: External
|
||||
ports:
|
||||
@@ -186,7 +186,7 @@ spec:
|
||||
port: 80
|
||||
targetPort: http
|
||||
---
|
||||
# Gated by authentik-gate-sync (ingress class authentik-gate).
|
||||
# Gated by authentik-gate-sync (the authentik-gate Middleware).
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
@@ -194,11 +194,13 @@ metadata:
|
||||
namespace: navidrome
|
||||
labels:
|
||||
dns.renner.uno/public: "true"
|
||||
netbird.renner.uno/public: "true"
|
||||
annotations:
|
||||
traefik.ingress.kubernetes.io/router.middlewares: authentik-gate@kubernetescrd
|
||||
cert-manager.io/cluster-issuer: letsencrypt-cluster
|
||||
auth.renner.uno/group: Music Librarians
|
||||
spec:
|
||||
ingressClassName: authentik-gate
|
||||
ingressClassName: traefik
|
||||
rules:
|
||||
- host: lidarr.renner.uno
|
||||
http:
|
||||
|
||||
@@ -2,11 +2,9 @@
|
||||
# Ingress so the alias-host redirect could be expressed as a Traefik
|
||||
# RedirectRegex Middleware instead of an nginx configuration-snippet.
|
||||
#
|
||||
# The Middleware short-circuits before the backend, so `paperless-gate` (the
|
||||
# ExternalName authentik-gate-sync generates for the paperless Ingress) is a
|
||||
# structural backend only — it is never reached. Even if the redirect
|
||||
# regex misses, the outpost rejects non-canonical Host headers with 404,
|
||||
# so there is no failure mode that leaks paperless access through this Ingress.
|
||||
# The redirect short-circuits before the backend. Should its regex miss, the
|
||||
# Authentik gate behind it admits Paperless Users only, as on
|
||||
# paperless.renner.uno, so nothing leaks paperless access through this Ingress.
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: Middleware
|
||||
metadata:
|
||||
@@ -24,12 +22,14 @@ metadata:
|
||||
name: docs
|
||||
namespace: paperless
|
||||
labels:
|
||||
# Registered publicly (Cloudflare wildcard -> NetBird proxy); the UDM
|
||||
# external-dns instance skips it, LAN reaches it via the hairpin NAT.
|
||||
# Registered publicly (explicit CNAME -> NetBird proxy). No
|
||||
# dns.renner.uno/internal label: external-dns-unifi writes no UDM record.
|
||||
dns.renner.uno/public: "true"
|
||||
netbird.renner.uno/public: "true"
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: letsencrypt-cluster
|
||||
traefik.ingress.kubernetes.io/router.middlewares: paperless-docs-to-paperless-redirect@kubernetescrd
|
||||
traefik.ingress.kubernetes.io/router.middlewares: paperless-docs-to-paperless-redirect@kubernetescrd,authentik-gate@kubernetescrd
|
||||
auth.renner.uno/group: Paperless Users
|
||||
spec:
|
||||
ingressClassName: traefik
|
||||
rules:
|
||||
@@ -40,9 +40,9 @@ spec:
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: paperless-gate
|
||||
name: paperless
|
||||
port:
|
||||
number: 9000
|
||||
number: 80
|
||||
tls:
|
||||
- secretName: docs-renner-uno-tls
|
||||
hosts:
|
||||
|
||||
@@ -113,6 +113,7 @@ metadata:
|
||||
namespace: paperless
|
||||
labels:
|
||||
lb-pool: bgp
|
||||
dns.renner.uno/internal: "true"
|
||||
annotations:
|
||||
io.cilium/lb-ipam-ips: "10.2.99.82,fd99::82"
|
||||
# LAN-only DNS via the UniFi external-dns instance. No cloudflare
|
||||
|
||||
@@ -23,7 +23,7 @@ spec:
|
||||
retryInterval: 60
|
||||
maxRetries: 1
|
||||
dns:
|
||||
# cluster services have no own record; they resolve through the *.renner.uno wildcard
|
||||
# public CNAME to the NetBird proxy, created by external-dns (dns.renner.uno/public)
|
||||
hostname: docs.renner.uno
|
||||
resolveType: CNAME
|
||||
resolveServer: "2606:4700:4700::1111,1.1.1.1"
|
||||
@@ -88,7 +88,7 @@ spec:
|
||||
retryInterval: 60
|
||||
maxRetries: 1
|
||||
dns:
|
||||
# cluster services have no own record; they resolve through the *.renner.uno wildcard
|
||||
# public CNAME to the NetBird proxy, created by external-dns (dns.renner.uno/public)
|
||||
hostname: paperless.renner.uno
|
||||
resolveType: CNAME
|
||||
resolveServer: "2606:4700:4700::1111,1.1.1.1"
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
---
|
||||
# Ingress from the gate outpost is the CNP paperless-gate that
|
||||
# authentik-gate-sync generates next to the Ingress. Header-based remote-user
|
||||
# auth means paperless trusts X-Authentik-Username unconditionally, so any pod
|
||||
# that reaches its HTTP listener can claim any username.
|
||||
# Ingress from traefik is the CNP paperless-gate that authentik-gate-sync
|
||||
# generates next to the Ingress; traefik sets X-Authentik-Username from
|
||||
# Authentik forward auth. Header-based remote-user auth means paperless trusts
|
||||
# that header unconditionally, so any pod that reaches its HTTP listener can
|
||||
# claim any username.
|
||||
#
|
||||
# What is enforced is wider than that CNP: default-deny-ingress in
|
||||
# kubernetes/infrastructure/network-policies/paperless-ns.yaml uses
|
||||
# `endpointSelector: {}`, and Cilium unions the allow rules of every CNP
|
||||
# selecting an endpoint. Besides the outpost, the pod admits:
|
||||
# selecting an endpoint. Besides traefik, the pod admits:
|
||||
# - the paperless namespace, every port
|
||||
# ../../infrastructure/network-policies/paperless-ns.yaml#paperless-admit
|
||||
# - host / remote-node, every port
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user