operator-sdk create api

operator-sdk create api

Scaffold a Kubernetes API

Synopsis

Scaffold a Kubernetes API by writing a Resource definition and/or a Controller.

If information about whether the resource and controller should be scaffolded was not explicitly provided, it will prompt the user if they should be.

After the scaffold is written, the dependencies will be updated and make generate will be run.

  1. operator-sdk create api [flags]

Examples

  1. # Create a frigates API with Group: ship, Version: v1beta1 and Kind: Frigate
  2. operator-sdk create api --group ship --version v1beta1 --kind Frigate
  3. # Edit the API Scheme
  4. nano api/v1beta1/frigate_types.go
  5. # Edit the Controller
  6. nano controllers/frigate/frigate_controller.go
  7. # Edit the Controller Test
  8. nano controllers/frigate/frigate_controller_test.go
  9. # Generate the manifests
  10. make manifests
  11. # Install CRDs into the Kubernetes cluster using kubectl apply
  12. make install
  13. # Regenerate code and run against the Kubernetes cluster configured by ~/.kube/config
  14. make run

Options

  1. --controller if set, generate the controller without prompting the user (default true)
  2. --force attempt to create resource even if it already exists
  3. --group string resource Group
  4. -h, --help help for api
  5. --kind string resource Kind
  6. --make make generate if true, run make generate after generating files (default true)
  7. --namespaced resource is namespaced (default true)
  8. --plural string resource irregular plural form
  9. --resource if set, generate the resource without prompting the user (default true)
  10. --version string resource Version

Options inherited from parent commands

  1. --plugins strings plugin keys to be used for this subcommand execution
  2. --verbose Enable verbose logging

SEE ALSO

Last modified October 12, 2021: update k8s 1.22 (#5228) (acbc148d)