1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00
Files
openshift-docs/modules/osdk-installing-cli.adoc
2020-01-21 20:56:00 +00:00

229 lines
6.0 KiB
Plaintext

// 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`) v4.3+ installed
- Access to a cluster based on Kubernetes v1.12.0+
- Access to a container registry
.Procedure
. Set the release version variable:
+
----
RELEASE_VERSION=v0.12.0
----
. Download the release binary.
+
--
* For Linux:
+
----
$ curl -OJL https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu
----
* For macOS:
+
----
$ 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:
+
----
$ curl -OJL https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu.asc
----
* For macOS:
+
----
$ 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:
+
----
$ gpg --verify operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu.asc
----
* For macOS:
+
----
$ gpg --verify operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin.asc
----
--
+
If you do not have the maintainer's public key on your workstation, you will
get the following error:
+
----
$ gpg --verify operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin.asc
$ 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 <key_id> <1>
$ gpg: Can't check signature: No public key
----
<1> RSA 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:
+
----
$ gpg [--keyserver keys.gnupg.net] --recv-key "<key_id>" <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:
+
----
$ chmod +x operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu
$ sudo cp operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu /usr/local/bin/operator-sdk
$ rm operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu
----
* For macOS:
+
----
$ chmod +x operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin
$ sudo cp operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin /usr/local/bin/operator-sdk
$ rm operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin
----
--
. Verify that the CLI tool was installed correctly:
+
----
$ 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`) v4.3+ 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:
+
----
$ brew install operator-sdk
----
. Verify that the CLI tool was installed correctly:
+
----
$ 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`) v4.3+ installed
- Access to a cluster based on Kubernetes v1.12.0+
- Access to a container registry
.Procedure
. Clone the `operator-sdk` repository:
+
----
$ mkdir -p $GOPATH/src/github.com/operator-framework
$ cd $GOPATH/src/github.com/operator-framework
$ git clone https://github.com/operator-framework/operator-sdk
$ cd operator-sdk
----
. Check out the desired release branch:
+
----
$ git checkout master
----
. Compile and install the SDK CLI:
+
----
$ make dep
$ make install
----
+
This installs the CLI binary `operator-sdk` at *_$GOPATH/bin_*.
. Verify that the CLI tool was installed correctly:
+
----
$ operator-sdk version
----