Operator SDK CLI reference

    Operator SDK CLI syntax

    Operator authors with cluster administrator access to a Kubernetes-based cluster (such as OKD) can use the Operator SDK CLI to develop their own Operators based on Go, Ansible, or Helm. Kubebuilder is embedded into the Operator SDK as the scaffolding solution for Go-based Operators, which means existing Kubebuilder projects can be used as is with the Operator SDK and continue to work.

    The command manages Operator bundle metadata.

    The bundle validate subcommand validates an Operator bundle.

    cleanup

    The operator-sdk cleanup command destroys and removes resources that were created for an Operator that was deployed with the run command.

    Table 2. cleanup flags
    FlagDescription

    -h, —help

    Help output for the run bundle subcommand.

    —kubeconfig (string)

    Path to the kubeconfig file to use for CLI requests.

    n, —namespace (string)

    If present, namespace in which to run the CLI request.

    —timeout <duration>

    Time to wait for the command to complete before failing. The default value is 2m0s.

    The operator-sdk completion command generates shell completions to make issuing CLI commands quicker and easier.

    Table 3. completion subcommands
    SubcommandDescription

    bash

    Generate bash completions.

    zsh

    Generate zsh completions.

    Table 4. completion flags
    FlagDescription

    -h, —help

    Usage help output.

    For example:

    Example output

    create

    The operator-sdk create command is used to create, or scaffold, a Kubernetes API.

    api

    The create api subcommand scaffolds a Kubernetes API. The subcommand must be run in a project that was initialized with the init command.

    The operator-sdk generate command invokes a specific generator to generate code or manifests.

    The generate bundle subcommand generates a set of bundle manifests, metadata, and a bundle.Dockerfile file for your Operator project.

    Typically, you run the generate kustomize manifests subcommand first to generate the input Kustomize bases that are used by the generate bundle subcommand. However, you can use the make bundle command in an initialized project to automate running these commands in sequence.

    Table 6. generate bundle flags
    FlagDescription

    —channels (string)

    Comma-separated list of channels to which the bundle belongs. The default value is alpha.

    —crds-dir (string)

    Root directory for CustomResoureDefinition manifests.

    —default-channel (string)

    The default channel for the bundle.

    —deploy-dir (string)

    Root directory for Operator manifests, such as deployments and RBAC. This directory is different from the directory passed to the —input-dir flag.

    -h, —help

    Help for

    —input-dir (string)

    —kustomize-dir (string)

    Directory containing Kustomize bases and a kustomization.yaml file for bundle manifests. The default path is config/manifests.

    —manifests

    Generate bundle manifests.

    —metadata

    Generate bundle metadata and Dockerfile.

    —output-dir (string)

    Directory to write the bundle to.

    —overwrite

    Overwrite the bundle metadata and Dockerfile if they exist. The default value is true.

    —package (string)

    Package name for the bundle.

    -q, —quiet

    Run in quiet mode.

    —stdout

    Write bundle manifest to standard out.

    —version (string)

    Semantic version of the Operator in the generated bundle. Set only when creating a new bundle or upgrading the Operator.

    Additional resources

    • See for a full procedure that includes using the make bundle command to call the generate bundle subcommand.

    kustomize

    The generate kustomize subcommand contains subcommands that generate data for the Operator.

    manifests

    The generate kustomize manifests subcommand generates or regenerates Kustomize bases and a kustomization.yaml file in the config/manifests directory, which are used to build bundle manifests by other Operator SDK commands. This command interactively asks for UI metadata, an important component of manifest bases, by default unless a base already exists or you set the --interactive=false flag.

    Table 7. generate kustomize manifests flags
    FlagDescription

    —apis-dir (string)

    Root directory for API type definitions.

    -h, —help

    Help for generate kustomize manifests.

    —input-dir (string)

    Directory containing existing Kustomize files.

    —interactive

    When set to false, if no Kustomize base exists, an interactive command prompt is presented to accept custom metadata.

    —output-dir (string)

    Directory where to write Kustomize files.

    —package (string)

    Package name.

    -q, —quiet

    Run in quiet mode.

    init

    The operator-sdk init command initializes a Operator project and generates, or scaffolds, a default project directory layout for the given plug-in.

    This command writes the following files:

    • Boilerplate license file

    • Makefile to build the project

    • go.mod file with project dependencies

    • kustomization.yaml file for customizing manifests

    • Patch file for customizing images for manager manifests

    • Patch file for enabling Prometheus metrics

    • main.go file to run

    The operator-sdk run command provides options that can launch the Operator in various environments.

    The subcommand deploys an Operator in the bundle format with Operator Lifecycle Manager (OLM).

    Table 9. run bundle flags
    FlagDescription

    —index-image (string)

    Index image in which to inject a bundle. The default image is quay.io/operator-framework/upstream-opm-builder:latest.

    —install-mode <install_mode_value>

    Install mode supported by the cluster service version (CSV) of the Operator, for example AllNamespaces or SingleNamespace.

    —timeout <duration>

    Install timeout. The default value is 2m0s.

    —kubeconfig (string)

    Path to the kubeconfig file to use for CLI requests.

    n, —namespace (string)

    If present, namespace in which to run the CLI request.

    -h, —help

    Help output for the run bundle subcommand.

    Additional resources

    bundle-upgrade

    The run bundle-upgrade subcommand upgrades an Operator that was previously installed in the bundle format with Operator Lifecycle Manager (OLM).

    Table 10. run bundle-upgrade flags
    FlagDescription

    —timeout <duration>

    Upgrade timeout. The default value is 2m0s.

    —kubeconfig (string)

    Path to the kubeconfig file to use for CLI requests.

    n, —namespace (string)

    If present, namespace in which to run the CLI request.

    -h, —help

    Help output for the run bundle subcommand.

    scorecard

    The operator-sdk scorecard command runs the scorecard tool to validate an Operator bundle and provide suggestions for improvements. The command takes one argument, either a bundle image or directory containing manifests and metadata. If the argument holds an image tag, the image must be present remotely.

    Table 11. scorecard flags
    FlagDescription

    -c, —config (string)

    Path to scorecard configuration file. The default path is bundle/tests/scorecard/config.yaml.

    -h, —help

    Help output for the scorecard command.

    —kubeconfig (string)

    Path to kubeconfig file.

    -L, —list

    List which tests are available to run.

    -n, —namespace (string)

    Namespace in which to run the test images.

    -o, —output (string)

    Output format for results. Available values are text, which is the default, and json.

    -l, —selector (string)

    Label selector to determine which tests are run.

    -s, —service-account (string)

    Service account to use for tests. The default value is default.

    -x, —skip-cleanup

    Disable resource cleanup after tests are run.

    -w, —wait-time <duration>

    Seconds to wait for tests to complete, for example 35s. The default value is .

    Additional resources

    • See for details about running the scorecard tool.