

To understand the API Go types and controller scaffolding see the Kubebuilder api doc and controller doc. See the API terminology doc for details on the CRD API conventions. This will scaffold the Memcached resource API at api/v1alpha1/memcached_types.go and the controller at controllers/memcached_controller.go. $ operator-sdk create api -group=cache -version=v1alpha1 -kind=Memcached When prompted, enter yes y for creating both the resource and controller. Create a new API and ControllerĬreate a new Custom Resource Definition(CRD) API with group cache version v1alpha1 and Kind Memcached. This guide will cover the default case of a single group API. įor multi-group projects, the API Go type files are created under apis/// and the controllers under controllers//. The Manager can restrict the namespace that all controllers will watch for resources:ĭomain : layout : go.kubebuilder.io/v2 multigroup : true. See the Kubebuilder entrypoint doc for more details on how the manager registers the Scheme for the custom resource API defintions, and sets up and runs controllers and webhooks.

The main program for the operator main.go initializes and runs the Manager. Ensure you activate module support by running export GO111MODULE=on before using the SDK. The -repo= flag is required when creating a project outside of $GOPATH/src, as scaffolded files require a valid module path. Operator-sdk init generates a go.mod file to be used with Go modules. To learn about the project directory structure, see Kubebuilder project layout doc. $ operator-sdk init -domain = -repo =/example-inc/memcached-operator # we'll use a domain of # so all API groups will be.

$ mkdir -p $HOME/projects/memcached-operator
