java-operator-sdk icon indicating copy to clipboard operation
java-operator-sdk copied to clipboard

Apply CRDs on startup of operator

Open dennisfischer opened this issue 3 years ago • 1 comments

CRDs can be generated by using io.fabric8:crd-generator-apt as an annotationProcessor. The CRDs need to be applied manually to the cluster every time they change. This results in a bad development experience.

The quarkus-operator-sdk already deals with both tasks (Generating CRDs, Applying CRDs) and provides a configuration property to enable/disable CRD installation.

Workaround Gradle

A simple workaround could be to create an additional task. The task could be structured like the following (will fail with Kubernetes 1.22+):

task applyCrds(type: Exec) {
    commandLine = ["kubectl", "apply", "-f", "$buildDir/classes/java/main/META-INF/fabric8/"]

    tasks.compileJava.finalizedBy(tasks.applyCrds)
}

dennisfischer avatar Jan 10 '22 18:01 dennisfischer

Use the quarkus extension 😉 More seriously, though, this could be done from the SDK itself. Interested in taking a stab at it?

metacosm avatar Jan 11 '22 17:01 metacosm