Skip to content

Repository files navigation

Building an Operator with the operator-sdk

# build operaotr-sdk
$ cd$GOPATH/src/github.com/operator-framework/operator-sdk
$ git checkout master
$ make dep
$ make install
# generate project
OPERATOR_NAME=echo-operator
GROUP=echo.redhat.com
VERSION=v1
KIND=EchoApp
$ cd$GOPATH/src/github.com/{user name}/
$ operator-sdk new ${OPERATOR_NAME} --api-version=${GROUP}/${VERSION} --kind=${KIND}
$ cd${OPERATOR_NAME}# build and push image
REGISTRY=docker.io
ORG=tohinkashem
TAG=v0.0.1
$ operator-sdk build ${REGISTRY}/${ORG}/${OPERATOR_NAME}:${TAG}
$ docker push ${REGISTRY}/${ORG}/${OPERATOR_NAME}:${TAG}
# addfieldstocustomtypestypeEchoAppstruct {
metav1.TypeMeta`json:",inline"`
metav1.ObjectMeta`json:"metadata"`SpecEchoAppSpec`json:"spec"`StatusEchoAppStatus`json:"status,omitempty"`
}
typeEchoAppSpecstruct {
Sizeint32`json:"size"`Imagestring`json:"image"`
}
typeEchoAppStatusstruct {
Nodes []string`json:"nodes"`
}
$ operator-sdk generate k8s

Deploying the operator

# Create the custom resource definition
$ kubectl create -f deploy/crd.yaml
# Create the Roleand create the Role Binding
$ kubectl create -f deploy/rbac.yaml
# Deploy the operator
$ kubectl create -f deploy/operator.yaml

Deploying a single node echo cluster

# Deploy the cluster
$ kubectl create -f deploy/example-single-node-cluster.yaml

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages