Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Operator SDK

This tutorial demonstrates simple operator-sdk workflow and examines Reconcile loop which will typical Operator developer deal with.

Official Operator SDK repository.

Operator SDK tutorial

Check operator-sdk prerequisites doc before starting this tutorial.

Create minimal Operator in GOPATH:

mkdir -p $GOPATH/src/
cd $GOPATH/src/
operator-sdk new workshop-operator

Add API to generated Operator(shall be executed inside workshop-operator directory):

operator-sdk add api --kind=WorkshopApp

Check which files were added or updated.

Add Controller to generated Operator:

operator-sdk add controller --kind=WorkshopApp

Check which files were added or updated.

Build and run operator locally:

# Create CRD
kubectl create -f ./deploy/crds/workshopapp_v1alpha1_workshopapp_crd.yaml

go build ./cmd/manager
WATCH_NAMESPACE=default ./manager

# Create instance of app
kubectl create -f ./deploy/crds/workshopapp_v1alpha1_workshopapp_cr.yaml


  • delete the pod, observe what happened and explain it
    • hint: check Reconcile method in pkg/controller/workshopapp/workshopapp_controller.go file.
  • Stop Operator and delete CR, observe if Pod was deleted and explain why.
You can’t perform that action at this time.