当前位置: 首页 > 工具软件 > operator-sdk > 使用案例 >

k8s operator-sdk安装及使用

程化
2023-12-01

参考 知乎文章 Kubernetes Operator 快速入门教程,

Operator sdk github

  1. 安装 参考 operator sdk 官方安装文档

    # set platform information
    export ARCH=$(case $(uname -m) in x86_64) echo -n amd64 ;; aarch64) echo -n arm64 ;; *) echo -n $(uname -m) ;; esac)
    export OS=$(uname | awk '{print tolower($0)}')
    
    # download 
    export OPERATOR_SDK_DL_URL=https://github.com/operator-framework/operator-sdk/releases/download/v1.12.0
    curl -LO ${OPERATOR_SDK_DL_URL}/operator-sdk_${OS}_${ARCH}
    
    # install
    chmod +x operator-sdk_${OS}_${ARCH} && sudo mv operator-sdk_${OS}_${ARCH} /usr/local/bin/operator-sdk
    
    
  2. 使用

    operator-sdk init --plugins go/v3 --project-version 3

    报错go: can only use path@version syntax with ‘go get’ and ‘go install’ in module-aware mode

    。。。

    Error: failed to initialize project: unable to scaffold with “base.go.kubebuilder.io/v3”: exit status 1

    后者查不到,通过前一句猜测跟module有关,修改go环境变量后重试

    go env -w GO111MODULE="on"
    rm -rf *
    operator-sdk init --plugins go/v3 --project-version 3
    成功
    
 类似资料: