How kubernetes-sigs/gateway-api works
Project type and purpose
• This is an open-source Kubernetes API specification repository. It defines Custom Resource Definitions (CRDs) and Go types for the Gateway API, provides code-generation pipelines, client libraries, a CLI (gwctl), a conformance test suite, examples, and documentation. Its purpose is to define the schema, tooling, tests, and docs that implementers and users of the Kubernetes Gateway API rely on.
Main components
• apis/…: Go type definitions for each API version (v1, v1alpha2, v1beta1, apisx, etc.)
• config/crd/: YAML manifests for CRDs (standard and experimental)
• applyconfiguration/: Builder-pattern code for server-side apply API objects
• pkg/client/: Generated clientset, informers, and listers for controllers and tools
• gwctl/: A standalone CLI that interacts with Gateway CRs via the client libraries
• hack/: Shell and Go scripts orchestrating codegen, CRD generation, docs build, tests, and deployments
• conformance/: End-to-end test suite (Go tests, example echo servers, YAML definitions) to validate Gateway API implementations
• examples/: Sample YAML definitions demonstrating API usage across versions and features
• site-src/ & mkdocs.yml: Documentation and website source for the project site
• pkg/generator, pkg/test, pkg/utils: Internal tools for code/docs generation and API validation
Relationships and interactions
• Source code in apis/ → hack/codegen scripts → generate deepcopy, registration, OpenAPI, clientset, applyconfiguration, and CRD YAML.
• Generated CRDs ↑ applied to a Kubernetes API server (cluster).
• External Gateway controllers (e.g., Envoy Gateway, Istio, Traefik) use pkg/client informers/listers to watch and reconcile CRs in the cluster.
• gwctl CLI uses the same generated clientset to read and manipulate CRs in the cluster.
• conformance suite deploys the CRDs and a test controller (echo servers), then runs Go and YAML tests to validate that controllers honor the spec.
• examples/ and docs/ guide users through creating CRs and running controllers.
Architectural patterns and design principles
• Schema-first approach: API definitions drive CRD and client code generation.
• Code generation: DeepCopy, registration, OpenAPI, clientset, informers, applyconfiguration.
• Builder pattern: applyconfiguration package for declarative object creation.
• Informer pattern: Generated shared informers and listers for event-driven controllers.
• Modular versioning: apis/v1, v1alpha2, v1beta1, and apisx for extension points.
Essential elements to capture
• Source→Generator→Artifact pipeline
• Generated clients/informers powering controllers and CLI
• CRD YAML and API server
• Conformance suite validating external implementations
• Documentation and examples feeding back into the developer/user workflow