Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 8. Operator SDK
8.1. Installing the Operator SDK CLI Link kopierenLink in die Zwischenablage kopiert!
The Operator SDK provides a command-line interface (CLI) tool that Operator developers can use to build, test, and deploy an Operator. You can install the Operator SDK CLI on your workstation so that you are prepared to start authoring your own Operators.
Operator authors with cluster administrator access to a Kubernetes-based cluster, such as OpenShift Container Platform, can use the Operator SDK CLI to develop their own Operators based on Go, Ansible, Java, 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.
See Developing Operators for full documentation on the Operator SDK.
OpenShift Container Platform 4.12 supports Operator SDK 1.25.4.
8.1.1. Installing the Operator SDK CLI on Linux Link kopierenLink in die Zwischenablage kopiert!
You can install the OpenShift SDK CLI tool on Linux.
Prerequisites
- Go v1.19+
-
v17.03+,
dockerv1.9.3+, orpodmanv1.7+buildah
Procedure
- Navigate to the OpenShift mirror site.
- From the latest 4.12 directory, download the latest version of the tarball for Linux.
Unpack the archive:
$ tar xvf operator-sdk-v1.25.4-ocp-linux-x86_64.tar.gzMake the file executable:
$ chmod +x operator-sdkMove the extracted
binary to a directory that is on youroperator-sdk.PATHTipTo check your
:PATH$ echo $PATH$ sudo mv ./operator-sdk /usr/local/bin/operator-sdk
Verification
After you install the Operator SDK CLI, verify that it is available:
$ operator-sdk versionExample output
operator-sdk version: "v1.25.4-ocp", ...
8.1.2. Installing the Operator SDK CLI on macOS Link kopierenLink in die Zwischenablage kopiert!
You can install the OpenShift SDK CLI tool on macOS.
Prerequisites
- Go v1.19+
-
v17.03+,
dockerv1.9.3+, orpodmanv1.7+buildah
Procedure
-
For the and
amd64architectures, navigate to the OpenShift mirror site for thearm64amd64architecture and OpenShift mirror site for thearm64architecture respectively. - From the latest 4.12 directory, download the latest version of the tarball for macOS.
Unpack the Operator SDK archive for
architecture by running the following command:amd64$ tar xvf operator-sdk-v1.25.4-ocp-darwin-x86_64.tar.gzUnpack the Operator SDK archive for
architecture by running the following command:arm64$ tar xvf operator-sdk-v1.25.4-ocp-darwin-aarch64.tar.gzMake the file executable by running the following command:
$ chmod +x operator-sdkMove the extracted
binary to a directory that is on youroperator-sdkby running the following command:PATHTipCheck your
by running the following command:PATH$ echo $PATH$ sudo mv ./operator-sdk /usr/local/bin/operator-sdk
Verification
After you install the Operator SDK CLI, verify that it is available by running the following command::
$ operator-sdk versionExample output
operator-sdk version: "v1.25.4-ocp", ...
8.2. Operator SDK CLI reference Link kopierenLink in die Zwischenablage kopiert!
The Operator SDK command-line interface (CLI) is a development kit designed to make writing Operators easier.
Operator SDK CLI syntax
$ operator-sdk <command> [<subcommand>] [<argument>] [<flags>]
See Developing Operators for full documentation on the Operator SDK.
8.2.1. bundle Link kopierenLink in die Zwischenablage kopiert!
The
operator-sdk bundle
8.2.1.1. validate Link kopierenLink in die Zwischenablage kopiert!
The
bundle validate
| Flag | Description |
|---|---|
|
| Help output for the
|
|
| Tool to pull and unpack bundle images. Only used when validating a bundle image. Available options are
|
|
| List all optional validators available. When set, no validators are run. |
|
| Label selector to select optional validators to run. When run with the
|
8.2.2. cleanup Link kopierenLink in die Zwischenablage kopiert!
The
operator-sdk cleanup
run
| Flag | Description |
|---|---|
|
| Help output for the
|
|
| Path to the
|
|
| If present, namespace in which to run the CLI request. |
|
| Time to wait for the command to complete before failing. The default value is
|
8.2.3. completion Link kopierenLink in die Zwischenablage kopiert!
The
operator-sdk completion
| Subcommand | Description |
|---|---|
|
| Generate bash completions. |
|
| Generate zsh completions. |
| Flag | Description |
|---|---|
|
| Usage help output. |
For example:
$ operator-sdk completion bash
Example output
# bash completion for operator-sdk -*- shell-script -*-
...
# ex: ts=4 sw=4 et filetype=sh
8.2.4. create Link kopierenLink in die Zwischenablage kopiert!
The
operator-sdk create
8.2.4.1. api Link kopierenLink in die Zwischenablage kopiert!
The
create api
init
| Flag | Description |
|---|---|
|
| Help output for the
|
8.2.5. generate Link kopierenLink in die Zwischenablage kopiert!
The
operator-sdk generate
8.2.5.1. bundle Link kopierenLink in die Zwischenablage kopiert!
The
generate bundle
bundle.Dockerfile
Typically, you run the
generate kustomize manifests
generate bundle
make bundle
| 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. |
|
| Directory to write the bundle to. |
|
| Overwrite the bundle metadata and Dockerfile if they exist. The default value is
|
|
| Package name for the bundle. |
|
| 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. |
8.2.5.2. kustomize Link kopierenLink in die Zwischenablage kopiert!
The
generate kustomize
8.2.5.2.1. manifests Link kopierenLink in die Zwischenablage kopiert!
The
generate kustomize manifests
kustomization.yaml
config/manifests
--interactive=false
| Flag | Description |
|---|---|
|
| Root directory for API type definitions. |
|
| Help for
|
|
| Directory containing existing Kustomize files. |
|
| When set to
|
|
| Directory where to write Kustomize files. |
|
| Package name. |
|
| Run in quiet mode. |
8.2.6. init Link kopierenLink in die Zwischenablage kopiert!
The
operator-sdk init
This command writes the following files:
- Boilerplate license file
-
file with the domain and repository
PROJECT -
to build the project
Makefile -
file with project dependencies
go.mod -
file for customizing manifests
kustomization.yaml - Patch file for customizing images for manager manifests
- Patch file for enabling Prometheus metrics
-
file to run
main.go
| Flag | Description |
|---|---|
|
| Help output for the
|
|
| Name and optionally version of the plugin to initialize the project with. Available plugins are
|
|
| Project version. Available values are
|
8.2.7. run Link kopierenLink in die Zwischenablage kopiert!
The
operator-sdk run
8.2.7.1. bundle Link kopierenLink in die Zwischenablage kopiert!
The
run bundle
| Flag | Description |
|---|---|
|
| Index image in which to inject a bundle. The default image is
|
|
| Install mode supported by the cluster service version (CSV) of the Operator, for example
|
|
| Install timeout. The default value is
|
|
| Path to the
|
|
| If present, namespace in which to run the CLI request. |
|
| Specifies the security context to use for the catalog pod. Allowed values include
|
|
| Help output for the
|
-
The security context is not compatible with the
restrictednamespace. To configure your Operator’s pod security admission in your production environment, see "Complying with pod security admission". For more information about pod security admission, see "Understanding and managing pod security admission".default
8.2.7.2. bundle-upgrade Link kopierenLink in die Zwischenablage kopiert!
The
run bundle-upgrade
| Flag | Description |
|---|---|
|
| Upgrade timeout. The default value is
|
|
| Path to the
|
|
| If present, namespace in which to run the CLI request. |
|
| Specifies the security context to use for the catalog pod. Allowed values include
|
|
| Help output for the
|
-
The security context is not compatible with the
restrictednamespace. To configure your Operator’s pod security admission in your production environment, see "Complying with pod security admission". For more information about pod security admission, see "Understanding and managing pod security admission".default
8.2.8. scorecard Link kopierenLink in die Zwischenablage kopiert!
The
operator-sdk scorecard
| Flag | Description |
|---|---|
|
| Path to scorecard configuration file. The default path is
|
|
| Help output for the
|
|
| Path to
|
|
| List which tests are available to run. |
|
| Namespace in which to run the test images. |
|
| Output format for results. Available values are
|
|
| Option to run scorecard with the specified security context. Allowed values include
|
|
| Label selector to determine which tests are run. |
|
| Service account to use for tests. The default value is
|
|
| Disable resource cleanup after tests are run. |
|
| Seconds to wait for tests to complete, for example
|
-
The security context is not compatible with the
restrictednamespace. To configure your Operator’s pod security admission in your production environment, see "Complying with pod security admission". For more information about pod security admission, see "Understanding and managing pod security admission".default