syn

Kubernetes monitoring

Syn can watch one or more Kubernetes clusters. It uses two separate, read-only paths:

Path What it reads Needs Feeds
Security Onion / Elasticsearch container logs, Kubernetes warning events, API server request metrics, pod / container / node metrics, IDS and detection alerts on node and pod IPs the Elastic Agent Kubernetes integration in each cluster, shipping to the same Elasticsearch Devices → Kubernetes (signals, events, API server, pods), the watcher (every event window, default 5 min), Open events
Kubernetes API (one read-only account per cluster) cluster configuration: namespaces, workloads, pods, services, ingresses, network policies, RBAC, control-plane flags, running image digests a ServiceAccount token with get/list/watch only CIS benchmark, Kubernetes map, container image updates and CVEs

The two paths are independent. A cluster without the Elastic Agent still gets the CIS benchmark, the map and the image checks. A cluster without an API account still gets the log, event and alert monitoring.

Syn never changes a cluster. It does not read secrets, ConfigMaps or pod logs through the API (logs come only from Elasticsearch), and it cannot exec into pods.

Setup

Logs, events and metrics (Elasticsearch)

Add the Elastic Agent Kubernetes integration to the cluster’s Fleet policy with these inputs:

kube-state-metrics is optional. When it is missing, the Security Onion data coverage box lists the state_* data sets as errors, and the nightly run reports them once.

Elasticsearch documents from Kubernetes carry no cluster name, so Syn attributes each document to the cluster that owns the node that sent it. For that matching to work, the cluster also needs an API account (next section).

Read-only API account (per cluster)

  1. Apply docs/kubernetes-readonly.yaml in the cluster. It creates:
    • the netmon-readonly namespace with pod security set to restricted;
    • a ServiceAccount, with the default account’s token automount turned off;
    • a long-lived token Secret;
    • a ClusterRole and binding with get / list / watch on named resources only.

    The role does not include secrets, configmaps, pods/log, pods/exec, pods/attach, pods/portforward, nodes/proxy (the kubelet API, which can be abused to run commands) or serviceaccounts/token.

  2. Read the token and the cluster CA:
    kubectl -n netmon-readonly get secret netmon-readonly-token -o jsonpath='{.data.token}' | base64 -d
    kubectl config view --raw --minify -o jsonpath='{.clusters[0].cluster.certificate-authority-data}' | base64 -d
    
  3. In Settings → Configuration → Integrations, fill in the Kubernetes API: add a cluster card:
    • a short name;
    • the API server URL(s), comma-separated, one per control-plane node;
    • the token and the CA.
  4. Click Test connection. It shows the version and node count. It also asks the API server (SelfSubjectAccessReview) whether the token may list secrets, create pods, exec, use nodes/proxy, delete or update. If any answer is yes, Test reports that the token is not read-only.
  5. Turn on Enabled (and Run CIS benchmark checks), then click Save.

The token is write-only: it is stored on the server and never shown again. The API server certificate is always verified. Each configured cluster has its own card, and Remove cluster deletes the cluster and its token.

What Syn checks

From Elasticsearch (k8s.py)

Pod pivot. Click a pod anywhere to open its page. It shows the pod notes, links to Kibana, the log volume (stderr marked) and the newest container logs with text, container and stream filters, plus its security hits, warning events and alerts. A workload name (from a pod note or the Risk page) shows all its pods.

Through the API

Risk page

Every workload (Deployment, StatefulSet, DaemonSet, Job, bare pod) is scored with the same model as hosts and ranked in the same list. Show switches between hosts and containers, hosts only, and containers only.

Container vulnerabilities ranked by risk lists each weakness per workload, with how to fix it. Workloads with an ingress or an external service weigh 1.4×. Workload names link to the pod pivot page.

Pod notes

Pods are temporary: they get a new name on every restart, rollout or reschedule. So a pod note is not stored on a pod. It is stored on the object that creates the pods - its Deployment, StatefulSet, DaemonSet, CronJob or Job - and applies to every pod that object makes, today’s and the ones it creates later. The subject is pod:<cluster>/<namespace>/<kind>/<name>, for example pod:talos/opencti/deployment/opencti-worker. A pod nothing creates (a static pod such as kube-apiserver-<node>) keeps its notes under kind pod and its own name. The owner comes from the Security Onion pod fields (a ReplicaSet maps to its Deployment, a CronJob’s Job to its CronJob). Notes written with the older subject pod:<cluster>/<namespace>/<workload> are still read.

In the dashboard:

Findings and events

Every result above becomes a host finding with a key starting k8s-. So the correlation, the review job, auto-close, Posture and Open events handle them like any other endpoint finding.

Key Priority Raised by
k8s-log\|cmd/miner/webattack\|… Investigate watcher + nightly
k8s-log\|secret\|…, k8s-api\|exec, k8s-api\|denied, k8s-cov\|…, k8s-img\|… Review watcher + nightly
k8s-ev\|… forbidden / PodSecurity events Review watcher + nightly
k8s-ev\|… other warning events, k8s-log\|… auth / denied / TLS / crash hits Info (low in Open events) nightly snapshot only
k8s-alert\|<rule> high Security Onion alert on a node or pod Investigate nightly

Failed CIS checks and container images with critical/high CVEs fixed by an available update are things to fix, not events. They go to Security → Fix list (k8s-cis|<cluster>|<id>, k8s-imgcve|<repo>, with how to fix them), not to endpoint findings or Open events. Accepted checks (k8s.cis_accept) are left out, and a check that passes again moves to Fixed.

Several clusters

Every Kubernetes page has a Cluster selector at the top: All clusters or one cluster. The choice is kept in the browser.

Components

Module Runs in Access
k8s.py host (broker, watcher, collector) Elasticsearch read-only
kube_api.py host Kubernetes API: GET + SelfSubjectAccessReview, TLS verified, fails over between API server URLs
kube_cis.py, kube_map.py host (broker, collector) through kube_api.py
kube_images.py host (scheduler job k8simages, broker Scan now) kube_api.py, registries (anonymous HTTPS), Docker for Trivy
static/k8s.js, static/k8smap.js dashboard /api/k8s* → host broker /k8s

The dashboard holds neither the Elasticsearch key nor any Kubernetes token. Everything goes through the loopback host broker (/k8s, actions overview, pod, clusters, map, cis, cis_run, images, image, images_run).