// Module included in the following assemblies: // // * operators/operator_sdk/osdk-getting-started.adoc // * operators/operator_sdk/osdk-ansible.adoc // * operators/operator_sdk/osdk-helm.adoc [id="osdk-installing-cli_{context}"] = Installing the Operator SDK CLI The Operator SDK has a CLI tool that assists developers in creating, building, and deploying a new Operator project. You can install the SDK CLI on your workstation so you are prepared to start authoring your own Operators. [NOTE] ==== This guide uses link:https://github.com/kubernetes/minikube#installation[minikube] v0.25.0+ as the local Kubernetes cluster and link:https://quay.io/[Quay.io] for the public registry. ==== [id="osdk-installing-cli-gh-release_{context}"] == Installing from GitHub release You can download and install a pre-built release binary of the SDK CLI from the project on GitHub. .Prerequisites - link:https://golang.org/dl/[Go] v1.13+ ifdef::openshift-origin[] - link:https://docs.docker.com/install/[`docker`] v17.03+, link:https://github.com/containers/libpod/blob/master/install.md[`podman`] v1.2.0+, or link:https://github.com/containers/buildah/blob/master/install.md[`buildah`] v1.7+ endif::[] ifndef::openshift-origin[] - `docker` v17.03+, `podman` v1.2.0+, or `buildah` v1.7+ endif::[] - OpenShift CLI (`oc`) v{product-version}+ installed - Access to a cluster based on Kubernetes v1.12.0+ - Access to a container registry .Procedure . Set the release version variable: + [source,terminal] ---- $ RELEASE_VERSION=v0.19.4 ---- . Download the release binary. + -- * For Linux: + [source,terminal] ---- $ curl -OJL https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu ---- * For macOS: + [source,terminal] ---- $ curl -OJL https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin ---- -- . Verify the downloaded release binary. .. Download the provided ASC file. + -- * For Linux: + [source,terminal] ---- $ curl -OJL https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu.asc ---- * For macOS: + [source,terminal] ---- $ curl -OJL https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin.asc ---- -- .. Place the binary and corresponding ASC file into the same directory and run the following command to verify the binary: + -- * For Linux: + [source,terminal] ---- $ gpg --verify operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu.asc ---- * For macOS: + [source,terminal] ---- $ 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 [source,terminal] ---- $ gpg: assuming signed data in 'operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin' $ gpg: Signature made Fri Apr 5 20:03:22 2019 CEST $ gpg: using RSA key <1> $ gpg: Can't check signature: No public key ---- <1> RSA key string. + To download the key, run the following command, replacing `` with the RSA key string provided in the output of the previous command: + [source,terminal] ---- $ gpg [--keyserver keys.gnupg.net] --recv-key "" <1> ---- <1> If you do not have a key server configured, specify one with the `--keyserver` option. . Install the release binary in your `PATH`: + -- * For Linux: + [source,terminal] ---- $ chmod +x operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu ---- + [source,terminal] ---- $ sudo cp operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu /usr/local/bin/operator-sdk ---- + [source,terminal] ---- $ rm operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu ---- * For macOS: + [source,terminal] ---- $ chmod +x operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin ---- + [source,terminal] ---- $ sudo cp operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin /usr/local/bin/operator-sdk ---- + [source,terminal] ---- $ rm operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin ---- -- . Verify that the CLI tool was installed correctly: + [source,terminal] ---- $ operator-sdk version ---- [id="osdk-installing-cli-homebrew_{context}"] == Installing from Homebrew You can install the SDK CLI using Homebrew. .Prerequisites - link:https://brew.sh/[Homebrew] ifdef::openshift-origin[] - link:https://docs.docker.com/install/[`docker`] v17.03+, link:https://github.com/containers/libpod/blob/master/install.md[`podman`] v1.2.0+, or link:https://github.com/containers/buildah/blob/master/install.md[`buildah`] v1.7+ endif::[] ifndef::openshift-origin[] - `docker` v17.03+, `podman` v1.2.0+, or `buildah` v1.7+ endif::[] - OpenShift CLI (`oc`) v{product-version}+ installed - Access to a cluster based on Kubernetes v1.12.0+ - Access to a container registry .Procedure . Install the SDK CLI using the `brew` command: + [source,terminal] ---- $ brew install operator-sdk ---- . Verify that the CLI tool was installed correctly: + [source,terminal] ---- $ operator-sdk version ---- [id="osdk-installing-cli-source_{context}"] == Compiling and installing from source You can obtain the Operator SDK source code to compile and install the SDK CLI. .Prerequisites - link:https://git-scm.com/downloads[Git] - link:https://golang.org/dl/[Go] v1.13+ ifdef::openshift-origin[] - link:https://docs.docker.com/install/[`docker`] v17.03+, link:https://github.com/containers/libpod/blob/master/install.md[`podman`] v1.2.0+, or link:https://github.com/containers/buildah/blob/master/install.md[`buildah`] v1.7+ endif::[] ifndef::openshift-origin[] - `docker` v17.03+, `podman` v1.2.0+, or `buildah` v1.7+ endif::[] - OpenShift CLI (`oc`) v{product-version}+ installed - Access to a cluster based on Kubernetes v1.12.0+ - Access to a container registry .Procedure . Clone the `operator-sdk` repository: + [source,terminal] ---- $ mkdir -p $GOPATH/src/github.com/operator-framework ---- + [source,terminal] ---- $ cd $GOPATH/src/github.com/operator-framework ---- + [source,terminal] ---- $ git clone https://github.com/operator-framework/operator-sdk ---- + [source,terminal] ---- $ cd operator-sdk ---- . Check out the desired release branch: + [source,terminal] ---- $ git checkout master ---- . Compile and install the SDK CLI: + [source,terminal] ---- $ make dep ---- + [source,terminal] ---- $ make install ---- + This installs the CLI binary `operator-sdk` at *_$GOPATH/bin_*. . Verify that the CLI tool was installed correctly: + [source,terminal] ---- $ operator-sdk version ----