aks-app-routing-operator
CLAUDE.md40 starsChanged 2 years agoMITView on GitHub
The AKS Web Application Routing Operator is a Kubernetes operator that manages resources for AKS Application Routing functionality. It's built using the Kubebuilder framework and manages several Custom Resource Definitions (CRDs) for routing, DNS, and certificate management. Some test packages (e.g. pkg/controller/dns/) use controller-runtime's envtest and require Kubernetes API server binaries. Use setup-envtest to install them and set KUBEBUILDER_ASSETS: If setup-envtest use -p path doesn't expand correctly in your shell, run setup-envtest use first to see the path, then set…
- Installs packages
The file
We split this CLAUDE.md into the rules it gives an agent
6 rules. About 0 are common, 2 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 31
If setup-envtest use -p path doesn't expand correctly in your shell, run setup-envtest use first to see the path, then set it directly:
- Distinctive: line 65
Default domain certificate controllers (when enabled)
- Very specific: line 140
Test changes with make unit before submitting PRs
- Very specific: line 141
If asked, verify changes with make e2e
- Distinctive: line 150
All unit tests must pass
- Very specific: line 179
Run make unit to ensure unit tests all pass
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
The AKS Web Application Routing Operator is a Kubernetes operator that manages resources for AKS Application Routing functionality. It's built using the Kubebuilder framework and manages several Custom Resource Definitions (CRDs) for routing, DNS, and certificate management.
Development Commands
Building and Testing
make help- Display all available make targetsmake unit- Run unit tests using Docker development environmentmake unit-vis- Run unit tests and create visualization outputmake docker-build-dev- Build the development Docker image for testing
Running Unit Tests Locally (without Docker)
Some test packages (e.g. pkg/controller/dns/) use controller-runtime's envtest and require Kubernetes API server binaries. Use setup-envtest to install them and set KUBEBUILDER_ASSETS:
# Install setup-envtest if not already installed
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
# Install envtest binaries and run tests
setup-envtest use
export KUBEBUILDER_ASSETS="$(setup-envtest use -p path)"
go test ./pkg/controller/dns/ -v -count=1If setup-envtest use -p path doesn't expand correctly in your shell, run setup-envtest use first to see the path, then set it directly:
KUBEBUILDER_ASSETS=<path from setup-envtest output> go test ./pkg/controller/dns/ -v -count=1Packages that don't use envtest (e.g. pkg/config/, pkg/controller/, pkg/manifests/) can be tested directly with go test.
Code Generation
make crd- Generate all CRD-related files (calls generate and manifests)make generate- Generate DeepCopy, DeepCopyInto, and DeepCopyObject methodsmake manifests- Generate CRD manifests and RBAC configurations
Development Environment
make clean- Clean development environment state and Terraform filesmake dev- Deploy a complete development environment (AKS cluster + Azure resources)make push- Build and push operator image to development environment
End-to-End Testing
make e2e- Run complete end-to-end testsmake e2e-deploy- Run only the deploy phase of e2e tests
Architecture Overview
Main Components
Operator Entry Point: cmd/operator/main.go - Main operator executable that sets up the manager and controllers
Controller Manager: pkg/controller/controller.go - Central manager that orchestrates all controllers:
- ExternalDNS controller for DNS management
- NginxIngressController reconciler for ingress management
- OSM (Open Service Mesh) integration controllers
- KeyVault secret provider class controllers
- Gateway API controllers (when enabled)
- Default domain certificate controllers (when enabled)
Custom Resource Definitions:
NginxIngressController- Manages NGINX ingress controller deploymentsExternalDNS(namespaced) - Manages DNS records for specific namespacesClusterExternalDNS(cluster-scoped) - Manages DNS records cluster-wideDefaultDomainCertificate- Manages default TLS certificates
Key Packages
API Layer (api/v1alpha1/): Contains CRD type definitions and validation logic
Controllers (pkg/controller/):
nginxingress/- NGINX ingress controller managementdns/- External DNS functionalityosm/- Open Service Mesh integrationkeyvault/- Azure Key Vault secret managementservice/- Service-level ingress reconciliationcommon/- Shared controller utilities
Configuration (pkg/config/): Operator configuration management and validation
Manifests (pkg/manifests/): Kubernetes manifest generation utilities.
Testing Framework (testing/e2e/): End-to-end testing infrastructure with support for multiple cluster configurations
Controller Architecture
The operator uses controller-runtime with:
- Leader election for high availability (active-passive model)
- Field indexers for efficient resource lookups
- Custom caching strategies to reduce memory usage on large clusters
- Structured logging with zap logger
- Prometheus metrics integration
Key indexers:
nicIngressClassIndex- Links ingress resources to NGINX ingress classesgatewayListenerIndexName- Associates Gateway listeners with service accounts
Configuration
Environment Variables and Flags
Configuration is handled through pkg/config/config.go with support for:
- Service account token path customization
- Metrics and health probe addresses
- Feature flags (Gateway API, Default Domain, etc.)
- Namespace and deployment name configuration
Feature Flags
EnableGateway- Enables Gateway API supportEnableDefaultDomain- Enables default domain certificate managementDisableExpensiveCache- Reduces memory usage by selective caching
Testing Strategy
Unit Tests
- Standard Go testing with Docker-based development environment
- Tests are located alongside source files (
*_test.go) - Mock implementations in
pkg/controller/testutils/
End-to-End Tests
- Comprehensive integration testing on real AKS clusters
- Multiple infrastructure configurations: basic, private, and OSM clusters
- Matrix testing across operator versions and configurations
- Automated testing on PRs via GitHub Actions
Test Infrastructure
E2E tests support various cluster configurations defined in testing/e2e/infra/infras.go:
basic-cluster- Standard public clusterprivate-cluster- Private AKS clusterosm-cluster- Cluster with Open Service Mesh enabled
Development Workflow
Local Development
- Test changes with
make unitbefore submitting PRs - If asked, verify changes with
make e2e
Development Environment Options
CLUSTER_TYPE- Set to "public" or "private" for cluster typeTF_VAR_location- Override default Azure region- Infrastructure provisioning uses Terraform
Pull Request Process
- E2E tests are triggered via
/ok-to-test sha=<sha>comment by repository writers - All unit tests must pass
- CRD generation must be up to date (
make crd)
Important Files and Directories
PROJECT- Kubebuilder project configurationconfig/crd/bases/- Generated CRD manifestsdevenv/- Development environment Terraform and scriptsdocker/- Dockerfiles for operator and development imagesdocs/- Additional documentation (e2e, local testing, releases)
Azure Integration
The operator integrates deeply with Azure services:
- Azure DNS for external DNS management
- Azure Key Vault for certificate storage
- AKS-specific networking and ingress patterns
- Azure Container Registry for image management
- Azure RBAC and service principal authentication
Common tasks
Upgrade Go version
To upgrade the Go version perform the following steps
- Determine what the latest version of Go is
- Upgrade the go.mod by changing the go directive to the new version of Go
- Run
go mod tidy - Upgrade the base dockerfiles to use the new Go image in ./docker directory
- Run
make unitto ensure unit tests all pass
Note: The CI workflow files (unit.yaml, e2e.yaml, provision-test.yaml) use go-version-file: 'go.mod' to read the Go version automatically, so no workflow changes are needed when bumping Go.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

