Calico uses Kubernetes style APIs. To add a new API to Calico, or to add a new field to an existing API, use the following steps.
For most cases, a new API field on an existing API is all that is needed. To add a new API field:
-
Update the structures in the v3 API
-
Run
make generate
to update generated code and CRDs. -
Add the new logic for your field, including validation.
-
Add unit tests for your field.
-
Start by opening a GitHub issue or design document to design the feature. Consider the following:
- What component(s) need to know about this resource?
- What is the correct abstraction for this feature?
- Is there an existing API that makes sense for this feature instead?
-
Agree on a design for the new API. Read and follow the Kubernetes API conventions for new APIs.
-
Get your proposed API reviewed.
-
Add the new structure to the api/pkg/apis/projectcalico/v3 in its own go file.
- Include kubebuilder validation and defaulting where appropriate.
-
Run code and CRD generation -
make generate
-
Add client code to libcalico-go for the new API, using existing resources as a template.
-
Add unit tests for the API, using existing ones as a template.
-
Add CRUD commands and tests to calicoctl using existing ones as a template.
-
If felix or confd needs the new resource, add it to either the felixsyncer or bgpsyncer respectively.