Skip to content

Real-time Kubernetes pod security monitoring and enforcement: dashboard, Helm, Gatekeeper, Pod Security Admission.

License

Notifications You must be signed in to change notification settings

bharats487/k8s-pod-security-monitor

Repository files navigation

<<<<<<< HEAD

Kubernetes Pod Security Monitoring & Enforcement

License: MIT GitHub stars GitHub issues Last Commit

This project provides real-time monitoring and best-practice enforcement for Kubernetes pod security, combining:

  • Live monitoring of pod security violations (Python backend + web dashboard)
  • Automated enforcement of Pod Security Standards and Gatekeeper policies
  • Helm chart for easy deployment of security controls

Features

  • Real-time alerts for pods violating security best practices (privileged, missing securityContext, etc.)
  • Web dashboard for instant visibility
  • Enforce Kubernetes Pod Security Admission (PSA) at namespace level
  • Gatekeeper policy to block privileged containers
  • Helm chart for automated setup

Directory Structure

  • backend/ — Python Flask backend for real-time pod monitoring
  • frontend/ — Simple web dashboard for alerts
  • helm-chart/ — Helm chart to label namespaces and enforce privileged-block policy
  • k8s_pod_security_enforcement.yaml — Example manifest for PSA enforcement
  • gatekeeper_privileged_block.yaml — Gatekeeper constraint YAML

Quick Start

1. Real-Time Monitoring

  1. Install Python requirements:
    pip install -r requirements.txt
  2. Ensure your kubeconfig is set (access to cluster).
  3. Run backend:
    python backend/main.py
  4. Open frontend/index.html in your browser.

2. Enforce Pod Security Admission (PSA)

  • Apply PSA enforcement to a namespace:
    kubectl apply -f k8s_pod_security_enforcement.yaml

3. Enforce Gatekeeper Policy

  • Install Gatekeeper
  • Apply privileged-block constraint:
    kubectl apply -f gatekeeper_privileged_block.yaml

4. Automated via Helm

  1. Edit helm-chart/values.yaml to set your namespace (default: secure-apps).
  2. Deploy with Helm:
    helm install pod-security-enforcement ./helm-chart

Extend & Customize

  • Add more constraints in helm-chart/templates/
  • Extend monitoring logic in backend/main.py
  • Integrate dashboard with alerting systems (Slack, email, etc.)

References & Best Practices


For production use, always test policies in audit mode first and review official Kubernetes/Gatekeeper documentation.

k8s-pod-security-monitor

Real-time Kubernetes pod security monitoring and enforcement: dashboard, Helm, Gatekeeper, Pod Security Admission.

60e87cbb0d60bd3b6acb262702fc4e4bd9f1a9cf

About

Real-time Kubernetes pod security monitoring and enforcement: dashboard, Helm, Gatekeeper, Pod Security Admission.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published