$ operator-sdk <command> [<subcommand>] [<argument>] [<flags>]
This guide documents the Operator SDK CLI commands and their syntax:
$ operator-sdk <command> [<subcommand>] [<argument>] [<flags>]
The operator-sdk alpha
command is used to run an alpha subcommand.
The alpha scorecard
subcommand 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.
Flag | Description |
---|---|
|
Path to scorecard configuration file. |
|
Help output for the |
|
Path to |
|
List which tests are available to run. |
|
Namespace in which to run the test images. Default: |
|
Output format for results. Available values are |
|
Label selector to determine which tests are run. |
|
Service account to use for tests. Default: |
|
Disable resource cleanup after tests are run. |
|
Seconds to wait for tests to complete, for example |
The operator-sdk build
command compiles the code and builds the executables. After build
completes, the image is built using a local container engine. It must then be pushed to a remote registry.
Argument | Description |
---|---|
|
The container image to be built, for example |
Flag | Description |
---|---|
|
Extra Go build arguments. |
|
Extra image build arguments as one string. |
|
Tool to build OCI images. Available options are: |
|
Usage help output. |
The operator-sdk bundle
command manages Operator bundle metadata.
The bundle validate
subcommand validates an Operator bundle.
Flag | Description |
---|---|
|
Help output for the |
|
Tool to pull and unpack bundle images. Only used when validating a bundle image. Available options are |
The operator-sdk cleanup
command destroys and removes resources that were created for an Operator that was deployed with the run
command.
cleanup packagemanifests
subcommand destroys an Operator that was deployed with OLM by using the run packagemanifests
command.
Arguments | Description |
---|---|
|
The file path to Kubernetes resource manifests, such as role and subscription objects. These supplement or override the defaults generated by |
|
The |
|
The file path to a Kubernetes configuration file. Default: The location specified by |
|
The namespace where the OLM is installed. Default: |
|
The namespace where the Operator resources are created. The namespace must already exist in the cluster, or be defined in a manifest that is passed to |
|
The version of the Operator to be deployed. |
|
The time to wait for the command to complete before it fails. Default: |
|
Usage help output. |
The operator-sdk completion
command generates shell completions to make issuing CLI commands quicker and easier.
Subcommand | Description |
---|---|
|
Generate bash completions. |
|
Generate zsh completions. |
Flag | Description |
---|---|
|
Usage help output. |
For example:
$ operator-sdk completion bash
# bash completion for operator-sdk -*- shell-script -*-
...
# ex: ts=4 sw=4 et filetype=sh
The operator-sdk create
command is used to create, or scaffold, a Kubernetes API.
The operator-sdk generate
command invokes a specific generator to generate code as needed.
The generate bundle
subcommand generates a set of bundle manifests, metadata, and a bundle.Dockerfile
file for your Operator project.
Typically, you run the |
Flag | Description |
---|---|
|
Comma-separated list of channels to which the bundle belongs. The default value is |
|
Root directory for |
|
The default channel for the bundle. |
|
Root directory for Operator manifests, such as deployments and RBAC. This directory is different from the directory passed to the |
|
Help for |
|
Directory from which to read an existing bundle. This directory is the parent of your bundle |
|
Directory containing Kustomize bases and a |
|
Generate bundle manifests. |
|
Generate bundle metadata and Dockerfile. |
|
Name of the Operator of the bundle. |
|
Directory to write the bundle to. |
|
Overwrite the bundle metadata and Dockerfile if they exist. The default value is |
|
Run in quiet mode. |
|
Write bundle manifest to standard out. |
|
Semantic version of the Operator in the generated bundle. Set only when creating a new bundle or upgrading the Operator. |
The generate kustomize
subcommand contains subcommands that generate Kustomize data for the Operator.
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.
Flag | Description |
---|---|
|
Root directory for API type definitions. |
|
Help for |
|
Directory containing existing Kustomize files. |
|
When set to |
|
Name of the Operator. |
|
Directory where to write Kustomize files. |
|
Run in quiet mode. |
Running generate packagemanifests
subcommand is the first step to publishing your Operator to a catalog, deploying
it with OLM or both. This command generates a set of manifests in a versioned directory and a package manifest file for
your Operator. You must run generate kustomize manifests
first to regenerate Kustomize bases
consumed by this command.
Flag | Description |
---|---|
|
The channel name for the generated package. |
|
The root directory for custom resource definition (CRD) manifests. |
|
Use the channel passed to |
|
The root directory for Operator manifests such as deployments and RBAC, for example, |
|
The semantic version of the Operator, from which it is being upgraded. |
|
Help for |
|
The directory to read existing package manifests from. This directory is the parent of individual versioned package directories, and different from |
|
The directory containing Kustomize bases and a |
|
The name of the packaged Operator. |
|
The directory in which to write package manifests. |
|
Run in quiet mode. |
|
Write package to |
|
Update custom resource definition (CRD) manifests in this package. Default: |
|
The semantic version of the packaged Operator. |
The operator-sdk init
command initializes an 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
PROJECT
file with the domain and repository
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
Flag | Description |
---|---|
|
Help output for the |
|
Name and optionally version of the plug-in to initialize the project with. Available plug-ins are |
|
Project version. Available values are |
The operator-sdk new
command creates a new Operator application and generates (or scaffolds) a default project directory layout based on the input <project_name>
.
Argument | Description |
---|---|
|
Name of the new project. |
Flag | Description |
---|---|
|
Kubernetes API version in the format |
|
CRD version to generate. Default: |
|
Generate an Ansible playbook skeleton. Used with |
|
Initialize helm Operator with existing helm chart: |
|
Chart repository URL for the requested helm chart. |
|
Specific version of the helm chart. Used only with the |
|
Usage and help output. |
|
CRD kind, for example |
|
Skip generation of deepcopy and OpenAPI code and OpenAPI CRD specs. |
|
Type of Operator to initialize: |
Starting with Operator SDK v0.12.0, the |
$ mkdir $GOPATH/src/github.com/example.com/
$ cd $GOPATH/src/github.com/example.com/
$ operator-sdk new app-operator
$ operator-sdk new app-operator \
--type=ansible \
--api-version=app.example.com/v1alpha1 \
--kind=AppService
The operator-sdk olm
command manages the Operator Lifecycle Manager (OLM) installation in your cluster.
olm install
subcommand installs OLM in your cluster.
Argument | Description |
---|---|
|
The namespace where OLM is installed. Default: |
|
The time to wait for the command to complete before it fails. Default: |
|
The version of OLM resources to be installed. Default: |
|
Usage help output. |
olm status
subcommand gets the status of the Operator Lifecycle Manager (OLM) installation in your cluster.
Argument | Description |
---|---|
|
The namespace from where OLM is installed. Default: |
|
The time to wait for the command to complete before it fails. Default: |
|
The version of the OLM that is installed on your cluster. If unset, |
|
Usage help output. |
olm uninstall
subcommand uninstalls OLM from your cluster.
Argument | Description |
---|---|
|
The namespace from where OLM is to be uninstalled. Default: |
|
The time to wait for the command to complete before it fails. Default: |
|
The version of OLM resources to be uninstalled. |
|
Usage help output. |
The operator-sdk run
command provides options that can launch the Operator in various environments.
run packagemanifests
subcommand deploys an Operator’s package manifests with Operator Lifecycle Manager (OLM). The command argument must be set to a valid package manifest root directory, for example, <project_root>/packagemanifests
.
Arguments | Description |
---|---|
|
The file path to Kubernetes resource manifests, such as role and subscription objects. These supplement or override the defaults generated by |
|
The |
|
The file path to a Kubernetes configuration file. Default: The location specified by |
|
The namespace where OLM is installed. Default: |
|
The namespace where the Operator resources are created. The namespace must already exist in the cluster, or be defined in a manifest that is passed to |
|
The version of the Operator to deploy. |
|
The time to wait for the command to complete before it fails. Default: |
|
Usage help output. |