Kubernetes Operator SDK - CloudCommandos/JohnChan GitHub Wiki
This guide walks you through the steps required to set up Kubernetes Operator SDK.
Install Dependencies
Install Golang
wget https://dl.google.com/go/go1.12.8.linux-amd64.tar.gz
tar -C $HOME -xzf go1.12.8.linux-amd64.tar.gz
Modify environment variables using your user's '.profile'
mkdir -p $HOME/goproj/src
nano $HOME/.profile
# export GOPATH=$HOME/goproj
# export GOROOT=$HOME/go
# export PATH=$PATH:$(/root/go/bin/go env GOPATH)/bin
Install Dep
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
Clone Kubernetes Operator SDK Repository
mkdir -p $GOPATH/src/github.com/operator-framework
git clone https://github.com/operator-framework/operator-sdk $GOPATH/src/github.com/operator-framework/operator-sdk
cd $GOPATH/src/github.com/operator-framework/operator-sdk
make install
Create a New Operator
Create new project
cd $GOPATH/src
export GO111MODULE=on #or make permanent with echo 'export GO111MODULE=on' >> $HOME/.profile
operator-sdk new your-operator-project-name
operator-sdk add api --api-version=example.com/v1alpha1 --kind=Examplekind
operator-sdk add controller --api-version=example.com/v1alpha1 --kind=Examplekind
Before you build your operator, run these
operator-sdk generate k8s
operator-sdk generate openapi
Build your operator
cd $GOPATH/src/your-operator-project-name
go mod vendor
operator-sdk build repository-name/image-name:image-version
DEBUG
If your building process runs into errors, the following are some fixes:
files under contrib.go.opencensus.io/exporter/ocagent refer to https://github.com/census-ecosystem/opencensus-go-exporter-ocagent for the latest version.