Overview
CronJob Guardian follows Kubernetes security best practices with least-privilege RBAC, secure secret handling, and optional network isolation. This document covers security configuration and hardening recommendations.RBAC Requirements
The operator requires specific Kubernetes permissions to function. RBAC resources are defined inconfig/rbac/.
ServiceAccount
File:config/rbac/service_account.yaml
ClusterRole (Manager Role)
File:config/rbac/role.yaml
The main ClusterRole grants permissions needed by the operator:
- Read-only: Events, Namespaces, Pods, Secrets, CronJobs, Jobs, Pod logs
- Full access: AlertChannel and CronJobMonitor CRDs
- No write access to core Kubernetes resources (CronJobs, Jobs, Pods)
Leader Election Role
File:config/rbac/leader_election_role.yaml
Required when leader-election.enabled: true:
Metrics Authentication Role
File:config/rbac/metrics_auth_role.yaml
Required when metrics.secure: true:
User Roles (Optional)
Pre-defined roles for users managing Guardian resources:CronJobMonitor Roles
Admin:AlertChannel Roles
Similar admin/editor/viewer roles exist for AlertChannels. Grant to users:Secrets Management
CronJob Guardian uses Kubernetes Secrets for sensitive data like webhook URLs, API tokens, and SMTP passwords.Channel Secrets
AlertChannels reference secrets for credentials: Example: Slack webhook secretCross-Namespace Secret Access
Security consideration: The operator can read secrets from any namespace (due to ClusterRole). Best practices:- Store channel secrets in operator namespace
- Use namespace-scoped AlertChannels when possible
- Audit secret access via API server audit logs
- Consider using external secret managers (see below)
Database Credentials
PostgreSQL password via environment variable:GUARDIAN_STORAGE_POSTGRES_PASSWORD
External Secret Management
Integrate with external secret managers:AWS Secrets Manager (External Secrets Operator)
HashiCorp Vault
Pod Security
Security Context
The operator runs with restrictive security settings: Deployment security context:Pod Security Standards
The operator complies with Restricted Pod Security Standard:readOnlyRootFilesystem: false). Use PostgreSQL/MySQL for fully read-only root filesystem.
Network Security
Network Policies
Restrict Metrics Access
File:config/network-policy/allow-metrics-traffic.yaml
Restrict UI Access
Egress Policies
Restrict outbound connections:TLS Configuration
Metrics Endpoint TLS
With cert-manager:Database TLS
PostgreSQL with SSL:sslrootcert parameter (requires custom DSN construction).
Audit Logging
Kubernetes Audit Logs
Enable audit logging to track Guardian API access:Application Logging
Sensitive data redaction: The operator automatically redacts:- Secret values from logs
- Database passwords
- API tokens and webhook URLs
Security Best Practices
Deployment
- Use least-privilege RBAC - Only grant necessary permissions
- Enable Pod Security Standards - Use “Restricted” profile
- Run as non-root - Never use UID 0
- Drop all capabilities - No special Linux capabilities needed
- Use read-only root filesystem - Where possible (PostgreSQL/MySQL)
- Enable seccomp - Use RuntimeDefault profile
- Network policies - Restrict ingress and egress
Secrets
- Use external secret managers - AWS Secrets Manager, HashiCorp Vault
- Rotate secrets regularly - Automated rotation via External Secrets Operator
- Namespace isolation - Store secrets in operator namespace
- Encrypt etcd - Enable encryption at rest
- Audit secret access - Monitor who reads secrets
- Never commit secrets - Use .gitignore, scan repositories
Network
- Enable TLS everywhere - Metrics, webhooks, database connections
- Use cert-manager - Automated certificate management
- Network policies - Explicit allow-list approach
- Private endpoints - Don’t expose UI/API publicly without authentication
- mTLS for sensitive channels - Consider mutual TLS for webhooks
Database
- Strong passwords - Use password generators
- SSL/TLS required - Never use plaintext connections
- Separate database user - Don’t use database admin account
- Connection limits - Set appropriate pool sizes
- Encrypt at rest - Enable database encryption
- Regular backups - Automated, encrypted backups
- Network isolation - Database in private subnet
Monitoring
- Audit logs enabled - Track all Guardian operations
- Alert on RBAC changes - Monitor ClusterRole modifications
- Monitor secret access - Unusual secret read patterns
- Track alert deliveries - Failed alerts may indicate compromise
- Resource limits - Prevent resource exhaustion attacks
Compliance Considerations
Data Protection
What data is stored:- Job execution metadata (timestamps, status, duration)
- Exit codes and failure reasons
- Pod logs (if enabled) - may contain sensitive information
- Alert history
- Job logs may contain customer data
- Suggested fixes generated from logs
- Alert messages sent to channels
- Disable log storage unless required:
log-storage-enabled: false - Use shorter retention:
log-retention-days: 7 - Implement data retention policies aligned with compliance requirements
- Encrypt database at rest
- Use encrypted backups
- Implement access controls on UI/API
Access Controls
Who can access what:- Cluster admins: Full access to Guardian resources and database
- Namespace admins: Can create CronJobMonitors in their namespaces
- Developers: Viewer access via RBAC
- Operators: Access to UI/API (implement authentication)
- Prometheus: Read-only metrics access
- Implement authentication on UI/API (OAuth2, OIDC)
- Use separate monitoring dashboards per team
- Grant least-privilege RBAC
- Regular access reviews
Incident Response
Compromise Scenarios
Scenario 1: Secret leakage- Rotate all affected secrets immediately
- Update AlertChannel resources with new secret references
- Check audit logs for unauthorized access
- Review alert history for suspicious activity
- Delete compromised pod (new one will be created)
- Check for unauthorized CRD modifications
- Review database for data tampering
- Rotate database credentials
- Analyze container image for backdoors
- Isolate database (network policies)
- Rotate database credentials
- Review data for exfiltration
- Restore from clean backup if needed
- Audit application logs
Security Contacts
Report security vulnerabilities:- GitHub Security Advisories: https://github.com/iLLeniumStudios/cronjob-guardian/security/advisories
- Email: [email protected] (if available)
Security Checklist
Production deployment security checklist: RBAC:- ServiceAccount with least-privilege ClusterRole
- No cluster-admin permissions
- User roles configured (admin/editor/viewer)
- Regular RBAC audits scheduled
- All secrets stored in Kubernetes Secrets or external manager
- No hardcoded credentials in configs
- Secret rotation policy defined
- etcd encryption at rest enabled
- NetworkPolicies configured (ingress + egress)
- TLS enabled for metrics endpoint
- Database connections use SSL/TLS
- UI/API not publicly exposed or has authentication
- runAsNonRoot: true
- allowPrivilegeEscalation: false
- capabilities dropped (ALL)
- seccompProfile: RuntimeDefault
- Pod Security Standards: Restricted
- Strong password (>20 characters)
- SSL/TLS required for connections
- Separate database user (not admin)
- Connection pooling configured
- Regular encrypted backups
- Kubernetes audit logging enabled
- Alerts on RBAC changes
- Metrics access restricted
- Failed alert delivery monitoring
- Data retention policy documented
- Log storage disabled or justified
- Access controls implemented
- Regular security reviews scheduled