Simple Java Operator built with Java Operator SDK
Prerequisites
- Operator SDK installed.
- Maven installed.
- AMQ Streams Operator installed in your cluster.
If you are on Mac OS, Operator SDK and Maven can be installed using Homebrew -
brew install operator-sdk mvn
Additional context
- https://javaoperatorsdk.io/docs/features
- https://developers.redhat.com/articles/2022/04/04/writing-kubernetes-operators-java-josdk-part-3-implementing-controller#reconciler
- https://github.com/fabric8io/kubernetes-client/blob/master/doc/CHEATSHEET.md
Generate code
operator-sdk init --plugins quarkus --domain opdev.io --project-name simple-java
operator-sdk create api --group tools --version v1 --kind DemoResource
Compilation (Maven)
mvn clean compile
mvn quarkus:dev
Testing (while Quarkus is running or controller deployed)
oc apply -f src/test/resources/cr-test-demo-resource.yaml
Cleanup
Removing the demo resource
Note: this works because all generated resources (Operands) have Owner References to the demo resource
oc delete -f src/test/resources/cr-test-demo-resource.yaml
Removing the operator
Press q
from Quarkus, or make undeploy
in case you have applied the kubernetes.yaml
.