Skip to content

Quickstart for Go-based Operators

About this tutorial

The original content is https://sdk.operatorframework.io/docs/building-operators/golang/quickstart/. In this tutorial, you can learn to create a go-based operator memcached-operator with operator-sdk step by step.

What memcached-operator does: - Manage a custom resource Memcached - spec.size: specify the number of memcached nodes. - status.nodes: contain information about nodes. - Implement the reconciliation loop in the controller - Fetch Memcached instance - Create Deployment if not exists - Keep the Memcached's size and Deployment's replicas same - Update status.nodes with Pod's name.

Prerequisite

Install the followings:

  1. operator-sdk: v1.23.0
  2. go: 1.18

Contents

  1. Initialize an operator
  2. Add API (resource and controller) for Memcached
  3. Define Memcached API (Custom Resource Definition)
  4. Implement the controller
  5. Deploy with Deployment
  6. Write controller tests
  7. CI