operator-sdk bundle validate

operator-sdk bundle validate

Validate an operator bundle

Synopsis

The ‘operator-sdk bundle validate’ command can validate both content and format of an operator bundle image or an operator bundle directory on-disk containing operator metadata and manifests. This command will exit with an exit code of 1 if any validation errors arise, and 0 if only warnings arise or all validators pass.

A valid bundle is defined by the bundle spec (linked below), therefore the default validator ensures a bundle conforms to that spec. If you want to ensure that your bundle is valid for an optional superset of requirements such as to those required to publish your operator on operatorhub.io, then you will need to run one or more supported optional validators. Set ‘–list-optional’ to list which optional validators are supported, and how they are grouped by label.

More information about operator bundles and metadata: https://github.com/operator-framework/operator-registry/blob/master/docs/design/operator-bundle.md

NOTE: if validating an image, the image must exist in a remote registry, not just locally.

  1. operator-sdk bundle validate [flags]

Examples

  1. This example assumes you either have a *pullable* bundle image,
  2. or something similar to the following operator bundle layout present locally:
  3. $ tree ./bundle
  4. ./bundle
  5. ├── manifests
  6. ├── cache.my.domain_memcacheds.yaml
  7. └── memcached-operator.clusterserviceversion.yaml
  8. └── metadata
  9. └── annotations.yaml
  10. To validate a local bundle:
  11. $ operator-sdk bundle validate ./bundle
  12. To build and validate a *pullable* bundle image:
  13. $ operator-sdk bundle validate <some-registry>/<operator-bundle-name>:<tag>
  14. To list and run optional validators, which are specified by a label selector:
  15. $ operator-sdk bundle validate --list-optional
  16. NAME LABELS DESCRIPTION
  17. operatorhub name=operatorhub OperatorHub.io metadata validation.
  18. suite=operatorframework
  19. To validate a bundle against the entire suite of validators for Operator Framework, in addition to required bundle validators:
  20. $ operator-sdk bundle validate ./bundle --select-optional suite=operatorframework
  21. The OperatorHub.io validator in the operatorframework optional suite allows you to validate that your manifests can work with a Kubernetes cluster of a particular version using the k8s-version optional key value:
  22. $ operator-sdk bundle validate ./bundle --select-optional suite=operatorframework --optional-values=k8s-version=1.22
  23. To validate a bundle against the validator for operatorhub.io specifically, in addition to required bundle validators:
  24. $ operator-sdk bundle validate ./bundle --select-optional name=operatorhub
  25. This validator allows check the bundle against an specific Kubernetes cluster version using the k8s-version optional key value:
  26. $ operator-sdk bundle validate ./bundle --select-optional name=operatorhub --optional-values=k8s-version=1.22
  27. [Deprecated] To validate a bundle against the (alpha) validator for Community Operators specifically, in addition to required bundle validators:
  28. $ operator-sdk bundle validate ./bundle --select-optional name=community --optional-values=index-path=bundle.Dockerfile
  29. To validate a bundle against the validator for Good Practices specifically, in addition to required bundle validators:
  30. $ operator-sdk bundle validate ./bundle --select-optional name=good-practices
  31. To validate a bundle against the (alpha) validator for Deprecated APIs specifically, in addition to required bundle validators:
  32. $ operator-sdk bundle validate ./bundle --select-optional name=alpha-deprecated-apis --optional-values=k8s-version=1.22
  33. To validate a bundle against an external validator, in addition to required bundle validators:
  34. $ operator-sdk bundle validate ./bundle --alpha-select-external /path/to/external-validator[:/path/to/optional-second-validator]

Options

  1. --alpha-select-external string Selector to select external validators to run. It should be set to a Unix path list ("/path/to/e1.sh:/path/to/e2")
  2. -h, --help help for validate
  3. -b, --image-builder string Tool to pull and unpack bundle images. Only used when validating a bundle image. One of: [docker, podman, none] (default "docker")
  4. --list-optional List all optional validators available. When set, no validators will be run
  5. --optional-values --optional-values=k8s-version=1.22 Inform a []string map of key=values which can be used by the validator. e.g. to check the operator bundle against an Kubernetes version that it is intended to be distributed use --optional-values=k8s-version=1.22 (default [])
  6. -o, --output string Result format for results. One of: [text, json-alpha1]. Note: output format types containing "alphaX" are subject to change and not covered by guarantees of stable APIs. (default "text")
  7. --select-optional string Label selector to select optional validators to run. Run this command with '--list-optional' to list available optional validators

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 April 21, 2022: Add support for external bundle validators (#5525) (95237b3a)