Catalog
Kubernetes
Kubernetes
| Pack name | Kubernetes |
| Version | 1.0.0 |
| Vendor | Cloud Native Computing Foundation (CNCF) |
| Capabilities | Parser · Streaming Rules · Correlation Rules · Dashboard |
| Categories | Cloud · Container · Kubernetes · Infrastructure |
Overview
Pack cung cấp giám sát bảo mật toàn diện Kubernetes cluster trên SecOps platform, bao gồm:
- Parser — chuẩn hóa 3 loại log K8s (pod container logs, cluster events, API audit logs) sang ECS
- 7 streaming rules — phát hiện CrashLoop, API auth failure, container error/fatal, pod scheduling fail, resource deletion, container killed
- 2 correlation rules — phát hiện container error spike và API auth burst
- 1 dashboard — 12 chart giám sát SOC cluster health và security
Yêu cầu trước khi cài đặt
| Yêu cầu | Chi tiết |
|---|---|
| Log shipper | Fluentd với kubernetes_metadata_filter hoặc Filebeat với add_kubernetes_metadata processor |
| Container logs | Stdout/stderr của pod — thu thập tự động qua node-level log driver |
| Cluster events | Kubelet event recording — mặc định enabled trong hầu hết distributions |
| API audit logs | Bật API server audit: --audit-log-path, --audit-policy-file |
Định dạng log bắt buộc
{
"message": "<log line from container or event message>",
"timestamp": "2024-01-15T10:30:00.000Z",
"kubernetes": {
"pod_name": "webapp-deployment-abc12-xyz9",
"namespace_name": "production",
"container_name": "webapp",
"container_id": "docker://a1b2c3d4e5f6abcd1234",
"pod_id": "pod-uid-1234-abcd-5678-efgh",
"host": "k8s-worker-node-01",
"labels": { "app": "webapp" }
}
}
Parser phân biệt loại log theo cấu trúc JSON và nội dung message. Kubernetes metadata được extract từ object
kubernetes.*.
Ví dụ log hợp lệ
Container log — ERROR level:
{"@timestamp":"2024-01-15T10:30:00.000Z","message":"ERROR Failed to connect to database: connection refused after 30s","timestamp":"2024-01-15T10:30:00.000Z","kubernetes":{"pod_name":"webapp-deployment-abc12-xyz9","namespace_name":"production","container_name":"webapp","container_id":"docker://a1b2c3d4e5f6abcd1234","pod_id":"pod-uid-1234-abcd","host":"k8s-worker-node-01","labels":{"app":"webapp"}}}
Cluster event — CrashLoopBackOff:
{"@timestamp":"2024-01-15T10:35:00.000Z","message":"Back-off restarting failed container webapp in pod webapp-deployment-abc12-xyz9_production(pod-uid-1234)","timestamp":"2024-01-15T10:35:00.000Z","kubernetes":{"pod_name":"webapp-deployment-abc12-xyz9","namespace_name":"production","container_name":"webapp","container_id":"docker://a1b2c3d4e5f6abcd1234","pod_id":"pod-uid-1234","host":"k8s-worker-node-01"}}
API audit log — authorization failure:
{"@timestamp":"2024-01-15T10:40:00.000Z","message":"{\"kind\":\"Event\",\"apiVersion\":\"audit.k8s.io/v1\",\"verb\":\"delete\",\"user\":{\"username\":\"system:serviceaccount:default:bad-actor\"},\"responseStatus\":{\"code\":403,\"message\":\"Forbidden\"}}","timestamp":"2024-01-15T10:40:00.000Z","kubernetes":{"pod_name":"kube-apiserver-master","namespace_name":"kube-system","container_name":"kube-apiserver","host":"k8s-master-01"}}
Parser tự động phát hiện loại log qua nội dung message (BackOff, FATAL, ERROR prefix, JSON audit structure).
Cài đặt
- Vào Marketplace → tìm "Kubernetes Security" → Install
- Kiểm tra Parsers →
kubernetes-parserđang active - Kiểm tra Detection Rules → filter tag Kubernetes → 9 rules đang enabled
- Mở Dashboards → Kubernetes Security Overview
Parser — Các trường ECS chính
| ECS Field | Nguồn | Mô tả |
|---|---|---|
event.action | Derived từ message | crash_loop, auth_failure, container_error, resource_delete... |
event.outcome | Derived | success / failure |
log.level | Message prefix hoặc API response code | error, fatal, warning |
container.name | kubernetes.container_name | Tên container |
container.id | kubernetes.container_id | Container ID |
host.hostname | kubernetes.host | Node hostname |
user.name | API audit user.username | User thực hiện API call |
labels.namespace | kubernetes.namespace_name | Kubernetes namespace |
Detection Rules
Streaming Rules (7 rules — real-time)
| # | Rule | Severity | Mô tả |
|---|---|---|---|
| 1 | Kubernetes Container CrashLoop | High | Container liên tục crash và restart — service instability hoặc misconfiguration nghiêm trọng |
| 2 | Kubernetes API Authorization Failure | Medium | API call bị từ chối vì không đủ quyền — unauthorized access hoặc misconfigured RBAC |
| 3 | Kubernetes Container Error Log | Low | Container log ở level ERROR — application error cần điều tra |
| 4 | Kubernetes Pod Scheduling Failed | Medium | Pod không thể schedule lên node — resource constraint hoặc taint/toleration issue |
| 5 | Kubernetes Resource Deletion Event | Medium | Tài nguyên K8s bị xóa qua API — giám sát xóa deployment, service, configmap bất thường |
| 6 | Kubernetes Container Fatal Log | High | Container log ở level FATAL — lỗi nghiêm trọng dẫn đến service crash |
| 7 | Kubernetes Container Killed | Medium | Container bị kill bởi OOMKiller hoặc liveness probe failure |
Correlation Rules (2 rules — pattern)
| # | Rule | Severity | Mô tả | Ngưỡng | Lookback |
|---|---|---|---|---|---|
| 8 | Kubernetes Container Error Spike | High | Đột biến error log từ cùng container — service đang gặp sự cố nghiêm trọng | > 20 error | 10 phút |
| 9 | Kubernetes API Auth Failure Burst | High | Nhiều API auth failure từ cùng user — brute-force service account hoặc token abuse | > 10 lần | 5 phút |
Dashboard — Kubernetes Security Overview
| # | Chart | Loại | Mô tả |
|---|---|---|---|
| 1 | Events Trend | LINE | Trend security events theo thời gian |
| 2 | Total Events | METRIC | Tổng số sự kiện K8s |
| 3 | CrashLoop Events | METRIC | Tổng container crash events |
| 4 | API Auth Failures | METRIC | Tổng API authorization failures |
| 5 | Container Error/Fatal Logs | METRIC | Tổng ERROR/FATAL container logs |
| 6 | Event Action Distribution | PIE | Phân bố loại sự kiện |
| 7 | Log Level Distribution | PIE | ERROR vs FATAL vs WARNING |
| 8 | Top Crashing Containers | BAR | Container bị crash nhiều nhất |
| 9 | Top API Failure Users | BAR | Service account có nhiều auth failure nhất |
| 10 | Top Namespaces by Events | BAR | Namespace có nhiều sự kiện nhất |
| 11 | Recent Critical Events | TABLE | 20 sự kiện CrashLoop/Fatal gần nhất |
| 12 | Recent API Auth Failures | TABLE | 20 API auth failure gần nhất |
SOC Triage nhanh:
- Metric 3 → CrashLoop cao → service instability, kiểm tra deployment config
- Metric 4 → API failures cao → RBAC misconfiguration hoặc unauthorized access
- Chart 8 → một container crash liên tục → điều tra application và resource limits
- Table 12 → xác nhận service account bị lạm dụng
Troubleshooting
| Triệu chứng | Nguyên nhân | Cách xử lý |
|---|---|---|
| Không có event | Thiếu kubernetes metadata | Kiểm tra Fluentd/Filebeat có kubernetes_metadata_filter enabled |
| Chỉ có container logs | API audit logs chưa bật | Enable API server audit: --audit-log-path và --audit-policy-file |
container.name trống | JSON thiếu kubernetes.container_name | Kiểm tra cấu hình log shipper output JSON structure |
| CrashLoop không detect | Message format khác | Kiểm tra kubelet event message chứa "Back-off restarting failed container" |
| Parser không khớp | Parser bị tắt | Kiểm tra kubernetes-parser.yaml đang active trong Parsers |
Checklist parser:
- JSON có đủ
message,timestamp,kubernetesobject -
kubernetes.pod_name,kubernetes.namespace_name,kubernetes.container_namecó giá trị - API audit logs được forward nếu cần giám sát API security
-
kubernetes-parser.yamlđang active
Hỗ trợ
- Lỗi platform: Mở ticket tại SecOps support portal
- Góp ý pack: Dùng tính năng feedback trên trang Marketplace
- Tuning rule: Slack
#detection-engineering
Last updated: 2026-06-04 · Vendor: CNCF · Author: secops-team