Image Registry Validation Policy
This guide demonstrates how to configure Kyverno to control which container registries can be used in a Kubernetes cluster. It implements registry access control policies to ensure only images from approved and trusted registries are deployed.
TOC
What is Image Registry Validation?
Registry validation provides centralized control over image sources. It enables:
- Control image sources: Only allow images from trusted registries
- Block risky registries: Prevent use of unknown or compromised registries
- Enforce compliance: Meet security requirements about image sources
- Different rules per environment: Strict rules for production, relaxed for development
- Track usage: Monitor which registries are being utilized
Quick Start
1. Block All Except Company Registry
2. Test It
Common Scenarios
Scenario 1: Allow Multiple Trusted Registries
Organizations typically use several registries:
Scenario 2: Different Rules for Different Environments
Production environments should be strict, development can be more flexible:
Scenario 3: Block Specific Risky Registries
Block specific registries while allowing others:
Scenario 4: Team-Specific Registry Access
Different teams can have access to different registries:
Advanced Patterns
Using Wildcards Effectively
Best Practices
Start with Warnings
Exclude System Namespaces
Common Issues
-
Wrong image format:
- ❌
registry.company.com:5000/app(missing protocol) - ✅
registry.company.com/app:latest
- ❌
-
Wildcard confusion:
- ❌
registry.company.com*(missing slash) - ✅
registry.company.com/*
- ❌
-
Docker Hub format:
- ❌
nginx(implicit docker.io) - ✅
docker.io/library/nginx
- ❌