Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[For Reference] Example of adding a new API and Controller #3587

Closed

Conversation

caseydavenport
Copy link
Member

@caseydavenport caseydavenport commented Nov 5, 2024

Description

This is an example PR to show rougly the changes necessary to add the skeleton for a new API and Controller.

NOTE

  • This example adds a namespaced resource. If you want to use a global resource (like most of our operator APIs), specify --namespaced=false on step 1.

The commits are broken down and show precisely which commands were run.
Specifically:

  1. Generate the new Resource and controller skeleton

    operator-sdk create api --group=operator.tigera.io --version=v1 --kind=DemoResource --resource --controller 
    
  2. Generate manifests

    make manifests 
    
  3. Add a new Reconciler to pkg/controller, and point the internal/controller implementation at it.

The next steps here would be to fill out the Add and Reconcile functions in pkg/controller/demoresource/demoresource_controller.go with the specific logic of the new feature.

For PR author

  • Tests for change.
  • If changing pkg/apis/, run make gen-files
  • If changing versions, run make gen-versions

For PR reviewers

A note for code reviewers - all pull requests must have the following:

  • Milestone set according to targeted release.
  • Appropriate labels:
    • kind/bug if this is a bugfix.
    • kind/enhancement if this is a a new feature.
    • enterprise if this PR applies to Calico Enterprise only.

@electricjesus
Copy link
Member

Love it.. what version of operator-sdk should I use for this? If we have a specific version that works with our PROJECT file maybe we could consider a dockerized version as a makefile target perhaps?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants