Policy-as-Code Agent
Policy-as-Code Agent
The Policy-as-Code AI agent is an intelligent CLI assistant that helps you create, test, and manage Kyverno policies using natural language. Instead of writing complex YAML by hand, you can describe what you want to achieve, and the AI agent will help you with:
- Natural Language Policy Creation: Describe your policy requirements in plain English
- Automated Test Generation: Creates test cases to validate your policies
- Resource Generation: Creates example resources for testing
- Git Integration: Prepares policies for submission to Git repositories
- Interactive Mode: Have a conversation with the agent to refine policies
- Local Development: Everything runs locally on your machine
Prerequisites
Before using the Policy-as-Code Agent, you need to be logged into Nirmata:
Get a Free Trial Account:
- Sign up for a 15-day free trial to get your API token.
Login to Nirmata:
nctl login --userid YOUR_USER_ID --token YOUR_API_TOKEN
Installation
Using Homebrew:
brew tap nirmata/tap
brew install nctl@4.8-rc
💡 Tip: If you run into the following error - Error: Cannot install nirmata/tap/nctl@4.8-rc because conflicting formulae are installed.
Unlink nctl first (brew unlink nctl
), and then try to install the RC version.
NOTE: For manual install, download the latest 4.8 RC from https://downloads.nirmata.io/nctl/allreleases/
Quick Start
Start Interactive Mode:
nctl ai
Direct Policy Generation:
nctl ai --prompt "create a policy that requires all pods to have resource limits"
Examples
Best Practices
Start Simple
- Begin with a basic policy description
- Let the AI help you refine it
Review Generated Content
- Always review generated policies
- Test policies before deployment
Iterative Development
- Use the interactive mode to refine policies
- Ask for explanations when needed
Version Control
- Store all generated policies and tests in Git
- Keep policies and tests together
Common Use Cases
Policy Development
- Create new policies from descriptions
- Convert existing policies to Kyverno
- Generate policy variations
Testing
- Create comprehensive test suites
- Generate example resources
- Validate policy behavior
Documentation
- Generate policy documentation
- Create usage examples
- Document test cases