Operator基础:2: Operator SDK安装

阳光穿透心脏的1/2处 2022-12-23 09:42 588阅读 0赞

在这里插入图片描述

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

Operator Framework

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

  • https://liumiaocn.blog.csdn.net/article/details/110039375

基本信息

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: 源码安装

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

安装示例

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

  1. liumiaocn:~ liumiao$ RELEASE_VERSION=v1.2.0
  2. liumiaocn:~ liumiao$ curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin
  3. % Total % Received % Xferd Average Speed Time Time Time Current
  4. Dload Upload Total Spent Left Speed
  5. 100 665 100 665 0 0 360 0 0:00:01 0:00:01 --:--:-- 360
  6. 100 62.2M 100 62.2M 0 0 4001k 0 0:00:15 0:00:15 --:--:-- 7140k
  7. 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
  8. Password:
  9. liumiaocn:~ liumiao$

结果确认

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

其他

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

参考内容

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

发表评论

表情:
评论列表 (有 0 条评论,588人围观)

还没有评论,来说两句吧...

相关阅读