operator-sdk generate csv

operator-sdk generate csv

Generates a ClusterServiceVersion YAML file for the operator

Synopsis

The ‘generate csv’ command generates a ClusterServiceVersion (CSV) YAML manifest for the operator. This file is used to publish the operator to the OLM Catalog.

A CSV semantic version is supplied via the –csv-version flag. If your operator has already generated a CSV manifest you want to use as a base, supply its version to –from-version. Otherwise the SDK will scaffold a new CSV manifest.

The –make-manifests flag directs the generator to create a bundle manifests directory intended to hold your latest operator manifests. This flag is true by default.

More information on bundles: https://github.com/operator-framework/operator-registry/blob/master/docs/design/operator-bundle.md#operator-bundle-overview

Flags that change project default paths: –deploy-dir: The CSV’s install strategy and permissions will be generated from the operator manifests (Deployment and Role/ClusterRole) present in this directory.

–apis-dir: The CSV annotation comments will be parsed from the Go types under this path to fill out metadata for owned APIs in spec.customresourcedefinitions.owned.

–crd-dir: The CSV’s spec.customresourcedefinitions.owned field is generated from the CRD manifests in this path. These CRD manifests are also copied over to the bundle directory if –update-crds=true (the default). Additionally the CR manifests will be used to populate the CSV example CRs.

  1. operator-sdk generate csv [flags]

Examples

  1. ##### Generate a CSV in bundle format from default input paths #####
  2. $ tree pkg/apis/ deploy/
  3. pkg/apis/
  4. ├── ...
  5. └── cache
  6. ├── group.go
  7. ├── v1alpha1
  8. ├── ...
  9. └── memcached_types.go
  10. deploy/
  11. ├── crds
  12. ├── cache.example.com_memcacheds_crd.yaml
  13. └── cache.example.com_v1alpha1_memcached_cr.yaml
  14. ├── operator.yaml
  15. ├── role.yaml
  16. ├── role_binding.yaml
  17. └── service_account.yaml
  18. $ operator-sdk generate csv --csv-version=0.0.1
  19. INFO[0000] Generating CSV manifest version 0.0.1
  20. ...
  21. $ tree deploy/
  22. deploy/
  23. ...
  24. └── olm-catalog
  25. └── memcached-operator
  26. └── manifests
  27. ├── cache.example.com_memcacheds_crd.yaml
  28. └── memcached-operator.clusterserviceversion.yaml
  29. ...
  30. ##### Generate a CSV in package manifests format from default input paths #####
  31. $ operator-sdk generate csv --csv-version=0.0.1 --make-manifests=false --update-crds
  32. INFO[0000] Generating CSV manifest version 0.0.1
  33. ...
  34. $ tree deploy/
  35. deploy/
  36. ...
  37. └── olm-catalog
  38. └── memcached-operator
  39. ├── 0.0.1
  40. ├── cache.example.com_memcacheds_crd.yaml
  41. └── memcached-operator.v0.0.1.clusterserviceversion.yaml
  42. └── memcached-operator.package.yaml
  43. ...
  44. ##### Generate CSV from custom input paths #####
  45. $ operator-sdk generate csv --csv-version=0.0.1 --update-crds \
  46. --deploy-dir=config --apis-dir=api --output-dir=production
  47. INFO[0000] Generating CSV manifest version 0.0.1
  48. ...
  49. $ tree config/ api/ production/
  50. config/
  51. ├── crds
  52. ├── cache.example.com_memcacheds_crd.yaml
  53. └── cache.example.com_v1alpha1_memcached_cr.yaml
  54. ├── operator.yaml
  55. ├── role.yaml
  56. ├── role_binding.yaml
  57. └── service_account.yaml
  58. api/
  59. ├── ...
  60. └── cache
  61. | ├── group.go
  62. | └── v1alpha1
  63. | ├── ...
  64. | └── memcached_types.go
  65. production/
  66. └── olm-catalog
  67. └── memcached-operator
  68. ├── 0.0.1
  69. ├── cache.example.com_memcacheds_crd.yaml
  70. └── memcached-operator.v0.0.1.clusterserviceversion.yaml
  71. └── memcached-operator.package.yaml

Options

  1. --apis-dir string Project relative path to root directory for API type defintions (default "pkg/apis")
  2. --crd-dir string Project relative path to root directory for CRD and CR manifests
  3. --csv-channel string Channel the CSV should be registered under in the package manifest
  4. --csv-version string Semantic version of the CSV. This flag must be set if a package manifest exists
  5. --default-channel Use the channel passed to --csv-channel as the package manifests' default channel. Only valid when --csv-channel is set
  6. --deploy-dir string Project relative path to root directory for operator manifests (Deployment and RBAC) (default "deploy")
  7. --from-version string Semantic version of an existing CSV to use as a base
  8. -h, --help help for csv
  9. --make-manifests When set, the generator will create or update a CSV manifest in a 'manifests' directory. This directory is intended to be used for your latest bundle manifests. The default location is deploy/olm-catalog/<operator-name>/manifests. If --output-dir is set, the directory will be <output-dir>/manifests (default true)
  10. --operator-name string Operator name to use while generating CSV
  11. --output-dir string Base directory to output generated CSV. If --make-manifests=false the resulting CSV bundle directory will be <output-dir>/olm-catalog/<operator-name>/<csv-version>. If --make-manifests=true, the bundle directory will be <output-dir>/manifests
  12. --update-crds Update CRD manifests in deploy/<operator-name>/<csv-version> from the default CRDs dir deploy/crds or --crd-dir if set. If --make-manifests=false, this option is false by default (default true)

SEE ALSO

Last modified January 1, 0001