This repository uses two projects to construct an operator, based on the Kubernetes sample guestbook application.
- YAML Overlay Tool Used for taking the source manifests found in the Kubernetes documentation and injecting operator-builder workload markers to prepare for building an operator.
- Operator Builder Used for constructing a fully functional operator from source Kubernetes manifests that have been marked up for CRD customization.
-
Clone the repository
-
Overlay the source manifests:
cd .yot; yot -i yot.yaml
-
Initialize the repository for Operator Builder:
# assuming you're in .yot still
cd ..
go mod init guestbook-app
operator-builder init \
--workload-config .source/workload.yaml \
--skip-go-version-check
- Build the guestbook operator:
operator-builder create api \
--workload-config .source/workload.yaml \
--controller \
--resource
- Install the guestbook CRD to your cluster:
make install
- Run the operator locally for testing purposes:
make run
- Since the controller is occupying your terminal, you'll want to start up another terminal to install the sample CR to your Kubernetes cluster:
kubectl apply -f config/samples
You should now see the guestbook application get deployed into your cluster.
Please reference the operator-builder documentation for all the details on building more complex operators.