Skip to content

Commit 46a49ca

Browse files
authored
various cleanup (#10985)
1 parent 3ab14da commit 46a49ca

File tree

3 files changed

+5
-454
lines changed

3 files changed

+5
-454
lines changed

api/README.md

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# APIs for Gloo Gateway - Kubernetes Gateway API Integration
1+
# APIs for kgateway
22

3-
This directory contains Go types for custom resources that Gloo Gateway uses with its Kubernetes Gateway API integration.
3+
This directory contains Go types for kgateway APIs & custom resources.
44

55
## Adding a new API / CRD
66

@@ -15,22 +15,11 @@ These are the steps required to add a new CRD to be used in the Kubernetes Gatew
1515
- Include all the appropriate json and kubebuilder annotations on fields and structs.
1616
- Make sure to include a unique `shortName` in the kubebuilder annotation for the resource.
1717
- Avoid using slices with pointers. see: https://github.com/kubernetes/code-generator/issues/166
18-
- Define RBAC rules using the `+kubebuilder:rbac` annotation (note: this annotation should not belong to the type, but rather the file or package.). Alternativly, define RBAC rules in the helm chart in `install/helm/gloo/templates/44-rbac.yaml`.
18+
- RBAC rules are defined in `doc.go` via `+kubebuilder:rbac` annotation (note: this annotation should not belong to the type, but rather the file or package).
1919
- Define a struct for the resource list (containing the metadata fields and `Items`)
2020
3. Run codegen via `make generated-code -B`. This will invoke the `controller-gen` command specified in [generate.go](/hack/generate.go), which should result in the following:
2121
- A `zz_generated.deepcopy.go` file is created in the same directory as the Go types.
2222
- A `zz_generated.register.go` file is created in the same directory as the Go types. To help with registering the Go types with the scheme.
23-
- A CRD file is generated in [install/helm/gloo/crds](/install/helm/gloo/crds)
24-
- RBAC role is generated in `install/helm/gloo/files/rbac/role.yaml`
23+
- CRDs are generated in the CRD helm chart template dir: `install/helm/kgateway-crds/templates`
24+
- RBAC role is generated in `install/helm/kgateway/templates/role.yaml`
2525
- Updates the `api/applyconfiguration` `pkg/generated` and `pkg/client` folders with kube clients. These are used in plugin initialization and the fake client is used in tests.
26-
27-
## Background
28-
29-
Historically, we have defined Gloo Gateway custom resources using protobuf files, which are then converted to Go types via solo-kit or skv2 codegen. This was also the initial implementation for the kube gateway resources, however we pivoted to using Go types for a few reasons.
30-
31-
Some of our Gloo Gateway APIs depend on Kubernetes [Core](https://github.com/kubernetes/api) and [Apimachinery](https://github.com/kubernetes/apimachinery) APIs, because our user-facing APIs (e.g GatewayParameters) allow users to configure some parts of Kubernetes resources (e.g. pod/container security context, affinity, tolerations) directly.
32-
33-
The source of truth for the Kubernetes APIs are the Go types defined in the Kubernetes repos, and protobuf files get generated from the Go types. Initially, the Gloo Gateway protobuf files imported a copy of the generated Kubernetes protobuf files, but:
34-
35-
- There turned out to be inconsistencies between the structure of the generated protobuf files and the source APIs (e.g. extra embedded fields).
36-
- Maintaining a copy of the generated files meant that we would need to remember to update them whenever we upgraded Kubernetes library versions in Gloo Gateway.

0 commit comments

Comments
 (0)