operator-sdk generate bundle

operator-sdk generate bundle

Generates bundle data for the operator

Synopsis

Running ‘generate bundle’ is the first step to publishing your operator to a catalog and/or deploying it with OLM. This command generates a set of bundle manifests, metadata, and a bundle.Dockerfile for your operator. Typically one would run ‘generate kustomize manifests’ first to (re)generate kustomize bases consumed by this command.

Set ‘–version’ to supply a semantic version for your bundle if you are creating one for the first time or upgrading an existing one.

If ‘–output-dir’ is set and you wish to build bundle images from that directory, either manually update your bundle.Dockerfile or set ‘–overwrite’.

More information on bundles: https://github.com/operator-framework/operator-registry/#manifest-format

  1. operator-sdk generate bundle [flags]

Examples

  1. # Generate bundle files and build your bundle image with these 'make' recipes:
  2. $ make bundle
  3. $ export USERNAME=<your registry username>
  4. $ export BUNDLE_IMG=quay.io/$USERNAME/memcached-operator-bundle:v0.0.1
  5. $ make bundle-build BUNDLE_IMG=$BUNDLE_IMG
  6. # The above recipe runs the following commands manually. First it creates bundle
  7. # manifests, metadata, and a bundle.Dockerfile:
  8. $ make manifests
  9. /home/user/go/bin/controller-gen "crd:trivialVersions=true" rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
  10. $ operator-sdk generate kustomize manifests
  11. Display name for the operator (required):
  12. > memcached-operator
  13. ...
  14. $ tree config/manifests
  15. config/manifests
  16. ├── bases
  17. └── memcached-operator.clusterserviceversion.yaml
  18. └── kustomization.yaml
  19. $ kustomize build config/manifests | operator-sdk generate bundle --overwrite --version 0.0.1
  20. Generating bundle manifest version 0.0.1
  21. ...
  22. # After running the above commands, you should see this directory structure:
  23. $ tree bundle
  24. bundle
  25. ├── manifests
  26. ├── cache.my.domain_memcacheds.yaml
  27. └── memcached-operator.clusterserviceversion.yaml
  28. └── metadata
  29. └── annotations.yaml
  30. # Then it validates your bundle files and builds your bundle image:
  31. $ operator-sdk bundle validate ./bundle
  32. $ docker build -f bundle.Dockerfile -t $BUNDLE_IMG .
  33. Sending build context to Docker daemon 42.33MB
  34. Step 1/9 : FROM scratch
  35. ...
  36. # You can then push your bundle image:
  37. $ make docker-push IMG=$BUNDLE_IMG

Options

  1. --channels string A comma-separated list of channels the bundle belongs to (default "alpha")
  2. --crds-dir string Root directory for CustomResoureDefinition manifests
  3. --default-channel string The default channel for the bundle
  4. --deploy-dir string Root directory for operator manifests such as Deployments and RBAC, ex. 'deploy'. This directory is different from that passed to --input-dir
  5. -h, --help help for bundle
  6. --input-dir string Directory to read an existing bundle from. This directory is the parent of your bundle 'manifests' directory, and different from --deploy-dir
  7. --kustomize-dir string Directory containing kustomize bases and a kustomization.yaml for operator-framework manifests (default "config/manifests")
  8. --manifests Generate bundle manifests
  9. --metadata Generate bundle metadata and Dockerfile
  10. --output-dir string Directory to write the bundle to
  11. --overwrite Overwrite the bundle's metadata and Dockerfile if they exist (default true)
  12. --package string Bundle's package name
  13. -q, --quiet Run in quiet mode
  14. --stdout Write bundle manifest to stdout
  15. -v, --version string Semantic version of the operator in the generated bundle. Only set if creating a new bundle or upgrading your operator

Options inherited from parent commands

  1. --verbose Enable verbose logging

SEE ALSO

Last modified December 3, 2020: generate: add `—package` and permit extra-project use of `<bundle|packagemanifests>` (#4074) (f246ef70)