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

README.org

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/github.com/prgcont/
cd $GOPATH/src/github.com/prgcont/
operator-sdk new workshop-operator

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

operator-sdk add api --api-version=workshopapp.operator.prgcont.cz/v1alpha1 --kind=WorkshopApp

Check which files were added or updated.

Add Controller to generated Operator:

operator-sdk add controller --api-version=workshopapp.operator.prgcont.cz/v1alpha1 --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

Tasks:

  • 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.