A Go controller-runtime operator for running Synapse on Kubernetes. It runs in two modes from the same binary: a config-sync controller that rolls Synapse pods when their config changes, and an Ingress + Gateway API controller that renders native Kubernetes routing into Synapse's upstreams.
What it does:
- Config-sync (default) — hashes every ConfigMap/Secret matching a label selector and stamps the hash onto the Synapse workload, so Kubernetes rolls the pods whenever config content changes (no manual restarts)
- Ingress / Gateway API mode (
--ingress-mode) — reconciles class-matchedIngressand Gateway APIHTTPRouteobjects into Synapse's v2upstreams.yamlon a shared volume, hot-reloaded via inotify +SIGHUP - TLS projection — projects referenced Ingress/Gateway TLS Secrets into Synapse's certificates directory, operator-owned and hot-reloaded. A certificate that cannot be written does not stop the render: the pair already on disk keeps serving (a new one is left out), a
CertificateNotWrittenevent is recorded on the object that references it, and the render is retried after a minute - Status & HA — optionally publishes load-balancer addresses on matched Ingresses and gates shared status writes behind a Lease when running more than one proxy replica
- Helm-native — keys off
app.kubernetes.io/namebeingsynapse,synapse-proxyorsynapse-agent, so it plugs straight into Synapse Helm releases - SynapseProxy (
--proxy-controller, alpha) — runs a Synapse proxy from one typed resource: its configuration, Deployment, Service, routes and certificates. See SynapseProxy - SynapseAgent (
--agent-controller, alpha) — runs a Synapse agent on every selected node from one typed resource: its configuration and DaemonSet. See SynapseAgent
Go 1.26+ · any conformant Kubernetes cluster · Gateway API CRDs required only for
--gateway-api
GOOS=linux GOARCH=amd64 go build -o bin/synapse-operatormake test # every package
make verify-generated # fails if the CRDs or deepcopy code are staleThe API tests run against a local Kubernetes API server. Its binaries are downloaded on first use; set KUBEBUILDER_ASSETS to use ones already on disk.
After changing a type under api/, run make generate manifests and commit the result.
make e2e E2E_SYNAPSE_IMAGE=ghcr.io/gen0sec/synapse:<version>runs a SynapseProxy end to end: it starts a k3s cluster in a container, installs the operator built from the working tree, and sends requests through the cluster's load balancer to the Synapse pods the operator creates. It needs Docker, kubectl, and a Synapse image, 0.8.9 or newer, that the local Docker has or can pull. The cluster gets a kubeconfig of its own; the one kubectl uses by default is not touched. See test/e2e.
docker build -t ghcr.io/<org>/synapse-operator:latest .
docker push ghcr.io/<org>/synapse-operator:latestUpdate config/manager.yaml with the pushed image reference.
kubectl apply -k configCreates the synapse-os namespace, ServiceAccount, RBAC, and a single operator replica.
helm repo add gen0sec https://helm.gen0sec.com
helm repo update
export GEN0SEC_API_KEY="REPLACE_ME"
helm upgrade --install synapse-stack gen0sec/synapse-stack \
-n synapse --create-namespace \
--set global.namespaces.synapse="synapse" \
--set global.namespaces.operator="synapse-os" \
--set synapse.image.repository="ghcr.io/gen0sec/synapse" \
--set synapse.image.tag="latest" \
--set synapse.synapse.gen0sec.apiKey="$GEN0SEC_API_KEY" \
--set operator.enabled=true \
--set operator.image.repository="ghcr.io/<org>/synapse-operator" \
--set operator.image.tag="latest"Verify, then trigger a config change and watch the rollout:
kubectl -n synapse-os rollout status deployment/synapse-operator
kubectl -n synapse edit configmap synapse-stack # change any key
kubectl -n synapse rollout status deployment/synapse-stack
# the pod annotation synapse.gen0sec.com/config-hash updatesThe operator runs as one of three controllers per process, selected by --ingress-mode or --config-sync. All share the same manager, health probes, and optional namespace scoping.
Config-sync is the default — it never touches routing, it only forces rollouts when watched config changes.
Ingress / Gateway API turns native Kubernetes routing objects into Synapse's
upstreams.yamland keeps Synapse hot-reloaded in place.
| Config-sync | Ingress / Gateway API | |
|---|---|---|
| Flag | (default) | --ingress-mode |
| Watches | ConfigMaps + Secrets (by label) | Ingress (+ HTTPRoute with --gateway-api) |
| Action | stamp config hash → roll workload | render upstreams.yaml → inotify + SIGHUP |
| TLS Secret projection | — | ✅ via --certs-out |
| Publishes LB status on Ingress | — | ✅ via --publish-status-address |
| One-shot initContainer prime | — | ✅ --render-once |
| Multi-replica shared-status HA | — | ✅ --status-leader-election |
The routes file is always a v2 file.
--ingress-modeand--gateway-apiused to write Synapse's v1 schema unless an Ingress hadssl-passthrough. They now write the v2 schema every time, the file aSynapseProxywrites. Synapse MUST be 0.8.9 or newer: an older one refuses a v2 file with a TLS back-end, a host without a certificate, ause-regexpath orhealthcheck: "false", and does not start on a refused first file. These modes never write a sticky route now:sticky-sessionsis ignored with aStickySessionsUnavailablewarning. See the upgrade-order note below for the two upgrades. The file name andupstream.confdo not change.What stops working:
server-alias: "*"and a mid-name wildcard such aswww.*.example.comare no longer a catch-all or a pattern; they are left out withInvalidServerAlias. Ause-regexpath (or a GatewayRegularExpressionpath) the operator refuses is left out withUnsupportedMatch: one Go cannot parse; one with a character class holding a character outside ASCII; one with a case-insensitive character outside ASCII; one with a character above 0x7f written by its number, or a character outside ASCII that cannot be printed; and one longer than 1024 bytes once written out. A path without header annotations no longer takes the headers of the path above it; set them on each Ingress.--config-sync --ensure-filescreates a v2 placeholder (Synapse 0.7.0 or newer).Every
use-regexpath and every GatewayRegularExpressionpath is written in Go's canonical form. For the few expressions the two engines read differently, such as\<(a literal character in Go, a word boundary in Synapse), the meaning follows Go's reading. One exception: under(?i), Go matchessandktoſ(U+017F) and the Kelvin sign (U+212A) as well; Synapse matches ASCII letters only.What stays: every annotation means what it meant: plain HTTP unless
backend-protocolasks for TLS, a probe unlesshealthcheck: "false", 120 s to send, no fingerprints forwarded.A file that was already v2 because of passthrough now says the v1 values. A route with no TLS setting says
ssl_enabled: false(plain HTTP, not chosen by port).healthcheck: "true"uses the global probe, not a TCP probe.healthcheck: "false"writestype: none. The read timeout is 120 s, not 60 s. Client fingerprints are not forwarded.To roll back, run operator 0.1.x again; the next render rewrites the file in v1.
In --ingress-mode, each Ingress/HTTPRoute path is rendered into a Synapse route by path type:
| Source | Rendered as |
|---|---|
Ingress Prefix · Gateway PathPrefix |
Synapse longest-prefix path (key = the path) |
Ingress Exact · Gateway Exact |
Approximated as a prefix (Synapse matches longest-prefix) + a warning event |
Ingress ImplementationSpecific + nginx.ingress.kubernetes.io/use-regex: "true" |
Regex route — match_expr: http.request.path matches "<regex>", with <regex> in its canonical form |
Gateway RegularExpression |
Regex route — match_expr: http.request.path matches "<regex>", with <regex> in its canonical form |
/.well-known/acme-challenge/<token> (cert-manager HTTP-01 solver) |
A plain-HTTP path of the host that serves the solver's name (ssl_enabled: false). A solver for the whole challenge directory on a host that has regex routes is a match_expr route under the key acme:challenge |
A solver's path is reached with Synapse 0.7.1 or newer. Before that, Synapse answered every path under /.well-known/acme-challenge/ itself, ahead of any host's routes.
The canonical form is the expression as Go's regexp parser writes it back, which Synapse's engine reads the same way: /v[0-9]+/.* becomes (?-s:/v[0-9]+/.*). An expression the operator refuses (Go cannot parse it, it holds a non-ASCII character class, a case-insensitive non-ASCII letter or a non-ASCII character written by its number or one that cannot be printed, or it is over 1024 bytes written out) is left out with an UnsupportedMatch warning, in every mode. Regex paths are anchored at the start (^) since they match from the beginning of the request path (the Kubernetes Ingress spec also requires the stored path to begin with /, so the leading ^ is supplied by the renderer). The path-map key for a regex route is a unique label; matching is driven entirely by match_expr. Header / method / query-param match conditions are not representable in Synapse's host+path model and are dropped with a warning event.
Alpha (
synapse.gen0sec.com/v1alpha1): the API can still change. Off unless the operator runs with--proxy-controller.
A SynapseProxy is a Synapse proxy described by one resource. The operator renders its configuration, creates its Deployment, Service and ServiceAccount, and renders the routes and TLS certificates of the Ingresses that belong to it. Nobody edits a ConfigMap.
apiVersion: synapse.gen0sec.com/v1alpha1
kind: SynapseProxy
metadata:
name: edge
namespace: edge
spec:
image: ghcr.io/gen0sec/synapse:<version> # 0.8.9 or newer
replicas: 2
service:
type: LoadBalancer
listeners:
- name: http
port: 80
protocol: HTTP
- name: https
port: 443
protocol: TLS
---
apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
name: edge
spec:
controller: gen0sec.com/synapse
parameters: # which proxy serves this class
apiGroup: synapse.gen0sec.com
kind: SynapseProxy
scope: Namespace
namespace: edge
name: edgeAn Ingress with ingressClassName: edge is then served by that proxy, with the certificates its tls section names. It can be in any namespace the operator watches.
$ kubectl get synapseproxies -n edge
NAME READY REASON DESIRED AVAILABLE ADDRESS AGE
edge True Applied 2 2 203.0.113.10 2mREADY is true when the pods run the spec as it is written. When they do not, REASON and the resource's conditions say why: a configuration that cannot be rendered, a rollout in progress, an object of the same name in the way.
kubectl apply -k config # the operator
kubectl apply -k config/proxy-controller # the CRD, and the role the controllers needthen add --proxy-controller to the operator's arguments in config/manager.yaml. test/e2e/operator is a kustomization that does all three. When it starts, the operator checks that it can read SynapseProxy resources, and exits if it cannot, saying whether the CRD is missing or the role is. A role that is bound but incomplete gets past that: the controller that is refused something stops the operator a couple of minutes later, naming the kind it could not read.
- The pod is privileged and runs as root, as the Helm chart's does, with packet capture, the firewall and the IDS on. Whoever may create a
SynapseProxyin a namespace gets such a pod there, running the image they name. Whoever may create or change one also choosesspec.hostNetwork,spec.nodeSelector,spec.tolerationsandspec.affinity. They choose which nodes the pod lands on, tainted ones included. They choose whether it joins the network namespace of its node. Create, update and patch rights onSynapseProxyMUST therefore go only to principals you trust with a root pod on those nodes. - Pod Security
baselineorrestrictedrefuses the pods, not the Deployment. The Deployment is created, the pods never are, and the proxy never becomes Ready. The operator has no condition for this.kubectl get synapseproxyshowsReadyasFalsewith the reasonRollingOut, and after the Deployment's progress deadline (ten minutes by default)ProgressDeadlineExceeded. The refusal itself is in the events and theReplicaFailurecondition of the Deployment's ReplicaSet (kubectl describe replicaset). Label the namespacepod-security.kubernetes.io/enforce: privilegedfor a proxy to run there. The label lifts Pod Security for every pod in the namespace, so run proxies in a namespace of their own. - A host belongs to one namespace. The class decides which proxy gets an Ingress, and a class is cluster-scoped on purpose: a proxy receives the TLS private keys of every Ingress of its classes, from every namespace. Within one proxy, a host goes to the namespace that claimed it first, by when the proxy first saw the claim (then namespace and name). The proxy keeps that in a ConfigMap it controls,
<proxy>-host-claims, with one line per namespace and host. Editing an old object to name a host is a new claim, aged from the render that sees it, and the object's creationTimestamp does not count; the first time the ledger is made, it is filled from the creation timestamps. A line stays for one hour after nothing claims the host, so that deleting and recreating an Ingress does not lose it; the host passes to the next claimant at once. A line expires an hour after a render first saw its claim absent, whether or not a render has run since: a claim that comes back after that hour is a new claim, aged from the render that sees it. A claim that was never seen absent keeps its age however old the line. While host ownership is off the ledger is neither read nor written; when it is turned on again, the lines keep their first-seen times and claims made in between are aged from that render. A namespace holds at most 1024 lines: its newest claims past that are not recorded and are aged afresh on every render, with aHostClaimQuotaExceededwarning on the proxy, so one namespace that names thousands of hosts cannot fill the ledger and make every later claim tie; if the ledger is still too big, lines new in that render are dropped first, then lines of claims no longer made, then the rest, each time from the namespace with the most bytes, and every line counts as long as it can get, with the longest time a claim can have been absent, so that a claim going absent never makes the ledger too big. New lines are therefore refused first, and a line that was there before is dropped only from a ledger that was already over the cap, for instance one edited by hand. What remains is that, while the ledger is full, two contested claims that are both new tie by namespace name. Deleting the ledger resets every age to the object's creation time, and whoever may write ConfigMaps in the proxy's namespace may write the ledger. A ledger that cannot be read fails the render and keeps the last routes; one that cannot be written does not stop the routes, is counted insynapse_operator_host_claim_ledger_errors_totaland is retried in a minute. The names are therules[].host, theserver-aliasvalues and thespec.tls[].hostsof its Ingresses, compared without case and without a trailing dot. Another namespace's Ingress that names the host loses that rule, alias or certificate, whatever its path or annotations (use-regex,ssl-passthrough, an ACME solver path), and gets aHostnameConflictwarning that names the owner's namespace;synapse_operator_host_conflicts_totalcounts them. A wildcard held by an older claim holds the hosts it covers, but a newer wildcard does not take a host an older claim holds: a held name that the file has no routes for (its backend cannot be resolved, or an Ingress names it only inspec.tlsorserver-alias) and that a wildcard of another namespace or of none covers is written with no paths, and the proxy answers 404 for it itself. A namespace may spread its host over any number of Ingresses. Ownership is per proxy: two proxies can serve the same host to different namespaces. A Gateway's listener and route hosts are claims too (see "A host belongs to one namespace, Gateways included" below). When the owner's last Ingress for a host goes, the host passes to the next oldest claimant on the next render. An Ingress that names hosts in its rules and may use none of them shows no address in its status, and gets noProgrammedevent. Setspec.hostOwnershiptoNoneon a SynapseProxy to turn this off for it, so that namespaces share hosts as before; the default isNamespace. - Routes and certificates take about a minute to reach running pods. They are delivered through mounted volumes, which the kubelet refreshes on its own schedule.
- Sticky sessions use a signing key the operator generates. Each
SynapseProxygets a Secret<proxy>-sticky-key(keysticky.key, 32 random bytes), mounted read-only into every replica, and the routes file names it assticky_sessions.secret_file. A Secret of that name that you made yourself is used as it is when it holds at least 32 bytes; a shorter one stops the proxy withReady=Falseand the reasonStickyKeyUnusable, and is not touched. To rotate the key, delete the Secret and runkubectl rollout restart deployment/<proxy>. The first rollout after an upgrade adds the mount. Until it finishes, an old replica that reloads a routes file with sticky sessions cannot read the key, refuses the file and keeps its last routes; a route change reaches it once it is replaced. With--ingress-modeand--config-syncthere is no such file, sosticky-sessionsis ignored with aStickySessionsUnavailablewarning. - It takes Synapse 0.8.9 or newer. An older Synapse refuses the routes file when a route is sticky or reaches its back-end over TLS, since it does not know
sticky_sessions.secret_fileorupstream_tls. It also refuses the file when a host has no certificate, a route is chosen by a regular expression orhealthcheckisfalse. A refused file means none of its routes are served: a running pod keeps its previous routes, and a new pod serves nothing. - Upgrade order: neither order is clean. An operator older than 0.2.0 writes
sticky_sessionswithoutsecret_filefor a sticky route. With--resolve-backend-cluster-ipsor--resolve-backend-endpointsit also addresses back-ends by IP. Synapse 0.8.9 refuses that sticky file, and checks the certificate of a TLS back-end against its address, which an in-cluster certificate rarely names. Operator 0.2.0 writessecret_fileandupstream_tls, which Synapse 0.8.8 and older refuse. So Synapse first breaks sticky and TLS routes until the operator follows, and the operator first breaks routes withupstream_tls(and those of aSynapseProxywith sticky sessions) until Synapse follows. A refused file means a running pod keeps its previous routes and a new pod serves nothing. You SHOULD upgrade both in one change: upgrade the operator, then raise theSynapseProxyimage to 0.8.9 or newer right after, or roll the Synapse image of your--ingress-modesidecar at once. Alternatively, remove thesticky-sessionsandbackend-protocol: HTTPSannotations first, upgrade, and add them back. - Synapse sets
X-Forwarded-Protoon every request to a back-end,httpswhen the client used TLS andhttpotherwise. A value the client sent is replaced, unless the client is inspec.trustedProxies. Behind a load balancer that ends TLS itself and sends plain HTTP on, list the balancer inspec.trustedProxiesso that itsX-Forwarded-Protopasses through. Withproxy.forwarded_proto: falseinspec.config, Synapse leaves the header as the client sent it. - An annotation does what it does in
--ingress-mode. Both write the same v2 file, which says plain HTTP to a backend unlessbackend-protocolasks for TLS, a probe unlesshealthcheckisfalse, 120 seconds for a backend to send, and nothing about the client in the request to it.request-headersandresponse-headersare for the routes of the Ingress that carries them: a path of another Ingress never takes them. Aserver-aliasvalue with a space, a newline or another character a host cannot have is left out, with anInvalidServerAliaswarning on the Ingress. So is a*anywhere but as the first label, as in*.example.com, and a bare*is no catch-all. - A back-end that speaks TLS is checked, and a CA can be named. With
backend-protocol: HTTPSSynapse verifies the back-end's certificate against the system roots.synapse.gen0sec.com/upstream-tls-ca(nginx:nginx.ingress.kubernetes.io/proxy-ssl-secret) names a Secret whoseca.crtis the CA to trust instead. The Secret MUST be in the namespace of the Ingress or HTTPRoute: another namespace is refused with anUpstreamCAForbiddenwarning, and a Secret that is missing, has noca.crtor holds no certificate givesUpstreamCAUnusable. In both cases the route writes noca, so Synapse checks it against the proxy-wideupstream_tls.cawhen that is set, else the system roots: a back-end of a private CA fails closed, and the other routes are served. The CA is written next to the routes file asca-<sha256[:16]>.pem, in the same ConfigMap asupstreams.yaml, and a change to the Secret renders again. A CA over 64 KiB, the distinct CA files of one namespace over 128 KiB together, or CA files over 512 KiB together, are refused. The proxy-wide CA (spec.upstreamTLS.caSecretRef) is taken first, so only its own size can refuse it; the CAs of the routes count after it, in the order of namespace and name, so which route is refused is stable. The routes file and the CA files together MUST stay under 1 MiB less 16 KiB. CA files that would push the routes ConfigMap over that are dropped. The one added last goes first. The proxy-wide CA is added first, so it goes last; the CAs of the routes are added in the order of namespace and name, Ingresses before Gateway routes. The owners of a dropped CA getUpstreamCAUnusable, once the render has succeeded. Their hosts fall back to the proxy-wideupstream_tls.cawhen that is set, else to the system roots. Verification stays on. When the routes alone are over that size, no CA is dropped: the render fails withRoutesTooLarge, and the ConfigMap is left as it was. A Secret with a CA under another key thanca.crtis watched only whenspec.upstreamTLS.caSecretRefnames it; otherwise it is picked up at the next render only. It takes Synapse 0.8.9 or newer. spec.upstreamTLSsets the default for the back-ends of the proxy.verifyturns checking on or off, andcaSecretRef(name, andkey, which defaults toca.crt) names a Secret in the namespace of theSynapseProxy. A route's own annotations win. It is written as the top-levelupstream_tlsof the routes file.- HSTS is set for the whole proxy or per host.
spec.hsts(maxAgeSeconds,includeSubdomains,preload) writes the top-levelhstsof the routes file.preloadMUST come withmaxAgeSecondsof at least 31536000 andincludeSubdomains: true, or the API server refuses the proxy. On an Ingress or HTTPRoute,synapse.gen0sec.com/hsts(offorfalseturns it off for the host),hsts-max-age,hsts-include-subdomainsandhsts-preloadwrite thehstsof each of its hosts, and a host's setting replaces the proxy-wide one as a whole. A per-host policy needshsts-max-age. A value that is not valid, or ahsts-preloadwithout ahsts-max-ageof at least 31536000 andhsts-include-subdomains, drops that setting with anInvalidHSTSwarning. Only the namespace that owns a host may set its HSTS. UnderhostOwnershipthat is the namespace that holds the host: for an Ingress its own namespace, for an HTTPRoute the namespace of the Gateway it is attached to, since a route claims its hosts through the Gateway (a route in another namespace on a shared Gateway is judged by the Gateway's namespace, and one in its own namespace by that); otherwise it is the namespace of the first object, in render order, to program a route on it, whether or not that object sets HSTS. An object sets HSTS for a host only once its own route on the host is programmed, so a dropped route or an unresolved backend sets nothing. A setting from another namespace is refused with aHostSettingConflictwarning that names the owner. Within the owner namespace, when two objects set different HSTS for one host, the first in order of namespace and name wins, and the other gets the same warning. A passthrough host takes no per-host HSTS. The annotations are not read on an HTTPRoute attached to a SynapseProxy Gateway yet. It takes Synapse 0.8.9 or newer. - To take traffic on a node's own address, set
spec.hostNetwork: true. The pods then run in the network namespace of their node and each listener binds that node's port, as a DaemonSet withhostNetworkdid, so a load balancer that connects to a node's public address reaches a real socket on the host and not the cluster's host-port rules (which aLoadBalancerService on k3s uses). A node runs one such pod per listener port; a pod stays Pending on a node where the port is taken, for example by an older proxy, which is how a node is handed over: keep the old one off it. A rollout replaces the pods in place, one at a time (maxSurge: 0,maxUnavailable: 1), since a new pod cannot start beside the old one. The Service has to be of typeClusterIP. Synapse's internal services bind the node's loopback, so a second such proxy on a node needs its ownproxy.internal_services.portinspec.config. - To cap the TCP MSS of a listener, set
tcpMSS(88 to 32767) on it. Synapse lowers the MSS of the connections that listener accepts, in both directions, in a TC stage of its BPF firewall. A client that offers less keeps it. The listener's address selects the packets, so every host on the listener is clamped. It needs Synapse 0.8.9 or newer withfirewall.modeautoorxdp, on Linux. Withnone,nftablesoriptables, or where the stage cannot attach, nothing is clamped: Synapse logs an error per listener and serves anyway. The field is unset by default, which renders nothing. - Behind a layer 4 load balancer that sends the PROXY protocol, set
spec.proxyProtocol.enabled: true(and, if the default does not suit,timeoutMs). The proxy then reads the header, v1 or v2, before the TLS handshake and takes the client address from it.proxy.protocolis refused inspec.config. spec.configtakes the Synapse settings that have no field. A key the operator owns, such asmodeor the listeners, is refused there and reported in theConfigValidcondition; it is never silently overridden. An invalid configuration changes nothing that is running.- Certificates come from the Ingresses' TLS Secrets, for example from cert-manager. Synapse's built-in ACME client is not used. A certificate for a concrete host is stored as
<host>.crtand<host>.key; one for a wildcard or no host as<namespace>_<secret>.crtand.key. A host namedcert,chain,fullchainordefaultis stored the same way: Synapse names a file of the first three after its directory, anddefaultis what a config written for an older operator may still name as its default certificate. The operator's own default certificate is_default, which no host can take. A customproxy.default_certificateSHOULD name_defaultor a<namespace>_<secret>stem. A name longer than 249 characters is cut to 232 and followed by_and 16 hex digits of its hash, so that it fits a Secret key and a file name. - The proxy has a default certificate of its own. The operator generates a self-signed one (CN
synapse-default, no SANs, valid for a year) and stores it as_default.crtand_default.keybeside the others. It is generated again only when it is missing, unparseable or within 30 days of expiry. ASynapseProxyserves it by default (proxy.default_certificate: _default;spec.configcan name another). With--ingress-mode, the config is yours: setdefault_certificate: _defaultin it, or Synapse serves whichever certificate it reads first, which can be any tenant's. A client that sends no SNI, or a name no certificate matches, gets this certificate and sees it as untrusted. - Ingresses and, where its CRDs are installed, the Gateway API. See below for what of it is served.
- Not together with
--ingress-modeor--config-syncin one operator process. - With
--namespace, only that namespace is seen. A proxy elsewhere is not run, and an Ingress elsewhere is not served, whatever its class; nothing reports either.
Where the cluster has the Gateway API's CRDs, a proxy serves Gateways as well. A GatewayClass names the proxy, as an IngressClass does:
apiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
metadata:
name: edge
spec:
controllerName: gen0sec.com/synapse
parametersRef: # which proxy serves this class
group: synapse.gen0sec.com
kind: SynapseProxy
namespace: edge
name: edge
---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: web
namespace: edge
spec:
gatewayClassName: edge
listeners:
- name: http
port: 80 # a port the SynapseProxy listens on
protocol: HTTP
allowedRoutes:
namespaces:
from: All
- name: https
port: 443
protocol: HTTPS
hostname: shop.example.com
tls:
certificateRefs:
- name: shop-tls
allowedRoutes:
namespaces:
from: AllAn HTTPRoute attached to that Gateway is then served by the proxy. The rule the operator follows: what is programmed is exactly what was asked for, and what cannot be is said in the object's status. Nothing is routed more broadly than written.
| Served | |
|---|---|
| Listeners | HTTP and HTTPS (terminated), on a port the SynapseProxy listens on with that protocol |
| Who may attach | allowedRoutes by namespace (Same, All, Selector); a parent's sectionName and port |
| Hosts | exact names and wildcards; a route that names no host takes its listener's |
| Matches | PathPrefix, Exact and RegularExpression paths, method, headers (Exact and RegularExpression) and query parameters (Exact), in the precedence the API gives them |
| Backends | Services, with weights; one in another namespace needs a ReferenceGrant |
| Certificates | a listener's certificateRefs; one in another namespace needs a ReferenceGrant |
| Filters | request and response headers: set, add and remove |
| Status | Accepted, Programmed, ResolvedRefs and PartiallyInvalid; attached routes per listener; the proxy's addresses |
What cannot be done is one of two things, and they are not treated alike.
- A rule the proxy cannot carry out keeps its requests. They are answered
404, and are not served by another rule that happens to match them too: a rule for/adminthat cannot be served does not hand/adminto the rule for/. The route saysPartiallyInvalid, orAccepted: Falsewhen nothing of it is served. This is a rule with:- a redirect, URL-rewrite or mirror filter, or a filter on a backend;
- a header filter Synapse does not take: one that names a framing or hop-by-hop header (
Content-Length,Transfer-Encoding,Connection,Keep-Alive,TE,Trailer,Upgrade,Proxy-Connection) orSec-WebSocket-KeyorSec-WebSocket-Accept, a name that is not a header's or has a*in it, or a value with a control character in it; - timeouts, retries or session persistence;
- a backend that cannot be used: one that does not exist, is not a Service, or is in another namespace without a
ReferenceGrant. One such backend among several is enough. Synapse cannot fail a share of the requests, and the other backends were not asked to take them. The route says which inResolvedRefs.
- A match the proxy cannot evaluate is left out, and what it would have matched is served as if the match were not there, by the route's other matches and by other routes. This is a query parameter matched by a regular expression, a query parameter whose name or value would be percent-encoded in a URL, and a regular expression that cannot be used.
Limits that come from how Synapse routes:
- A header's value is matched whole, and as it is.
Exactis the value byte for byte, case included. A header sent on several lines matches when one of them fits; one line with commas in it is one value. - A query parameter is matched as the client wrote it.
beta=1matches that parameter wherever it stands in the query string, and notbeta=10. It does not matchbeta=%31, which says the same in another spelling; a name or a value that has to be percent-encoded is not served for that reason. A parameter given more than once matches when one of its values does. - Regular expressions are ASCII, and bounded. Synapse's regex engine runs without Unicode: a character class may not hold a character outside ASCII, and a letter outside ASCII has no other case. An expression may be 1024 bytes with its classes written out as ranges. A
RegularExpressionmatch ranks betweenExactandPathPrefix. - A route belongs to a host, not to a listener. One attached to a single listener of a Gateway is served on every listener of the proxy, the plain-HTTP ones included.
- A route that names no host needs a listener that names one. Synapse has no host that stands for all others. On a listener without a hostname such a route is not served, and says so.
- A host an Ingress of the same proxy routes is taken. An
HTTPRoutefor it is not accepted (HostnameConflict). - A host belongs to one namespace, Gateways included. A listener's
hostnameis claimed for the Gateway's namespace, and so are a route's hosts through a listener that admits the route (allowedRoutes), whatever the route's own namespace is. Ownership is per namespace across all its Gateways: routes of several namespaces on one Gateway do not refuse each other, but a route of another namespace cannot reach, through a listener with no hostname or a wildcard, a host that the Gateway's namespace names more specifically through its own Ingresses, listeners or routes. A claim is aged by the ledger like an Ingress's, under the Gateway's namespace. When the ledger is first made, it is seeded from the later of the object's and the Gateway's creation time. When an older claim of another namespace holds the host, the listener saysAccepted: False(HostnameConflict) and is not programmed, and a route saysHostnameConflict(also for a host named more specifically in the Gateway's namespace), orPartiallyInvalidwhen it keeps other hosts. An older Gateway also wins a host from a newer Ingress of another namespace. A name the Gateway's namespace names, that has no route of its own under a wildcard any route of another namespace brings in, is written with no paths, so that the wildcard does not serve it. /healthis Synapse's own. It answers that path itself, on every host, and a backend's/healthis not reached through the proxy.
A Gateway that asks for more than is done says so.
- With
spec.addresses,spec.infrastructure.parametersReforspec.tls.backendthe Gateway is not accepted, and none of its listeners is served. - With client certificates (
spec.tls.frontend) or withtls.optionsan HTTPS listener is not served. A listener that was to ask for a client certificate and does not would be open to everyone. - TLS passthrough, and every kind of route but
HTTPRoute, are not served. BackendTLSPolicy,ListenerSetand default Gateways (useDefaultGateways) are not implemented. Such objects get no status from this controller.
Statuses are taken back. When a GatewayClass names a SynapseProxy that does not exist, the class says InvalidParameters, its Gateways go back to Pending without addresses, and routes lose their entries for those Gateways.
When the operator starts it looks for the Gateway API's CRDs. Installed later, they are found after a restart. If they are there and the operator's role does not let it read them, it serves Ingresses only and logs what it is missing: the role is in config/proxy-controller.
The Gateway API conformance suite has not been run against it.
flowchart TD
subgraph K8s[Kubernetes API]
CM[ConfigMaps / Secrets]
ING["Ingress / HTTPRoute<br/>(+ Gateway API)"]
TLS[TLS Secrets]
end
subgraph OP[synapse-operator · controller-runtime]
direction TB
C1[Config-sync controller]
C2["Ingress / Gateway controller<br/>(--ingress-mode)"]
end
CM --> C1
ING --> C2
TLS --> C2
C1 -->|patch synapse.gen0sec.com/config-hash| WL[Synapse workload<br/>Deployment / DaemonSet / StatefulSet]
WL -->|rolls pods| SYN[Synapse pods]
C2 -->|render upstreams.yaml + project certs| SHV[(Shared volume)]
SHV -->|inotify| SYN
C2 -.SIGHUP.-> SYN
Alpha (
synapse.gen0sec.com/v1alpha1): the API can still change. Off unless the operator runs with--agent-controller.
A SynapseAgent is a Synapse agent (packet capture, firewall and IDS, no proxy) that runs on every node it selects, described by one resource. The operator renders its configuration into a Secret and creates the ServiceAccount and the DaemonSet. Nobody edits a ConfigMap.
apiVersion: synapse.gen0sec.com/v1alpha1
kind: SynapseAgent
metadata:
name: agent
namespace: synapse
spec:
image: ghcr.io/gen0sec/synapse:<version>
platform:
apiKeySecretRef: # optional
name: gen0sec-api-key
key: api-keyOnly spec.image is required. Without spec.platform.apiKeySecretRef the agent runs with no platform API key. The Secret MUST be in the agent's namespace.
$ kubectl get synagent -n synapse
NAME READY REASON NODES READY-PODS UPDATED AGE
agent True Applied 3 3 3 2msynagent is the short name of synapseagents. -o wide adds IMAGE and CONFIG (the hash of the rendered configuration). READY is true when the DaemonSet runs the spec as it is written. It does not say that Synapse loaded the configuration, or that it attached to every interface (see Status). When it is not true, REASON and the resource's conditions say why.
kubectl apply -k config # the operator
kubectl apply -k config/crd # the CRDs
kubectl apply -k config/agent-controller # the role the agent controller needsWhere the SynapseProxy controller is installed too, config/proxy-controller already carries both CRDs: apply it and config/agent-controller, and skip config/crd. Then add --agent-controller to the operator's arguments in config/manager.yaml. The ClusterRole and its binding are both named synapse-operator-agent-controller, and bind the ServiceAccount synapse-operator in synapse-os. When it starts, the operator checks that it can read SynapseAgent resources, and exits with an error if it cannot. The error names config/crd when the CRD is missing, and config/agent-controller when the listing is forbidden. It is refused with --ingress-mode and --config-sync, with exit 1.
- The pod is privileged and runs as root, as the Helm chart's agent does, because packet capture, the kernel firewall and the IDS need it. The container is
privileged, addsSYS_ADMIN,NET_ADMIN,BPF,SYS_RESOURCE,SYS_PTRACE,DAC_READ_SEARCHandPERFMON(the last three let SSL attribution read other processes' socket fds through hostPID and attach uprobes), runs withhostNetworkunlessspec.hostNetworkisfalse, and withhostPIDunlessspec.hostPIDisfalse. Its seccomp and AppArmor profiles areUnconfined. Whoever may create or change aSynapseAgentchooses the image, the nodes and the pod's scheduling. Create, update and patch rights onSynapseAgentMUST therefore go only to principals you trust with a root pod on those nodes. - Pod Security
baselineorrestrictedrefuses the pods, not the DaemonSet. Label the namespacepod-security.kubernetes.io/enforce: privileged, and run agents in a namespace of their own. - It takes Kubernetes 1.30 or newer, because the pod sets the
appArmorProfilefield. There is no annotation fallback. - Three hostPaths are mounted (two with
spec.hostNetwork: false, which drops/sys/fs/bpf):/sys/fs/bpf(bidirectional, for the BPF pins),/sys/kernel/debug(read-write) and/lib/modules(read-only). Each is created when it is missing. Only/lib/modulesis read-only./sys/kernel/btfis not mounted, on purpose: a privileged pod already sees the host's sysfs, and Synapse treats BTF as optional. - The node's kernel MUST support eBPF and XDP. XDP needs IPv6 on the interface to attach. Where it is off, Synapse writes
0to/proc/sys/net/ipv6/conf/<iface>/disable_ipv6and retries. That changes the node's interface setting, and it stays changed. The attach fails only if that write fails or IPv6 is disabled at boot (ipv6.disable=1). Synapse then falls back without XDP (AF_PACKET capture) andREADYstill goesTrue. Check the pod's log. - There is no Service and there are no probes. An agent listens on nothing.
READYfollows the DaemonSet, not a health check. The ServiceAccount has no token mounted and no RBAC: the agent never talks to the Kubernetes API. - Defaults of the spec:
spec.tolerationsunset tolerates every taint, so the agent runs on every selected node. An explicittolerations: []tolerates none.spec.hostNetworkunset istrue.spec.hostPIDunset istrue.spec.ids.enabledunset istrue. Synapse's own default isfalse.spec.updateStrategyunset is a rolling update withmaxUnavailable: 1, one node at a time.spec.nodeSelectoralways getskubernetes.io/os: linux. A selector that says another value is refused.
spec.hostNetwork: falsetakes the agent off the node's network. The pod gets its own network namespace and no bpffs of the node. Withnetwork.iface: autothe agent picks the pod's own interface. It inspects and protects only the traffic of that pod. Synapse's XDP dispatcher always pins under/sys/fs/bpf/hillock/xdp, so without a bpffs XDP never attaches. Capture uses AF_PACKET and the firewall uses nftables or iptables. IDS hot changes, HOME_NET changes from node churn included, take effect only at the next restart. Switching an existing agent leaves the XDP link, tc programs and pinned maps of the earlier pod on the node. To clear them, wait until the switch has rolled that node (its pod runs withhostNetwork: false), then drain the node and reboot it. Before that, kubelet restarts the old pod after the reboot and it pins again. The bpffs lives in memory, and XDP and tc attachments do not survive a reboot.synapse --force-stop, run once the node has rolled, is an alternative only on a node where no CNI uses tc or XDP. It sweeps the whole node. It detaches every XDP program and removes every clsact qdisc, with all its tc filters, on every interface, the CNI's included. It removes all Synapse and hillock pins. It stops every Synapse process on the node, proxies included (SIGTERM, then SIGKILL after 10 s if one is still alive). Run it in the node's network and PID namespaces with the node's/sys/fs/bpf: a node shell, or a privileged pod withhostNetwork,hostPIDand a/sys/fs/bpfhostPath. HOME_NET is still computed cluster-wide.spec.configtakes the Synapse settings that have no field, in the shape of Synapse's own configuration file. A key the operator owns is refused and reported in theConfigValidcondition. It is never silently overridden. An invalid configuration changes nothing that is running. The owned keys aremode,daemon.enabled,proxy.enabled,proxyand its aliaspingora,arxignis(useplatform),firewall.ids(use the top-levelids),logging.level,logging.eve_log(usespec.logging.eve),platform.api_key,platform.identity.enabled,platform.identity.cluster,network.ifaces,ids.enabled,ids.enforce_blockandids.address_vars.HOME_NET. Other keys under these sections, such asids.address_vars.CUSTOM, are allowed.platform.policy_edges.enabledis refused only whenspec.platform.policyEdges.enabledis also set. That field needsspec.platform.identity.enabled: truewhen set to true. A rawplatform.policy_edgesblock with noenabledkeeps Synapse's default, which is on; setspec.platform.policyEdges.enabled: falseto turn it off.network.ip_versionhas no field. Synapse does not act on it. It MAY be set inspec.config.spec.capture.interfaceswritesnetwork.ifaces. Synapse ignoresnetwork.ifacebeside it, so a rawnetwork.ifaceinspec.configis refused when interfaces are set.spec.capture.cnifills in the east-west observer.ciliumwritescapture.observe_interfaces: [cilium_vxlan],capture.observe_egress_interfaces: [auto]andcapture.observe_mode: tcx.ciliumfits Cilium's default VXLAN tunnel mode only. With native routing or Geneve (cilium_geneve), setspec.capture.observeInterfaces.bridgewrites[cni0],[auto],tcxandcapture.observe_pod_veths: true.none, or empty, writes nothing.spec.capture.observeInterfaces,observeEgressInterfaces,observeModeandobservePodVethseach replace the preset's value for their key. A rawcapture.observe_*key inspec.configis refused only when the preset or a typed field also writes it. The tcx observer needs Linux 6.6 or newer and a non-emptyobserve_interfaces, even withobserve_pod_veths. Theaf_packetbackend taps only the firstobserve_interfacesentry. It ignoresobserve_egress_interfacesandobserve_pod_veths. Onlytcxuses them.- HOME_NET. A typed
spec.ids.homeNetwins. Its entries MUST be IP addresses or CIDRs; the operator refuses anything else, such asany, a comma or a bracket, and names the entry. Without it the operator computes HOME_NET from the nodes' addresses, their PodCIDRs and the LoadBalancer IPs of Services, plus the private-network supernets, and follows the cluster as it changes. Withids.enabledfalse, every such change (a node joins or leaves, a load balancer IP changes) rolls the DaemonSet on every node. A typedspec.ids.homeNetstops that. - CONTROL_PLANE_NET. The operator also fills
ids.address_vars.CONTROL_PLANE_NETin a config ConfigMap labelledsynapse.gen0sec.com/resolve-netvars: "true". The list holds the ClusterIP ofdefault/kubernetes, the addresses of its EndpointSlices and the InternalIPs of the nodes labellednode-role.kubernetes.io/control-plane. With no such Service the variable is left out. Two annotations on that ConfigMap govern both HOME_NET and CONTROL_PLANE_NET:synapse.gen0sec.com/home-netandsynapse.gen0sec.com/control-plane-netpin the variable to the annotation's value verbatim.synapse.gen0sec.com/netvars-managedandsynapse.gen0sec.com/control-plane-net-managedrecord that the operator wrote the current value (auto). While the marker isauto, the operator re-derives the variable and overwrites an edit made to it inconfig.yaml. A non-empty value with noautomarker is taken as your pin and kept. To pin the current value of CONTROL_PLANE_NET, remove its-managedannotation by hand, or use the override annotation.
- A typed
spec.ids.homeNetreplaces the computed list. HOME_NET also feeds Synapse's never-ban guard. A short list can letenforceBlockban the cluster's own nodes or a load balancer IP. The list SHOULD cover the nodes, the pods and the load balancers. - With
--namespace, only that namespace is seen. An agent elsewhere is not run, and nothing reports it. The agent controller caches Secrets whole and ConfigMaps as metadata only. It reads a rule ConfigMap from the API server at each reconcile. The computed HOME_NET counts only the LoadBalancer Services of that namespace. - The agent owns three objects: the Secret
<name>-config, the ServiceAccount<name>and the DaemonSet<name>. Each has an owner reference to the agent, and they go with it.
spec.ids.rules lists up to 16 sources of rule files. Each source is a configMapRef or a secretRef in the agent's namespace, and may name keys. Without keys, every key that ends in .rules is used.
spec:
ids:
rules:
- configMapRef: {name: local-rules}
keys: [web.rules]
- secretRef: {name: paid-rules}- The operator copies the files into the config Secret. Each one is listed in
ids.rule_pathsafter the configuredrule_paths, as/etc/synapse/config/rules.<n>.<key>.<hash>.rules. The hash is of the content. spec.config.ids.rule_pathsstill works for paths the operator does not manage. Arule_pathsthere replaces the default glob, and the copied files follow that list.- A source MUST NOT be a SynapseAgent's own config Secret, or any Secret a SynapseAgent controls. It holds copies of rules. The operator refuses it with
RulesSourceInvalid. - A ConfigMap's
binaryDatakeys count like itsdatakeys. - An edit is hot. The rules change the config Secret in place and no pod is replaced. See "Hot reload and rollouts" for the delay and for AF_PACKET.
- At most 256 files, and 900 KiB together. The config Secret also holds
config.yaml, which lists every file, so the two together stay under 1,000,000 bytes. Keep larger sets in the platform's rules. - A source the operator cannot read changes nothing that runs.
ConfigValidis false withRulesSourceNotFound(a missing ConfigMap or Secret),RulesKeyNotFound(a named key that is absent),RulesSourceInvalidorRulesTooLarge. - The operator needs
get,listandwatchon ConfigMaps.config/agent-controller/rbac.yamlgrants it.
spec.logging.eve turns on Synapse's EVE log: alert, http and stats events as JSON lines. It is off unless enabled is true. spec.config.logging.eve_log is refused.
spec:
logging:
eve:
enabled: true
output: stdout # stdout (the default), stderr or file
eventTypes: [alert, stats] # alert, http, stats; empty means allstdoutis the default. It carries little else by default.stderrcarries Synapse's own JSON logs and its block events. Filter onevent_type.filewriteseve.jsonto a node directory,/var/log/synapseunlesshostPathnames another. The directory MUST be under/var/log/, and the operator creates it. For example,hostPath: /var/log/synapse-agents.hostPathis a guard against accidents, not a security boundary: the pod is privileged.- Nothing rotates the file, and Synapse keeps it open. A logrotate rule for it MUST use
copytruncate. Only one agent per node SHOULD write to a directory. - Any change to
everolls the DaemonSet.
spec.volumes and spec.volumeMounts add volumes to the agent pod. The volumes follow the operator's own in the pod. The mounts go into the Synapse container, in spec order. Each list takes at most 16 entries. Volumes are keyed by name and mounts by mountPath, so one volume MAY be mounted at several paths, and two mounts on one path are refused when you create the resource.
spec:
volumes:
- name: rules
configMap:
name: my-rules
volumeMounts:
- name: rules
mountPath: /etc/synapse/rules
readOnly: trueThis mounts the ConfigMap my-rules at /etc/synapse/rules. The default ids.rule_paths is /etc/synapse/rules/*.rules, so Synapse loads every *.rules file in it. A rule_paths in spec.config replaces that default, so it MUST list the mount path too, or the mounted rules are not loaded.
The operator refuses the spec with ConfigValid=False, reason InvalidVolumes, when:
- a volume name is not a DNS label, or a volume sets no source or more than one;
- a volume is named
config,data,bpffs,debugfs,modulesoreve-log, which the operator uses; - a mount names a volume that
spec.volumesdoes not hold; - a mount path is not absolute, or equals, contains or lies inside
/etc/synapse/config,/var/lib/synapse,/sys/fs/bpf,/sys/kernel/debug,/lib/modulesor/var/log/synapse-eve; - a mount sets
subPathorsubPathExpr. Kubelet does not refresh such a mount, so a changed ConfigMap or Secret would never reach the pod.
The message names the entry. What runs is left as it is.
Adding, removing or changing a volume or a mount changes the pod template, so it rolls the DaemonSet. The operator does not check the volume sources. A missing ConfigMap or Secret keeps the pod from starting, and READY stays False.
An edit to a mounted rule file does not reload by itself: Synapse rebuilds its rules only on a reload signal or when config.yaml changes. It takes effect at the next restart, or whenever Synapse rebuilds its rules first, which happens only under XDP with the IDS on. Synapse rebuilds them on a change to spec.ids.rules, HOME_NET or another rule or variable setting, on an update of the platform-managed rules, and on SIGHUP. An enforceBlock change alone does not rebuild them. At a rebuild, every pod loads the mounted files as soon as its kubelet has synced the volume. So an edit staged in a mounted ConfigMap MAY go live on some nodes before you restart. To roll it out, run kubectl -n <ns> rollout restart daemonset/<name> right after the edit. Use spec.ids.rules when you want the edit to reload at once.
Six IDS settings are hot: rule_paths, address_vars (HOME_NET included), port_vars, flow_timeout_secs, max_flows and enforce_block, under ids and firewall.ids. A change confined to them updates the config Secret in place. The pods are not replaced. Synapse reloads the file once kubelet has synced the mounted Secret, which takes up to about a minute.
Every other change rolls the DaemonSet, one node at a time by default. The pod template carries a hash of the configuration without the six settings (synapse.gen0sec.com/restart-config-hash), so only a change to the rest replaces pods. A new image, a new resource limit and the like roll it in the usual way.
When ids.enabled is false, every change rolls, since no IDS worker would reload the file.
The hot swap runs only in the XDP IDS worker. Under AF_PACKET, a hot change never reaches a running pod. It takes effect at the next restart, including a HOME_NET change, which also feeds the never-ban guard. Restart it yourself: kubectl -n <ns> rollout restart daemonset/<name>.
| Condition | Meaning |
|---|---|
ConfigValid |
True (Rendered) when the spec renders to a Synapse configuration. False carries InvalidConfig (a refused key, an entry that is not an address, bad text), InvalidVolumes (a volume or mount the operator refuses), SecretNotFound or SecretKeyNotFound (the API-key reference), RulesSourceNotFound, RulesKeyNotFound, RulesSourceInvalid or RulesTooLarge (spec.ids.rules) |
Ready |
The DaemonSet runs the spec as it is written |
Reasons of Ready:
| Reason | Meaning |
|---|---|
Applied |
The DaemonSet runs the current template and every pod is available. The Secret is applied, but kubelet may not have synced the file yet, and Synapse may not have reloaded it. A hot change is not confirmed by this |
RollingOut |
The DaemonSet is not yet observed, or not every pod runs the current template or is available |
NoMatchingNodes |
No node matches the node selector and tolerations |
ConfigInvalid |
ConfigValid is false. What runs is left as it is |
NameCollision |
An object of the same name that the agent does not own is in the way. Nothing is written until it is gone |
synapse_operator_agent_ready{namespace,name} is 1 while Ready is true and 0 otherwise. The series is deleted with the agent.
The agent.enabled toggle exists only in the synapse-stack chart (an alias of the synapse subchart, off by default). For a standalone synapse release that runs as the agent, uninstall that release instead.
Both paths leave a window. Pick one.
Overlap first keeps the node protected, and costs a window of two agents. What happens depends on the Helm agent:
- Without the
/sys/fs/bpfmount (the chart's default), the second attach is either refused, so the new agent skips the interface, or it replaces the Helm agent's program, depending on the attach mode. - With the mount, the new agent opens the pinned link and swaps its program in. Nothing is refused, and the two agents share the pins and run two firewalls.
-
Create the
SynapseAgentand wait forREADYto beTrue. -
Remove the Helm agent (
agent.enabled=false). -
Restart the new agent:
kubectl -n <ns> rollout restart daemonset/<name>. The attach happens when the pod starts, so an interface it skipped stays skipped until then. -
Read the pod's log. Look for these lines:
XDP: skipped N interface(s) that already have a foreign XDP program: an interface was skipped.Failed to attach XDP to '<iface>': ...: the attach failed, for example when the Helm agent holds a pinned link.thalamus IDS capture auto-resolved to AF_PACKET recvfrom (XDP unavailable): the IDS fell back.XDP/BPF: no interface attached: no interface got XDP.
Synapse then falls back to AF_PACKET for the IDS and to nftables or iptables for the firewall, and
READYis stillTrue.
Gap first has no overlap and no skipped interface, and costs a node that is unprotected between the two steps. Remove the Helm agent, then create the SynapseAgent. It is the simpler path where a short gap is acceptable.
The operator's objects carry no app.kubernetes.io/name label, so the chart's selectors, and the config-hash controller's --label-selector, never match them.
A SynapseAgent and a SynapseProxy MUST NOT share a name in one namespace. They would collide on the ServiceAccount, and the operator refuses with NameCollision.
Common
| Flag | Default | Purpose |
|---|---|---|
--metrics-bind-address |
:8080 |
Metrics endpoint address |
--health-probe-bind-address |
:8081 |
Health probe address |
--leader-elect |
false |
Leader election for the controller manager |
--namespace |
(all) | Restrict the watch to one namespace |
Before this default, it was app.kubernetes.io/name=synapse. An install that does not pass --label-selector now also selects workloads named synapse-proxy and synapse-agent. The first reconcile after the upgrade stamps a hash on each of them, which rolls each once. When a proxy and an agent share a namespace, they also share that namespace's hash, so a change to the agent's config rolls the proxy: set --per-workload-config-hash to avoid it.
Config-sync mode
| Flag | Default | Purpose |
|---|---|---|
--label-selector |
app.kubernetes.io/name in (synapse,synapse-proxy,synapse-agent) |
Selects config sources and workloads. Objects controlled by one of the operator's own resources (synapse.gen0sec.com) are left alone even when they match: the controller for that resource rolls them |
--config-hash-annotation |
synapse.gen0sec.com/config-hash |
Annotation key for the hash |
--ignore-configmap-keys |
upstreams.yaml |
Comma-separated ConfigMap keys excluded from the hash; the ca-<hex>.pem files beside upstreams.yaml are ignored with it |
--ignore-secret-keys |
(none) | Comma-separated Secret keys excluded from the hash |
SynapseProxy
| Flag | Default | Purpose |
|---|---|---|
--proxy-controller |
false |
Run SynapseProxy resources. Needs the CRD and the role in config/proxy-controller. Composable with the default config-sync controller and the resolvers; refused with --ingress-mode and --config-sync |
--cluster-domain |
cluster.local |
Cluster DNS domain, for a backend that has no cluster IP |
SynapseAgent
| Flag | Default | Purpose |
|---|---|---|
--agent-controller |
false |
Run SynapseAgent resources. Needs the CRD in config/crd and the role in config/agent-controller. Composable with the default config-sync controller, --proxy-controller and the resolvers; refused with --ingress-mode and --config-sync |
Ingress / Gateway API mode (--ingress-mode)
| Flag | Default | Purpose |
|---|---|---|
--render-once |
false |
One-shot: render upstreams.yaml and exit (initContainer prime) |
--ingress-class |
synapse |
spec.ingressClassName this controller serves |
--upstreams-out |
/shared/upstreams.yaml |
Path of the rendered upstreams file (sidecar layout) |
--upstreams-out-configmap |
(none) | Central layout: write the rendered upstreams.yaml to this ConfigMap (namespace/name) instead of a file. Only the upstreams.yaml key is updated; other keys are preserved. Synapse reloads from its ConfigMap mount. |
--upstreams-ca-dir |
(the SynapseProxy mount, /etc/synapse/upstreams) |
Used only with --upstreams-out-configmap. Absolute directory the proxies read the ca-<hex>.pem files from; the routes name each CA file there. Set it to the config-sync sidecar's --out-dir (/shared) when the proxies read the ConfigMap through config-sync. A relative value stops the operator at startup. |
--resolve-backend-cluster-ips |
false |
Emit <clusterIP>:port instead of <svc>.<ns>.svc.<cluster-domain>:port, so Synapse skips backend DNS (falls back to the FQDN for headless / ExternalName / unallocated Services) |
--cluster-domain |
cluster.local |
Cluster DNS domain for backend FQDNs |
--certs-out |
(disabled) | Directory to project referenced TLS Secrets into |
--gateway-api |
false |
Also reconcile Gateway API (requires the CRDs) |
--publish-status-address |
(none) | IPs/hostnames to publish on matched Ingresses' status |
--reload-process-name |
synapse |
argv0 of the co-located proxy to SIGHUP |
--status-leader-election |
false |
Only the Lease holder writes shared status (>1 replica) |
--status-leader-election-id |
synapse-ingress-status |
Lease name for the shared-status election |
--leader-election-namespace |
$POD_NAMESPACE |
Namespace for the shared-status Lease |
Config-sync mode (--config-sync) — the thin reload sidecar
| Flag | Default | Purpose |
|---|---|---|
--watch-configmap |
(required) | ConfigMap to project, as namespace/name. Repeatable. |
--out-dir |
/shared |
Directory to project ConfigMap keys into (the volume shared with synapse) |
--sync-keys |
(all) | Comma-separated data keys to project |
--sync-once |
false |
One-shot: project once, guarantee --ensure-files, exit (initContainer) |
--ensure-files |
upstreams.yaml |
Filenames that must exist in --out-dir before synapse starts. A missing one is created as an empty v2 document (Synapse 0.7.0 or newer) |
--reload-process-name |
synapse |
argv0 of the co-located proxy to SIGHUP |
--reload-debounce |
500ms |
Coalesce SIGHUP bursts |
A ConfigMap mount is not a real-time delivery mechanism. kubelet re-projects a mounted ConfigMap on its own sync loop, so the delay scales with the kubelet's syncFrequency, which defaults to 1m. In central mode nothing signals the proxy either: SignalReload is disabled whenever --upstreams-out-configmap is set, and upstreams.yaml sits in --ignore-configmap-keys so the config-hash controller deliberately does not roll the pods. Delivery depends entirely on kubelet propagation.
Config-sync reads the ConfigMap through the API instead, collapsing that to a single watch event:
ConfigMap write -> watch event -> write <out-dir>/<key> -> SIGHUP
which lands well inside a second. Synapse is untouched — it still just reads a file and reloads.
Measured on a single-node k3s cluster: Ingress created → proxy actually serving the route, at both the default syncFrequency and a tuned-down one.
syncFrequency: 1m (kubelet default), n=5
| min | median | max | |
|---|---|---|---|
| ConfigMap mount | 55.151s | 69.600s | 75.497s |
| config-sync sidecar | 0.159s | 0.190s | 0.254s |
syncFrequency: 10s (tuned), n=10
| min | median | max | |
|---|---|---|---|
| ConfigMap mount | 2.555s | 6.572s | 8.573s |
| config-sync sidecar | 0.157s | 0.189s | 0.270s |
The mounted path tracks syncFrequency — a 6x shorter sync loop bought a 10.6x lower median — while the sidecar is flat at ~0.19s across both. That is the point: the sidecar does not shorten the kubelet leg, it removes it. It reads the ConfigMap through the API and writes to an emptyDir, which kubelet never re-projects.
The median worst case exceeds syncFrequency itself (75.5s against a 60s loop) because the total is the remaining sync interval plus jitter, the remount, and synapse's own 500ms settle debounce.
Isolating the kubelet leg alone — ConfigMap write until the file changes inside the pod — the sidecar lands in 7–9ms.
shareProcessNamespace: trueon the pod, so the sidecar can see the synapse PID.runAsUser: 0on the sidecar container. The operator image is distroless nonroot (USER 65532) while synapse runs as root, sosyscall.KillreturnsEPERMwithout it.appArmorProfile: {type: Unconfined}on the sidecar, on any AppArmor-enforcing host (most Ubuntu/Debian installs). uid parity is not sufficient: the sidecar runs under containerd's default AppArmor profile, which only permits signalling peers in the same profile, while a privileged synapse is unconfined. The kernel then denies the signal regardless of uid orCAP_KILL:Failure here is degraded rather than fatal — synapse still picks the file up via its own inotify watch, just after the 500ms settle debounce instead of immediately.apparmor="DENIED" operation="signal" profile="cri-containerd.apparmor.d" signal=hup peer="unconfined"- A
--sync-onceinitContainer. Not optional: synapse-proxy does a blocking initial read of its upstreams file and, if that read fails, aborts its whole background service without ever establishing a file watch — so a pod that starts before the file exists stays deaf to every later update rather than recovering. - Metrics/health binds disabled (the mode forces
0unless overridden). synapse binds:8080for health in the same pod netns, which collides with the operator's metrics default. - RBAC:
configmaps: get,list,watchin the namespace. It cannot be narrowed to a single ConfigMap —resourceNamesis ignored forlist/watch, which a watch-based informer requires.
A missing source ConfigMap is not an error and never prunes files: leaving the last-good upstreams.yaml in place degrades to stale routing, whereas truncating it takes every route down at once.
Nothing changes on the operator side unless a route names a CA. Central mode keeps rendering into the same ConfigMap, so the sidecar is purely additive on the proxy pod — you can migrate one workload at a time, and the old mounted path stays valid throughout, which is what makes rollback trivial.
A route with upstream-tls-ca breaks that. --upstreams-ca-dir applies to the
whole operator and to every proxy that reads its ConfigMap: once it is
/shared, a proxy still on the mounted path finds no CA file and refuses the
routes file. With such routes, move every proxy that reads the ConfigMap to
config-sync before you set the flag, and unset it before you roll one back. Or
run a second operator and ConfigMap for the proxies on config-sync.
The two capabilities are independent switches. --config-sync changes how
config is delivered; --resolve-backend-endpoints changes how backends are
addressed. Adopt either alone.
Phase 0 — upgrade synapse first. Take a build with the atomic reload publication fix before anything else. It is a no-op at today's reload rate and needs no config change, but the later phases raise the reload rate, and the older clear-then-repopulate applier has a window where a concurrent lookup misses and the request 502s. Order matters here.
Phase 1 — delivery (--config-sync). A pod-spec change, so it takes a
rollout. Start from examples/config-sync-values.yaml in the synapse-stack
chart; the moving parts are:
proxy.shareProcessNamespace |
true, so the sidecar can see the synapse PID |
proxy.volumes / volumeMounts |
a shared emptyDir mounted at /shared in both containers |
proxy.initContainers |
operator with --config-sync --sync-once --ensure-files=upstreams.yaml |
proxy.extraContainers |
the long-running sidecar, runAsUser: 0 and appArmorProfile: Unconfined |
proxy.configSync.rbac.create |
true — configmaps: get,list,watch in the namespace |
proxy.synapse.config |
point proxy.upstream.conf at /shared/upstreams.yaml |
| the central operator's arguments | --upstreams-ca-dir=/shared, the sidecar's --out-dir, when an Ingress or HTTPRoute names a CA (upstream-tls-ca). A SynapseProxy is not affected: its routes always name its own mount |
The routes file names each CA file by path. Without --upstreams-ca-dir, the
path is under /etc/synapse/upstreams, the kubelet mount, which is
re-projected about a minute after the sidecar has written the file. Synapse
then refuses the routes file and keeps its old routes. With the flag, the
routes name /shared/ca-<hex>.pem, which the sidecar writes before
upstreams.yaml. --sync-keys MUST include the ca-<hex>.pem files, or stay
empty (all keys); a list that leaves them out never delivers the CA files.
Leave the ConfigMap projection in place. Once conf points at /shared the
mounted upstreams.yaml is inert, but keeping it means reverting is a values
change rather than a re-plumb.
Verify: the sidecar logs SIGHUP → reload (not a permission error), synapse
logs Loading upstreams configuration from: /shared/upstreams.yaml, and an
Ingress edit is served in well under a second.
Phase 2 — addressing (--resolve-backend-endpoints). Operator-side flag
plus the endpointslices RBAC rule. Verify the rendered upstreams.yaml
flips from one <svc>.<ns>.svc.<domain>:<servicePort> entry to a sorted list
of <podIP>:<targetPort>. Check the port: pods listen on targetPort,
so a Service of 80 → targetPort 8080 must render :8080. If it renders
:80, the mapping is wrong and every request fails.
Roll back either phase independently by reverting the values; the ConfigMap is maintained the whole time.
Things that bite:
- The
--sync-onceinitContainer is not optional. synapse does a blocking initial read of its upstreams file and, if that read fails, aborts its background service without ever establishing a file watch — a pod that starts before the file exists stays deaf to every later update rather than recovering. appArmorProfile: Unconfinedis required on any AppArmor-enforcing host. uid parity alone is not enough; see Deployment requirements above. TheappArmorProfilefield needs Kubernetes 1.30+, otherwise use thecontainer.apparmor.security.beta.kubernetes.io/<container>: unconfinedannotation.- RBAC cannot be narrowed to a single ConfigMap —
resourceNamesis ignored forlist/watch, which a watch-based informer requires. If read on every ConfigMap in the namespace is unacceptable, put the rendered ConfigMap in a namespace of its own. - Don't let the sidecar bind a port synapse already uses; it defaults its metrics and health binds to off for this reason.
config.yamlstill arrives via the ConfigMap mount. That is deliberate — most of it is restart-only and a change there rolls the pod anyway, and a fresh pod is populated at mount time rather than on the sync loop. Add it to--sync-keysif you want it delivered the same way.
--resolve-backend-endpoints (ingress-mode) renders the ready pod IPs from EndpointSlices as the server list, instead of a single Service address.
Without it the renderer emits a Service FQDN and synapse resolves it through its in-process DNS cache, which pins the first A record only, is configured once at startup, and does not evict on a failed re-resolve — so a replaced pod can keep receiving traffic long after it is gone. Pod IPs are literals, so synapse never resolves them at all, and a pod change re-renders immediately.
Details that matter:
- The port comes from the EndpointSlice, not the Service. Pods listen on
targetPort; pairing a pod IP with the Service port fails on every request. - All slices for a Service are unioned (by the
kubernetes.io/service-namelabel) and the result is sorted — API ordering is unstable, and an unsorted list would make every reconcile look like a change. Ready == nilcounts as ready (the API contract for unknown readiness); only an explicitfalseexcludes, as doesTerminating.- Dual-stack renders IPv4 when any IPv4 endpoint exists, otherwise IPv6. Unioning both would enter each pod twice.
- An empty result falls back to ClusterIP/FQDN rather than rendering an empty server list, which would be a 502 for every request to that host.
- Requires
discovery.k8s.io/endpointslices: get,list,watch. The watch is only registered when the flag is set.
| Gen0Sec Docs | Product documentation and guides |
| Synapse | The NDR/proxy this operator manages |
config/ |
Kustomize deployment: namespace, ServiceAccount, RBAC, manager |
config/proxy-controller/ |
What --proxy-controller needs on top: the SynapseProxy CRD and its role |
test/e2e/ |
End-to-end test of a SynapseProxy on k3s |
SECURITY.md |
Security policy and disclosure |
- Kubernetes SIGs for controller-runtime
- Kubernetes Gateway API for the Gateway API