大家好,欢迎来到IT知识分享网。
在前一篇文章中介绍了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
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/24783.html