Kubernetes¶
Kubernetes runs containers in clusters; one connector covers one cluster.
- What DRACO uses: Cluster configuration for posture scans and API server audit events.
- What for: Compliance and attack paths, detections and hunts on audit events, response in the cluster.
Add it in Connectors > Add connector: pick Kubernetes, then choose what DRACO collects and what it may change. Add more later with Add a part on its connector page. See Connectors for how connectors, sign-in and tags work.
Parts¶
| Part | What DRACO uses | Access | Permissions |
|---|---|---|---|
| Posture | Kubernetes | read | A read-only ServiceAccount (get and list on pods, configmaps, nodes, namespaces and the RBAC objects) with its token in a kubeconfig context; the API server reachable from DRACO at a public address. |
| Logs | Kubernetes audit logs | read | None in the cluster for DRACO: a self-managed API server posts its audit events to DRACO's ingest URL with the source token (audit webhook); EKS and AKS send them through the edge collector. |
| Response | Cordon node (Kubernetes), Delete pod (Kubernetes), Isolate pod network (Kubernetes), Scale deployment to zero (Kubernetes) | write | Cordon node (Kubernetes): RBAC: get and patch on nodes (cluster scope) Delete pod (Kubernetes): RBAC: get and delete on pods in the namespace Isolate pod network (Kubernetes): RBAC: get on pods; get, create and delete on networkpolicies (networking.k8s.io) in the namespace; a network plugin that enforces NetworkPolicies Scale deployment to zero (Kubernetes): RBAC: get and patch on deployments/scale (apps) in the namespace |
Posture¶
DRACO scans a cluster with a read-only service account in a kubeconfig context.
Connect the provider in DRACO¶
Step 1: Access DRACO¶
- Sign in to DRACO, open Connectors, click Add connector and pick Kubernetes: the wizard opens at Link a Provider.
- Enter the context name of the kubeconfig (steps below) and optionally a friendly alias (the connector's name).
After Launch Scan, the wizard goes on with Collectors (tick Logs for the API server audit events: they need no other sign-in, the wizard asks only for the cluster name in Settings) and Responders (tick Response if DRACO may act in the cluster) on the same connector. Tick nothing more to keep scans only; anything else can be added later with Add a part on the connector page.
Step 2: Configure Kubernetes Authentication¶
For Kubernetes, DRACO uses a kubeconfig file to authenticate. Paste the contents of your kubeconfig file into the Kubeconfig Content field.
Note
Only inline kubeconfig credentials are supported: token, username/password, or client-certificate-data with client-key-data for users, and certificate-authority-data for clusters. Kubeconfigs that reference external files (tokenFile, client-certificate, client-key, certificate-authority), run commands (exec, cmd-path), use auth-provider directives, set a proxy URL, or include unsupported user or cluster fields are rejected. Impersonation fields (as, as-uid, as-groups, as-user-extra) are accepted but not applied, so DRACO connects with the identity of the user credentials. Use inline credentials such as the ServiceAccount token flow documented below.
By default, the kubeconfig file is located at ~/.kube/config.
Step 3: Create the read-only service account and its token (every cluster)¶
DRACO takes only inline credentials, and a typical admin kubeconfig (EKS, GKE, AKS) signs in with a command or files, so every cluster connects with a read-only service account token:
Make sure your cluster allows traffic from the public address of your DRACO server (the API server must be reachable from the DRACO worker)
-
Save the following read-only service account, ClusterRole and binding as
draco-scanner.yaml:apiVersion: v1 kind: Namespace metadata: name: draco-ns --- apiVersion: v1 kind: ServiceAccount metadata: name: draco-sa namespace: draco-ns --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: draco-read-cluster rules: - apiGroups: [""] resources: ["pods", "configmaps", "nodes", "namespaces"] verbs: ["get", "list"] - apiGroups: ["rbac.authorization.k8s.io"] resources: ["clusterrolebindings", "rolebindings", "clusterroles", "roles"] verbs: ["get", "list"] --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: draco-read-cluster-binding roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: draco-read-cluster subjects: - kind: ServiceAccount name: draco-sa namespace: draco-nsThen apply it to the cluster:
kubectl apply -f draco-scanner.yaml -
Generate a token for the service account (set a duration your security policy allows):
kubectl create token draco-sa -n draco-ns --duration=8760h- Note:
--duration=0does not create a non-expiring token: it leaves the lifetime to the API server (often one hour), after which scans fail.8760his one year; renew the token before it expires.
- Note:
Note
Important: If the token expires, DRACO can no longer authenticate with the cluster. Generate a new token and enter the updated kubeconfig with Update Credentials in the provider's row actions.
Warning
Last resort: a token that never expires
When the cluster has --service-account-max-token-expiration, a longer duration is cut to the cluster's maximum. Kubernetes advises against tokens that never expire (they stay valid until the Secret or the ServiceAccount is deleted, even if leaked); prefer renewing the token. If a long-lived token is still needed, create it as a Secret linked to the ServiceAccount:
Steps:
- Create a
secret-sa.yamlfile (or any preferred name) with the following content:
apiVersion: v1
kind: Secret
metadata:
name: draco-token-long-lived
namespace: draco-ns
annotations:
kubernetes.io/service-account.name: "draco-sa"
type: kubernetes.io/service-account-token
- Apply the secret:
kubectl apply -f secret-sa.yaml
- Retrieve the token (which will be permanent):
kubectl get secret draco-token-long-lived -n draco-ns -o jsonpath='{.data.token}' | base64 --decode
-
Update your
kubeconfigto use the ServiceAccount token:kubectl config set-credentials draco-sa --token=<SA_TOKEN> kubectl config set-context <CONTEXT_NAME> --user=draco-saDRACO validates the entire kubeconfig file and requires it to contain only the ServiceAccount user and its cluster entry with certificate-authority-data; remove any exec entries from EKS, GKE, or AKS or DRACO will reject the file.
Replace
<SA_TOKEN>with the generated token and<CONTEXT_NAME>with your KubeConfig Context Name of your EKS, GKE or AKS cluster. -
Paste the modified
kubeconfigin DRACO, click Authenticate, then Check connection. When the connection works, launch the first scan (Run now or On a schedule) and go on with Collectors as described in step 1.
Logs¶
The Kubernetes audit logs data source (kubernetes_audit) receives the audit events of a Kubernetes API server: who (user, groups, service account), which verb on which object (resource, namespace, name, subresource), from which address, and the answer (code, RBAC decision). DRACO's built-in rules find exec into pods, privileged or host-access workloads, cluster-admin bindings, secret dumps, anonymous access and credential minting.
One data source per cluster: its Cluster name becomes the host of every event.
How events reach DRACO¶
| Cluster | Route |
|---|---|
| Self-managed (kubeadm, k3s, RKE2, OpenShift, Talos...) | The API server's audit webhook backend posts batches to DRACO's ingest endpoint with the source token (HTTPS) |
| Amazon EKS | Control plane logging (audit) to CloudWatch Logs, a subscription filter to Kinesis Data Firehose, the Firehose HTTP endpoint on the edge collector |
| Azure AKS | A diagnostic setting sends kube-audit-admin (or kube-audit) to an Event Hub; the edge collector reads it with its Kafka source |
| Google GKE | Audit logs are in Cloud Logging: the Google Cloud audit logs source already reads Admin Activity (turn on Data Access for the Kubernetes Engine API for reads). The Kubernetes rules read the native format only; GKE coverage by the Kubernetes rules is planned |
Self-managed clusters¶
- Turn on Logs on the cluster's connector (Add a part, or Collectors right after Launch Scan when you add the cluster) and enter the cluster name. Push sources are created at once; the source page shows the endpoint, the token and the files.
- On every control plane node, save the audit policy shown on the source page as
/etc/kubernetes/audit/policy.yaml. It drops health checks, leases and events, records secrets, config maps and tokens atMetadataonly (never their content) and the bodies of workloads, RBAC objects and certificate requests atRequest(the privileged-pod and cluster-admin rules need them). - Save the webhook kubeconfig as
/etc/kubernetes/audit/draco-webhook.kubeconfig(chmod 600: it holds the source token asuser.token, sent asAuthorization: Bearer). - Add the kube-apiserver flags (
--audit-policy-file,--audit-webhook-config-file,--audit-webhook-mode=batch...) to/etc/kubernetes/manifests/kube-apiserver.yamland mount/etc/kubernetes/audit(hostPath, read-only). The API server restarts. - The ingest endpoint must present a certificate the API server trusts (a public CA, or
certificate-authority-datain the kubeconfig). - Run
kubectl get podsand check Last event.
The API server posts EventList batches (up to 400 events); DRACO stores one event per audit event, and a batch retried by the API server is stored once (the event id comes from auditID and stage).
Amazon EKS¶
- EKS > the cluster > Observability > Manage logging: turn on Audit. Logs go to the log group
/aws/eks/<cluster>/cluster, streamskube-apiserver-audit-*. - Run the edge collector where Firehose can reach it over HTTPS (a public certificate is required by Firehose) and add the EKS collector snippet from the source page to its
vector.yaml; put this source's token indraco-secrets.jsonaskubernetes_tokenand a random access key asfirehose_access_key. - Create a Kinesis Data Firehose stream: source Direct PUT, destination HTTP endpoint
https://<collector>:8443, access key =firehose_access_key, content encoding GZIP. - CloudWatch Logs > the log group > Subscription filters > Create Kinesis Firehose subscription filter, filter pattern empty, with an IAM role that may
firehose:PutRecord*.
The collector unpacks the CloudWatch Logs batches and forwards one audit event per line. CloudWatch Logs ingestion and Firehose are billed by AWS (audit logs are verbose: estimate from the cluster's request rate).
Azure AKS¶
- The AKS cluster > Diagnostic settings > Add: category kube-audit-admin (writes only, much cheaper) or kube-audit (reads too), destination Stream to an event hub (Standard tier or higher, which has the Kafka endpoint).
- Add to the collector a Kafka source on
<namespace>.servicebus.windows.net:9093(SASL PLAIN, user$ConnectionString, the event hub's connection string fromdraco-secrets.json), aremapthat keeps the records of categorykube-audit*and setsmessagetoproperties.log, and anhttpsink withencoding.codec: textand this source's token (as in the EKS snippet).
What DRACO collects¶
| Column | From |
|---|---|
ts |
stageTimestamp |
actor_user |
user.username (system:serviceaccount:<ns>:<name> for service accounts) |
src_ip |
the first of sourceIPs |
action |
the verb (create, get, list, patch, delete...) |
resource_uid |
the object path, namespaces/<ns>/<resource>/<name>[/<subresource>] |
status |
success for 2xx and 101, else failure |
url, user_agent |
requestURI, userAgent |
host |
the cluster name of the source |
message |
"[email protected] create pods/exec payments/api-7d9f from 203.0.113.10: allow (101)" |
The whole audit event stays in the fields (objectRef, user.groups, responseStatus, annotations, requestObject at Request level).
IDs resolved (Readable IDs): user UID → username (service accounts and impersonated users too); object UID (objectRef, request or response object) → namespace/name.
Built-in rules (draco-edr-network)¶
| Rule | When |
|---|---|
| exec or attach into a pod (recommended) | pods/exec or pods/attach by anyone but nodes and kube-system service accounts |
| privileged or host-access workload created (recommended) | privileged, hostPID, hostIPC, hostNetwork or hostPath in a created or changed workload |
| cluster-admin granted (recommended) | a (Cluster)RoleBinding to cluster-admin or admin |
| many secrets read by a person | 10 secret reads in 10 minutes by a user that is not system:* |
| anonymous request allowed (recommended) | system:anonymous answered with success (health endpoints excepted) |
| certificate request approved or token minted by a person | CSR create or approval, or a TokenRequest, by a non-system user |
Response¶
Runs response actions on the Kubernetes cluster from incidents and workflows: Cordon node (Kubernetes), Delete pod (Kubernetes), Isolate pod network (Kubernetes) and Scale deployment to zero (Kubernetes).
Setup: Response actions.
Troubleshooting¶
- No events: check the API server logs for
audit webhookerrors (TLS trust, 401 for a wrong token, 413 for a batch above the ingest body limit: lower--audit-webhook-batch-max-size). - Privileged-pod or cluster-admin rule never fires: the policy must record workloads and RBAC objects at
Requestlevel. - Too many events: keep
get,listandwatchof system components atNone(the DRACO policy does).