This guide will help you get started with developing the Kyverno website. It covers setup, project structure, common tasks, and development workflows.
Before you begin, ensure you have the following installed:
- Node.js v24 or higher (Download)
- npm package manager
- Git for version control
- Docker (optional, for generating CLI documentation)
git clone https://github.com/kyverno/website.git
cd websiteIf you're contributing, you should fork the repository first and clone your fork:
git clone https://github.com/YOUR-GITHUB-ID/website.git
cd websiteWe're using NPM as dependency manager
npm installnpm run devThe development server will start at http://localhost:4321. The site will automatically reload when you make changes to source files.
.
├── public/ # Static assets (images, favicons, etc.)
│ └── assets/
│ ├── images/ # Image assets
│ └── product-icons/ # Product/company icons
├── src/
│ ├── components/ # React components (JSX)
│ ├── constants/ # Constants and configuration data
│ ├── content/ # Content files (Markdown/MDX)
│ │ └── docs/ # Documentation content
│ │ ├── blog/ # Blog posts
│ │ ├── docs/ # Documentation pages
│ │ └── policies/ # Policy examples (generated)
│ ├── layouts/ # Astro layout components
│ ├── pages/ # Astro pages (file-based routing)
│ ├── sections/ # Page section components
│ ├── styles/ # Global CSS styles
│ └── content.config.ts # Content collection configuration
├── scripts/ # Development scripts and tools
│ ├── render-policies.ts # Policy rendering tool (TypeScript)
│ └── codegen-cli-docs.sh # CLI documentation generator
├── astro.config.mjs # Astro configuration
├── package.json # Dependencies and scripts
└── tsconfig.json # TypeScript configuration
npm run dev- Start the development server atlocalhost:4321npm run start- Alias fordevcommand
npm run build- Build the production site to./dist/npm run preview- Preview the production build locally
npm run format:check- Check code formatting with Prettiernpm run format:write- Format code with Prettiernpm run check:links- Validate all internal and external links in the documentation
The project uses npm scripts for generating content:
npm run codegen:policies- Generate policy markdown files from the kyverno/policies repositorynpm run codegen:cli-docs- Generate CLI documentation from the kyverno-cli Docker image
You can also run both in sequence:
npm run codegen:policies && npm run codegen:cli-docsThis website is built with:
- Astro - Static site generator
- Starlight - Documentation theme for Astro
- React - UI library (via
@astrojs/react) - Tailwind CSS - Utility-first CSS framework
- Framer Motion - Animation library
- Lucide React - Icon library
- Prettier - Code formatter
- Husky - Git hooks
-
Create a branch for your changes:
git checkout -b your-feature-branch
-
Make your changes to the relevant files:
- React components:
src/components/orsrc/sections/ - Content:
src/content/docs/ - Styles:
src/styles/ - Pages:
src/pages/
- React components:
-
Preview your changes:
npm run dev
Visit
http://localhost:4321to see your changes. -
Format your code:
npm run format:write
-
Test the production build:
npm run build npm run preview
Documentation pages are written in Markdown (.md) or MDX (.mdx) and located in src/content/docs/docs/. The sidebar is automatically generated from the directory structure as configured in astro.config.mjs.
Link Formatting Guidelines:
- Use absolute paths for internal documentation links (e.g.,
/docs/policy-types/cluster-policy/validate) - Avoid relative links (e.g.,
../validate.mdor./validate.md) as they can break when pages are moved or reorganized - Remove file extensions from links (use
/docs/path/to/pageinstead of/docs/path/to/page.md) - Use anchor links for specific sections (e.g.,
/docs/policy-types/cluster-policy/validate#anchors)
Examples:
✅ Good:
[Validate Policy](/docs/policy-types/cluster-policy/validate)
[Installation Guide](/docs/installation#methods)❌ Bad:
[Validate Policy](../validate.md)
[Installation Guide](./installation/methods.md#methods)Blog posts are located in src/content/docs/blog/ and organized by category (e.g., general/, releases/).
Policy examples are generated from the kyverno/policies repository. To regenerate them:
npm run codegen:policiesThis will:
- Clone the kyverno/policies repository (shallow clone, single branch)
- Find all YAML policy files recursively
- Extract metadata from policy annotations
- Generate markdown files with frontmatter and full YAML content
- Preserve the directory structure from the source repository
The generated files are placed in src/content/policies/. The script uses TypeScript and requires Node.js v24+.
React components are located in src/components/ and src/sections/. They use JSX syntax and can be imported in Astro files:
---
import MyComponent from '../components/MyComponent.jsx'
---
<MyComponent />The project uses Tailwind CSS for styling. You can use Tailwind utility classes directly in components. Global styles are in src/styles/.
The website includes automatically generated content that should be regenerated when upstream sources change.
Policy documentation is generated from the kyverno/policies repository. The TypeScript script (scripts/render-policies.ts) fetches policies and converts them to markdown format.
Usage:
Default (uses kyverno/policies repository):
npm run codegen:policiesCustom repository and output directory:
npm run codegen:policies -- <repo-url> <output-dir>Example with custom arguments:
npm run codegen:policies -- https://github.com/kyverno/policies/main ./src/content/policies/What it does:
- Clones the specified GitHub repository (shallow clone, single branch)
- Recursively finds all YAML policy files (
.yamlor.yml) - Extracts metadata from policy annotations:
policies.kyverno.io/titlepolicies.kyverno.io/categorypolicies.kyverno.io/minversionpolicies.kyverno.io/subjectpolicies.kyverno.io/description
- Determines policy type (
validate,mutate, orgenerate) from the spec - Generates markdown files with frontmatter and full YAML content
- Preserves the directory structure from the source repository
Output format: Each generated markdown file includes:
- Frontmatter with policy metadata (title, category, version, subject, policyType, description)
- A link to the raw YAML file on GitHub
- The complete policy YAML in a code block
Requirements:
- Node.js v24 or higher
- Dependencies installed (
npm install) - Git (for cloning repositories)
CLI documentation is generated from the kyverno-cli Docker image:
npm run codegen:cli-docsThis script:
- Removes existing CLI documentation files
- Runs the kyverno-cli Docker container to generate documentation
- Outputs markdown files to
src/content/docs/docs/kyverno-cli/reference/
Requirements:
- Docker installed and running
- Access to pull
ghcr.io/kyverno/kyverno-cliimage
Before committing changes, ensure generated content is up to date. You can verify by:
-
Running the codegen scripts:
npm run codegen:policies npm run codegen:cli-docs
-
Checking git status to see if any files changed:
git status
-
If files changed, commit them along with your changes
Note: Generated content should be committed to the repository so the website can be built without requiring codegen steps during deployment.
- Visual Testing: Use the development server to visually inspect your changes
- Build Testing: Run
npm run buildto ensure the site builds without errors - Format Checking: Run
npm run format:checkto ensure code is properly formatted - Link Checking: Run
npm run check:linksto validate all links in the documentation (both internal and external) - Code Generation: Run
npm run codegen:policiesandnpm run codegen:cli-docsto ensure generated content is up to date, then checkgit statusfor any changes
The check:links command validates all links in the documentation to ensure they are correct and accessible. This is especially important when:
- Adding new documentation pages
- Moving or renaming existing pages
- Updating links between pages
- Fixing broken links
Usage:
npm run check:linksThis command will:
- Build the site with link validation enabled
- Check all internal documentation links
- Verify external links are accessible
- Report any broken or invalid links
Note: The link checker will fail the build if any broken links are found. Fix any reported issues before committing your changes. The link checker uses the Starlight Links Validator plugin.
- Create a new file in
src/components/(e.g.,MyComponent.jsx) - Write your React component
- Import and use it in your pages or layouts
- Create a new
.mdor.mdxfile in the appropriate directory undersrc/content/docs/docs/ - The sidebar will automatically include it based on the directory structure
- Use frontmatter to configure the page:
---
title: My Page Title
description: Page description
---Edit astro.config.mjs and modify the sidebar configuration in the Starlight config.
- Use Tailwind utility classes directly in components
- Add global styles to
src/styles/global.cssorsrc/styles/custom.css
The project uses Husky for git hooks. The prepare script automatically sets up git hooks when you run npm install. These hooks help ensure code quality before commits.
The site is deployed to Netlify. The build command is npm run build, and the publish directory is dist/.
- Documentation: See README.md and CONTRIBUTING.md
- Issues: Report issues on GitHub Issues
- Community: Join the Kyverno Slack or CNCF Slack
- Meetings: See Community Meetings