@Operator(forKind = "bar", prefix = "radanalytics.io", infoClass = BarInfo::class)
class BarOperator : AbstractOperator<BarInfo>() {
val log: Logger = LoggerFactory.getLogger(BarOperator::class.qualifiedName)
override fun onDelete(bar: BarInfo) {
log.info("deleted 'bar' with name ${bar.name} and parameter = ${bar.parameter}")
}
override fun onAdd(bar: BarInfo) {
log.info("created 'bar' with name ${bar.name} and parameter = ${bar.parameter}")
}
}
Check the full source code of the operator
# build the project
mvn clean install
# assuming Kubernetes is up and running, run the operator
java -jar ./target/kotlin-example-operator-*.jar
then in another terminal
# create resource bar
kubectl create -f examples/bar.yaml
# delete resource bar
kubectl delete cm my-bar