You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Kubernetes API Operations Analysis
==================================
Step 1: Extracting operationIds from swagger.json...
Swagger URL: https://raw.githubusercontent.com/kubernetes/kubernetes/refs/heads/master/api/openapi-spec/swagger.json
Output file: swagger_operations.txt
Downloading swagger specification...
Extracted 1062 operationIds to swagger_operations.txt
No CI audit endpoints file specified, auto-discovering latest from GCS...
Searching for latest CI audit run...
Enumerating directories in gs://kubernetes-ci-logs/logs/ci-kubernetes-audit-kind-conformance...
Found directory with finished.json: gs://kubernetes-ci-logs/logs/ci-kubernetes-audit-kind-conformance/1960318661684105216/
Found audit file at: gs://kubernetes-ci-logs/logs/ci-kubernetes-audit-kind-conformance/1960318661684105216/artifacts/audit/audit-endpoints.txt
Downloaded to: ci-audit-kind-conformance-audit-endpoints.txt
Step 2: Comparing audit endpoint files...
CI File: ci-audit-kind-conformance-audit-endpoints.txt
Pull File: audit/audit-endpoints.txt
Extracting operations from audit files (filtering by swagger operations)...
SUMMARY
=======
Total Operations in Swagger: 1062
Operations in CI: 508
Operations in Pull: 517
Operations Added: 9
Operations Removed: 0
Net Change: +9
OPERATIONS ADDED IN PULL (NOT IN CI)
====================================
Count: 9
1. createResourceV1DeviceClass
2. createResourceV1NamespacedResourceClaim
3. createResourceV1NamespacedResourceClaimTemplate
4. createResourceV1ResourceSlice
5. deleteResourceV1DeviceClass
6. deleteResourceV1NamespacedResourceClaim
7. readResourceV1NamespacedResourceClaim
8. replaceResourceV1NamespacedResourceClaim
9. replaceResourceV1NamespacedResourceClaimStatus
OPERATIONS REMOVED FROM PULL (IN CI BUT NOT PULL)
=================================================
Count: 0
No operations removed.
STABLE ENDPOINTS NOT FOUND IN PULL AUDIT LOG
============================================
Count: 29
These are stable, non-deprecated API endpoints defined in the Swagger spec
but not exercised in the pull request audit log:
1. connectCoreV1PostNamespacedPodExec
2. connectCoreV1PostNamespacedPodPortforward
3. createStorageV1VolumeAttributesClass
4. deleteResourceV1CollectionDeviceClass
5. deleteResourceV1NamespacedResourceClaimTemplate
6. deleteResourceV1ResourceSlice
7. deleteStorageV1CollectionVolumeAttributesClass
8. deleteStorageV1VolumeAttributesClass
9. getResourceV1APIResources
10. listResourceV1ResourceClaimTemplateForAllNamespaces
11. listStorageV1VolumeAttributesClass
12. patchCoreV1NamespacedPodResize
13. patchResourceV1DeviceClass
14. patchResourceV1NamespacedResourceClaim
15. patchResourceV1NamespacedResourceClaimStatus
16. patchResourceV1NamespacedResourceClaimTemplate
17. patchResourceV1ResourceSlice
18. patchStorageV1VolumeAttributesClass
19. readCoreV1NamespacedPodResize
20. readResourceV1DeviceClass
21. readResourceV1NamespacedResourceClaimStatus
22. readResourceV1NamespacedResourceClaimTemplate
23. readResourceV1ResourceSlice
24. readStorageV1VolumeAttributesClass
25. replaceCoreV1NamespacedPodResize
26. replaceResourceV1DeviceClass
27. replaceResourceV1NamespacedResourceClaimTemplate
28. replaceResourceV1ResourceSlice
29. replaceStorageV1VolumeAttributesClass
Analysis complete!
Generated files:
- swagger_operations.txt (swagger operations list)
Outputs
audit_log_parser.py
audit/audit-endpoints.txt: Human-readable report (602 operations, 79K API calls)
audit/audit-operations.json: JSON with up to 5 audit samples per operation
kubernetes_api_analysis.py
Console output: Comparison showing added/removed operations vs CI baseline
swagger_operations.txt: Complete list of 1062 Swagger operations
How It Works
Each operation flows through this pipeline:
swagger.json → audit_log_parser.py → audit-endpoints.txt → kubernetes_api_analysis.py
↓ ↓ ↓ ↓
POST /apis/ requestURI match Line 98: | 1 "OPERATIONS ADDED"
resource... → operationId (1 API call) (new in this PR)
The Kubernetes conformance audit system ensures that new API endpoints reaching General Availability (GA) are properly covered by conformance tests, preventing technical debt accumulation and maintaining API testing integrity across the project.
Overview
The conformance audit process automatically tracks API endpoint usage through audit logs and compares it against conformance test coverage, flagging gaps that need attention from contributors and maintainers.
Key Components
Swagger/OpenAPI Specification: The authoritative definition of Kubernetes APIs in swagger.json
Audit Log Analysis: Scripts that parse Kubernetes audit logs to identify API endpoint usage
Endpoint Tracking Files: YAML files that categorize endpoints as pending, ineligible, or conformance-ready
CI Jobs: Automated jobs that run the analysis and report on compliance
Conformance Audit Workflow
The conformance audit system operates through a continuous integration pipeline that validates API endpoint coverage:
Entry format: Simple list of operation IDs from swagger.json that correspond to stable API endpoints that should have conformance test coverage but don't yet.
Ineligible Endpoints
Endpoints explicitly excluded from conformance testing for valid technical or policy reasons.
Optional features: Components not required in all Kubernetes distributions (NetworkPolicy, HPA)
Debug features: Development and troubleshooting tools (port forwarding, pod attach)
Administrative endpoints: Operations that distributions may restrict for security
Unstable features: APIs that lack stable implementations across providers
Each entry includes the endpoint name, exclusion reason, and link to relevant issue discussion.
Example entries:
- endpoint: connectCoreV1DeleteNodeProxyreason: "Unable to be tested, and likely soon deprecated"issue: "https://github.com/kubernetes/kubernetes/issues/12345"
- endpoint: readAuthorizationV1NamespacedLocalSubjectAccessReview reason: "Optional feature - not all distros implement RBAC authorization"issue: "https://github.com/kubernetes/kubernetes/issues/67890"
- endpoint: connectCoreV1GetNamespacedPodPortforwardreason: "Explicitly designed to be a debug feature"issue: "https://github.com/kubernetes/kubernetes/issues/24680"
Entry format: Structured YAML with endpoint name, justification, and reference to community discussion.
Audit Analysis Scripts
audit_log_parser.py
Purpose: Parses Kubernetes audit logs and maps entries to official API specifications.
Key functions:
Downloads current swagger.json specification
Processes audit log JSON entries
Maps log entries to OpenAPI operation IDs
Generates usage statistics and operation samples
Outputs:
Console report with endpoint counts and matches
audit-endpoints.txt: Sorted list of endpoints with usage counts
audit-operations.json: Sample audit entries for each operation
Command line usage:
# Basic usage with single audit log
python3 audit_log_parser.py --audit-logs audit.log
# Process multiple audit log files
python3 audit_log_parser.py --audit-logs audit-*.log
# Custom swagger URL and sorting
python3 audit_log_parser.py --audit-logs audit.log \
--swagger-url https://custom.k8s.io/swagger.json \
--sort count
# Output to specific file
python3 audit_log_parser.py --audit-logs audit.log \
--output results/
Solution: Verify swagger.json format and ensure it's accessible
Step-by-Step Resolution Guides
Marking Endpoints as Ineligible
Problem: Your PR adds endpoints that shouldn't be part of conformance testing.
Step-by-step resolution:
Document the reasoning:
# Add to ineligible_endpoints.yaml
- endpoint: connectCoreV1GetNamespacedPodExecreason: "Debug feature requiring special cluster permissions"issue: "https://github.com/kubernetes/kubernetes/issues/12345"
Create or reference issue:
Title: Conformance exemption: Pod exec endpoint
Body: The connectCoreV1GetNamespacedPodExec endpoint should be
exempt from conformance testing because:
1. It's primarily a debug/development feature
2. Requires special RBAC permissions that conformance tests avoid
3. Implementation varies significantly across distributions
Follow established patterns:
Review existing ineligible entries for similar reasoning
Ensure your exemption follows community precedent
Get SIG approval for controversial exemptions
Enforcement Process
For Pull Request Authors
When the presubmit job identifies issues, contributors must follow the appropriate scenario guide above. The system enforces:
Stable endpoints not in pending_eligible_endpoints.yaml: Must be added to pending list or have conformance tests
Endpoints in pending_eligible_endpoints.yaml that are now tested: Must be removed from pending list
New ineligible endpoints: Must be documented in ineligible list with justification
Error Messages and Resolution
"Stable endpoint X not found in pending_eligible_endpoints.yaml"
Cause: New GA endpoint lacks conformance test coverage
Resolution: Add endpoint to pending list or create conformance test
"Endpoint X found in pending_eligible_endpoints.yaml but is being tested"
Cause: Endpoint now has conformance test coverage
Resolution: Remove from pending list as no longer needed
Technical Implementation Details
Audit Log Collection
The conformance audit system relies on comprehensive Kubernetes audit logging during test execution:
Audit Policy Configuration:
# policy.yaml - Captures all API server requestsapiVersion: audit.k8s.io/v1kind: Policyrules:
- level: Requestnamespaces: ["default", "kube-system"]verbs: ["get", "list", "create", "update", "patch", "delete"]resources:
- group: ""resources: ["*"]
- group: "apps"resources: ["*"]
# CI job uploads artifacts to GCS
gsutil -m cp -r artifacts/audit/* \
gs://kubernetes-ci-logs/pr-logs/pull/${PULL_NUMBER}/pull-kubernetes-audit-kind-conformance/${BUILD_ID}/artifacts/audit/
Troubleshooting
CI Job Failures
Build failures: Check build logs for:
KIND cluster creation issues
Test execution failures
Script execution errors
Artifact generation problems
Analysis failures: Common issues:
Swagger specification download problems
Audit log parsing errors
GCS access permission issues
File format inconsistencies
Script Execution Issues
Local development:
# Run audit log parser
python3 audit_log_parser.py --audit-logs audit.log
# Compare against CI baseline
python3 kubernetes_api_analysis.py
Requirements:
Python 3.x
Network access for downloading specifications
gsutil installed for GCS operations
Valid audit log files in JSON format
Common Resolution Steps
Check network connectivity for specification downloads
Verify file permissions for audit logs and output files
Validate JSON format of audit log entries
Ensure gsutil authentication for GCS access
Review script error output for specific failure details
Best Practices
For API Developers
Update tracking files promptly:
# Good workflow - immediate tracking
git add api/openapi-spec/swagger.json
git add test/conformance/testdata/pending_eligible_endpoints.yaml
git commit -m "Add new stable endpoint to pending conformance listThe createAppsV1NamespacedDeployment endpoint is now stable butlacks conformance test coverage. Tracked in issue #12345."
Provide clear justifications:
# Good documentation in ineligible_endpoints.yaml
- endpoint: connectCoreV1GetNamespacedPodPortforwardreason: "Debug feature: requires special permissions, varies by implementation"issue: "https://github.com/kubernetes/kubernetes/issues/24680"# Poor documentation
- endpoint: someEndpointreason: "doesn't work"# Too vagueissue: ""# Missing reference
Test locally before submitting:
# Complete local validation workflow# 1. Run conformance tests with audit logging
kind create cluster --config kind-audit-config.yaml
export KUBECONFIG="$(kind get kubeconfig-path)"
go test ./test/e2e/... --ginkgo.focus="Conformance"# 2. Parse audit logs
python3 audit_log_parser.py --audit-logs /tmp/audit.log
# 3. Compare against baseline
python3 kubernetes_api_analysis.py --baseline-file previous-endpoints.txt
# 4. Verify endpoint categorization
diff -u previous-pending.yaml test/conformance/testdata/pending_eligible_endpoints.yaml
Frequently Asked Questions
General Questions
Q: Why is conformance audit enforcement necessary?
A: Without systematic enforcement, stable APIs can reach GA status without adequate test coverage, creating technical debt and potential compatibility issues across Kubernetes distributions. The audit system ensures every stable endpoint is either tested or explicitly documented as exempt.
Q: How often do the CI jobs run?
A: The periodic job runs automatically on a schedule to maintain baseline data. The presubmit job triggers only when swagger.json or related conformance files are modified in pull requests.
Q: Can I disable the audit check for my PR?
A: No, the conformance audit is mandatory for API changes. However, you can satisfy the requirements by appropriately categorizing endpoints in the tracking files rather than writing tests immediately.
Technical Questions
Q: Why doesn't the audit pick up my API endpoint usage?
A: Common causes:
Endpoint not called during conformance test execution
Audit logging policy doesn't capture your API group
URI pattern matching failed (check for typos in swagger.json)
Test runs in non-audited namespace
Q: How do I test the audit scripts locally?
A: Complete local workflow:
# 1. Set up KIND cluster with audit logging
kind create cluster --config kind-audit-config.yaml
# 2. Run conformance tests
go test ./test/e2e/... --ginkgo.focus="Conformance" --provider=skeleton
# 3. Extract audit logs from KIND container
docker cp kind-control-plane:/var/log/audit.log ./audit.log
# 4. Run parser
python3 audit_log_parser.py --audit-logs audit.log
# 5. Compare against CI baseline
python3 kubernetes_api_analysis.py
Process Questions
Q: How long should endpoints stay in pending_eligible_endpoints.yaml?
A: No strict time limit, but best practice is to resolve within 1-2 release cycles. Long-pending endpoints should be evaluated for potential ineligibility or prioritized for test development.
Q: Who decides if an endpoint should be ineligible?
A: The relevant SIG makes the initial determination, but controversial decisions should involve SIG Architecture. All decisions must be documented with clear reasoning.
Q: Can alpha/beta endpoints be in the audit system?
A: The audit system focuses on stable (GA) endpoints, but alpha/beta endpoints may appear in audit logs if used by conformance tests. They should not be added to tracking files until reaching stability.
Q: What happens if I ignore the audit failures?
A: Pull requests with audit failures should not be merged. The presubmit is a required check that must pass before code integration.
SIG Architecture: Primary owner of conformance audit system
CNCF Conformance WG: Policy and certification oversight
Kubernetes Slack: #sig-architecture and #conformance channels for questions
The conformance audit system represents a crucial safeguard in Kubernetes development, ensuring that the project's commitment to API stability and comprehensive testing remains
intact as the platform evolves. By automatically tracking API coverage and enforcing systematic categorization of endpoints, this system helps maintain the high quality
and compatibility standards that make Kubernetes a reliable platform for diverse deployment environments.