Operator基础:2: Operator SDK安装

在这里插入图片描述

在前一篇文章中介绍了Operator Framework,提到了Operator SDK是用来搭建脚手架的重要工具,这篇文章就Operator SDK进行继续展开。

Operator Framework

关于Operator和Operator Framework的介绍,可参看:

基本信息

Operator SDK的基本信息如下所示:

项目说明
官方网站https://sdk.operatorframework.io/
开源/闭源开源
License类别Apache License 2.0
代码管理地址https://github.com/operator-framework/operator-sdk
开发语言Go
支持平台由于使用Go,可以支持多种操作系统诸如Linux/MacOSX等
当前版本1.2.0 (2020/11/12)

三种开发方式

通过使用SDK-CLI,可以使用如下三种方式进行CRD相关的扩展开发,

  • go
  • Ansible
  • Helm
    三者相关所能实现的能力如下所示,使用Helm一般只能实现安装和无缝升级等功能。
    在这里插入图片描述

安装方式

方式1: 使用brew安装(MacOS)

在MacOS下,可以直接使用brew进行安装

执行命令:brew install operator-sdk

方式2: 二进制文件(github)

使用github的release下提供的支持各种OS的相应二进制文件,然后进行权限设定即可。

  • 下载文件
# Set the release version variable
$ RELEASE_VERSION=v1.2.0
# Linux
$ curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu
$ curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/ansible-operator-${RELEASE_VERSION}-x86_64-linux-gnu
$ curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/helm-operator-${RELEASE_VERSION}-x86_64-linux-gnu
# macOS
$ curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin
$ curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/ansible-operator-${RELEASE_VERSION}-x86_64-apple-darwin
$ curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/helm-operator-${RELEASE_VERSION}-x86_64-apple-darwin
  • 安装设定
# Linux
$ chmod +x operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu && sudo mkdir -p /usr/local/bin/ && sudo cp operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu /usr/local/bin/operator-sdk && rm operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu
$ chmod +x ansible-operator-${RELEASE_VERSION}-x86_64-linux-gnu && sudo mkdir -p /usr/local/bin/ && sudo cp ansible-operator-${RELEASE_VERSION}-x86_64-linux-gnu /usr/local/bin/ansible-operator && rm ansible-operator-${RELEASE_VERSION}-x86_64-linux-gnu
$ chmod +x helm-operator-${RELEASE_VERSION}-x86_64-linux-gnu && sudo mkdir -p /usr/local/bin/ && sudo cp helm-operator-${RELEASE_VERSION}-x86_64-linux-gnu /usr/local/bin/helm-operator && rm helm-operator-${RELEASE_VERSION}-x86_64-linux-gnu
# macOS
$ chmod +x operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin && sudo mkdir -p /usr/local/bin/ && sudo cp operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin /usr/local/bin/operator-sdk && rm operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin
$ chmod +x ansible-operator-${RELEASE_VERSION}-x86_64-apple-darwin && sudo mkdir -p /usr/local/bin/ && sudo cp ansible-operator-${RELEASE_VERSION}-x86_64-apple-darwin /usr/local/bin/ansible-operator && rm ansible-operator-${RELEASE_VERSION}-x86_64-apple-darwin
$ chmod +x helm-operator-${RELEASE_VERSION}-x86_64-apple-darwin && sudo mkdir -p /usr/local/bin/ && sudo cp helm-operator-${RELEASE_VERSION}-x86_64-apple-darwin /usr/local/bin/helm-operator && rm helm-operator-${RELEASE_VERSION}-x86_64-apple-darwin

方式3: 源码安装

$ git clone https://github.com/operator-framework/operator-sdk
$ cd operator-sdk
$ git checkout master
$ make install

安装示例

这里以方式2为例,在MacOS上安装operator-sdk为例,执行如下命令和日志如下所示

liumiaocn:~ liumiao$ RELEASE_VERSION=v1.2.0
liumiaocn:~ liumiao$ curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   665  100   665    0     0    360      0  0:00:01  0:00:01 --:--:--   360
100 62.2M  100 62.2M    0     0  4001k      0  0:00:15  0:00:15 --:--:-- 7140k
liumiaocn:~ liumiao$ chmod +x operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin && sudo mkdir -p /usr/local/bin/ && sudo cp operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin /usr/local/bin/operator-sdk && rm operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin
Password:
liumiaocn:~ liumiao$ 

结果确认

liumiaocn:~ liumiao$ which operator-sdk
/usr/local/bin/operator-sdk
liumiaocn:~ liumiao$ operator-sdk version
operator-sdk version: "v1.2.0", commit: "215fc50b2d4acc7d92b36828f42d7d1ae212015c", kubernetes version: "v1.18.8", go version: "go1.15.3", GOOS: "darwin", GOARCH: "amd64"
liumiaocn:~ liumiao$ 

其他

BTW,Operator SDK开头的图的颜色的原因是因为这个。
在这里插入图片描述

参考内容

https://sdk.operatorframework.io/
https://github.com/operator-framework/operator-sdk

淼叔 CSDN认证博客专家 神经网络 TensorFlow NLP
资深架构师,PMP、OCP、CSM、HPE University讲师,EXIN DevOps Professional与DevOps Master认证讲师,曾担任HPE GD China DevOps & Agile Leader,帮助企业级客户提供DevOps咨询培训以及实施指导。熟悉通信和金融领域,有超过十年金融外汇行业的架构设计、开发、维护经验,在十几年的IT从业生涯中拥有了软件开发设计领域接近全生命周期的经验和知识积累,著有企业级DevOps技术与工具实战。
已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 数字20 设计师:CSDN官方博客 返回首页