operator-sdk add api

operator-sdk add api

Adds a new api definition under pkg/apis

Synopsis

operator-sdk add api –kind= –api-version= creates the api definition for a new custom resource under pkg/apis. This command must be run from the project root directory. If the api already exists at pkg/apis// then the command will not overwrite and return an error.

By default, this command runs Kubernetes deepcopy and CRD generators on tagged types in all paths under pkg/apis. Go code is generated under pkg/apis///zz_generated.deepcopy.go. CRD’s are generated, or updated if they exist for a particular group + version + kind, under deploy/crds/__crd.yaml; OpenAPI V3 validation YAML is generated as a ‘validation’ object. Generation can be disabled with the –skip-generation flag.

Example:

  1. $ operator-sdk add api --api-version=app.example.com/v1alpha1 --kind=AppService
  2. $ tree pkg/apis
  3. pkg/apis/
  4. ├── addtoscheme_app_appservice.go
  5. ├── apis.go
  6. └── app
  7. └── v1alpha1
  8. ├── doc.go
  9. ├── register.go
  10. ├── appservice_types.go
  11. ├── zz_generated.deepcopy.go
  12. $ tree deploy/crds
  13. ├── deploy/crds/app.example.com_v1alpha1_appservice_cr.yaml
  14. ├── deploy/crds/app.example.com_appservices_crd.yaml
  1. operator-sdk add api [flags]

Options

  1. --api-version string Kubernetes APIVersion that has a format of $GROUP_NAME/$VERSION (e.g app.example.com/v1alpha1)
  2. --crd-version string CRD version to generate (default "v1beta1")
  3. -h, --help help for api
  4. --kind string Kubernetes resource Kind name. (e.g AppService)
  5. --skip-generation Skip generation of deepcopy and OpenAPI code and OpenAPI CRD specs

SEE ALSO

Last modified January 1, 0001