Installing the Operator SDK CLI

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.

OKD 4.6 supports Operator SDK v0.19.4, which can be installed from upstream sources.

Starting in OKD 4.7, the Operator SDK is fully supported and available from official Red Hat product sources. See OKD 4.7 release notes for more information.

Installing the Operator SDK CLI from from GitHub releases

You can download and install a pre-built release binary of the Operator SDK CLI from the project on GitHub.

Prerequisites

  • Go v1.13+

  • docker v17.03+, podman v1.2.0+, or buildah v1.7+

  • OpenShift CLI (oc) v4.6+ installed

  • Access to a cluster based on Kubernetes v1.12.0+

  • Access to a container registry

Procedure

  1. Set the release version variable:

    1. $ RELEASE_VERSION=v0.19.4
  2. Download the release binary.

    • For Linux:

      1. $ curl -OJL https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu
    • For macOS:

      1. $ curl -OJL https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin
  3. Verify the downloaded release binary.

    1. Download the provided .asc file.

      • For Linux:

        1. $ curl -OJL https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu.asc
      • For macOS:

        1. $ curl -OJL https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin.asc
    2. Place the binary and corresponding .asc file into the same directory and run the following command to verify the binary:

      • For Linux:

        1. $ gpg --verify operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu.asc
      • For macOS:

        1. $ gpg --verify operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin.asc

      If you do not have the public key of the maintainer on your workstation, you will get the following error:

      Example output with error

      1. $ gpg: assuming signed data in 'operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin'
      2. $ gpg: Signature made Fri Apr 5 20:03:22 2019 CEST
      3. $ gpg: using RSA key <key_id> (1)
      4. $ gpg: Can't check signature: No public key
      1RSA key string.

      To download the key, run the following command, replacing <key_id> with the RSA key string provided in the output of the previous command:

      1. $ gpg [--keyserver keys.gnupg.net] --recv-key "<key_id>" (1)
      1If you do not have a key server configured, specify one with the —keyserver option.
  4. Install the release binary in your PATH:

    • For Linux:

      1. $ chmod +x operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu
      1. $ sudo cp operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu /usr/local/bin/operator-sdk
      1. $ rm operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu
    • For macOS:

      1. $ chmod +x operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin
      1. $ sudo cp operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin /usr/local/bin/operator-sdk
      1. $ rm operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin
  5. Verify that the CLI tool was installed correctly:

    1. $ operator-sdk version

Installing the Operator SDK CLI from Homebrew

You can install the SDK CLI using Homebrew.

Prerequisites

  • Homebrew

  • docker v17.03+, podman v1.2.0+, or buildah v1.7+

  • OpenShift CLI (oc) v4.6+ installed

  • Access to a cluster based on Kubernetes v1.12.0+

  • Access to a container registry

Procedure

  1. Install the SDK CLI using the brew command:

    1. $ brew install operator-sdk
  2. Verify that the CLI tool was installed correctly:

    1. $ operator-sdk version

Compiling and installing the Operator SDK CLI from source

You can obtain the Operator SDK source code to compile and install the SDK CLI.

Prerequisites

  • Git

  • Go v1.13+

  • docker v17.03+, podman v1.2.0+, or buildah v1.7+

  • OpenShift CLI (oc) v4.6+ installed

  • Access to a cluster based on Kubernetes v1.12.0+

  • Access to a container registry

Procedure

  1. Clone the operator-sdk repository:

    1. $ git clone https://github.com/operator-framework/operator-sdk
  2. Change to the directory for the cloned repository:

    1. $ cd operator-sdk
  3. Check out the v0.19.4 release:

    1. $ git checkout tags/v0.19.4 -b v0.19.4
  4. Update dependencies:

    1. $ make tidy
  5. Compile and install the SDK CLI:

    1. $ make install

    This installs the CLI binary operator-sdk in the $GOPATH/bin/ directory.

  6. Verify that the CLI tool was installed correctly:

    1. $ operator-sdk version