如何在Linux/macOS上安装Operator SDK CLI
时间:2020-02-23 14:31:35 来源:igfitidea点击:
Operator Framework是一个开放源代码工具包,旨在以有效,自动化和可扩展的方式管理Kubernetes本地应用程序(Operators)。运营商可以利用Kubernetes的可扩展性来提供云服务的自动化优势,例如配置,扩展,备份和还原,同时可以在Kubernetes可以运行的任何位置运行。
Operator SDK具有CLI工具,供开发人员和群集管理员在创建,构建和部署新的Operator项目时使用。本教程将向我们展示如何轻松地在工作站上安装最新版本的Operator SDK CLI,以便我们准备开始构建自己的Operators。
在Linux/macOS上安装Operator SDK CLI
我们应该先下载该应用程序的最新可用版本。我们使用curl命令行直接从Github API查询最新版本。
在Linux上下载发行版二进制文件:
curl -s https://api.github.com/repos/operator-framework/operator-sdk/releases/latest | grep browser_download_url | grep x86_64-linux-gnu | cut -d '"' -f 4 | wget -i
在macOS上下载发行版二进制文件:
curl -s https://api.github.com/repos/operator-framework/operator-sdk/releases/latest | grep browser_download_url | grep x86_64-apple-darwin | cut -d '"' -f 4 | wget -i
下载文件后,请使用提供的ASC文件验证下载的发行版二进制文件。
--- Linux --- $gpg --verify operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu.asc --- macOS -- $gpg --verify operator-sdk-*-x86_64-apple-darwin.asc
如果计算机上没有维护者公钥,则将显示以下错误:
gpg: directory '/var/home/jkmutai/.gnupg' created gpg: keybox '/var/home/jkmutai/.gnupg/pubring.kbx' created gpg: assuming signed data in 'operator-sdk-v0.16.0-x86_64-apple-darwin' gpg: Signature made Tue 17 Mar 2017 09:47:38 PM EAT gpg: using RSA key 7CC439CD21EE1031C3831C6590354A3F09FCE996 gpg: Can't check signature: No public key
使用以下命令下载密钥,将<key_id>替换为上一个输出中提供的RSA密钥字符串。
$gpg --recv-key "<key_id>"
对我来说,这将是:
$gpg --recv-key 7CC439CD21EE1031C3831C6590354A3F09FCE996 gpg: /var/home/jkmutai/.gnupg/trustdb.gpg: trustdb created gpg: key 90354A3F09FCE996: public key "Varsha Prasad Narsing (RedHat office purpose) <theitroad@localhost>" imported gpg: Total number processed: 1 gpg: imported: 1
现在我们应该能够验证二进制文件了。
$gpg --verify operator-sdk-*-x86_64-apple-darwin.asc gpg: assuming signed data in 'operator-sdk-v0.16.0-x86_64-apple-darwin' gpg: Signature made Tue 17 Mar 2017 09:47:38 PM EAT gpg: using RSA key 7CC439CD21EE1031C3831C6590354A3F09FCE996 gpg: Good signature from "Varsha Prasad Narsing (RedHat office purpose) <theitroad@localhost>" [unknown] gpg: WARNING: This key is not certified with a trusted signature! gpg: There is no indication that the signature belongs to the owner. Primary key fingerprint: 7CC4 39CD 21EE 1031 C383 1C65 9035 4A3F 09FC E996
将二进制文件移动到/usr/local/bin目录:
--- Linux -- sudo mv operator-sdk-*-x86_64-linux-gnu /usr/local/bin/operator-sdk rm -rf operator-sdk* --- macOS -- sudo mv operator-sdk-*-x86_64-apple-darwin /usr/local/bin/operator-sdk rm -rf operator-sdk*
验证CLI工具是否已正确安装:
$operator-sdk version operator-sdk version: "v0.16.0-dirty", commit: "55f1446c5f472e7d8e308dcdf36d0d7fc44fc4fd", go version: "go1.13.8 linux/amd64"