Quarkiverse Java Operator SDK

This extension integrates the Java Operator SDK project (JOSDK) with Quarkus, making it even easier to use both.

For an introduction to this project, please read the blog series that we wrote on how to write operators in Java with Quarkus. Please also refer to the JOSDK documentation for more details.

Features

  • Automatically generates a main class, so that the only thing that’s required is to write Reconciler implementation(s)

  • Automatically makes a Kubernetes/OpenShift client available for CDI injection

  • Automatically sets up an Operator instance, also available for CDI injection

  • Automatically processes the reconcilers' configuration at build time, exposing all the available configuration of JOSDK via application properties

  • Automatically registers reconcilers with the Operator and start them

  • Automatically generates CRDs for all CustomResource implementations used by reconcilers

  • Automatically generates Kubernetes descriptors

  • Automatically generates the bundle manifests for all reconcilers (using the quarkus-operator-sdk-bundle-generator extension)

  • Integrates with the Dev mode:

    • Watches your code for changes and reload automatically your operator if needed without having to hit an endpoint

    • Only re-generates the CRDs if a change impacting its generation is detected

    • Only re-processes a reconciler’s configuration if needed

    • Automatically apply the CRD to the cluster when it has changed

  • Supports micrometer registry extensions (adding a Quarkus-supported micrometer registry extension will automatically inject said registry into the operator)

  • Automatically adds a SmallRye health check

  • Sets up reflection for native binary generation

  • [Deprecated] Customize the JSON serialization that the Fabric8 client relies on by providing an ObjectMapperCustomizer implementation, qualified with the @KubernetesClientSerializationCustomizer annotation

    • The Quarkus kubernetes client extension now provides an official mechanism to do so by implementing the io.quarkus.kubernetes.client.KubernetesClientObjectMapperCustomizer interface instead so this mechanism should be used moving forward.

  • Dev mode commands:

    • Dev commands are automatically accessible from the Dev console after typing : in the Quarkus terminal in Dev mode, under the qosdk name. Two commands currently exist: qosdk api to create a Kubernetes API (hint: type qosdk api -h for more details) and qosdk versions to show which versions are targeted by QOSDK.

  • CLI command:

    • Add the Quarkus CLI command using: quarkus plug add io.quarkiverse.operatorsdk:quarkus-operator-sdk-cli:runner:jar:6.6.7

    • You can create a Kubernetes API using the quarkus operator-sdk api command, e.g. quarkus operator-sdk api -g halkyon.io -v v1 -k foo

Installation

If you want to use this extension, you need to add the quarkus-operator-sdk extension first.

You need to add minimally, the following to your pom.xml file:

<dependency>
    <groupId>io.quarkiverse.operatorsdk</groupId>
    <artifactId>quarkus-operator-sdk</artifactId>
    <version>6.6.7</version>
</dependency>

However, it might be more convenient to use the quarkus-operator-sdk-bom dependency to ensure that all dependency versions are properly aligned:

<dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>io.quarkiverse.operatorsdk</groupId>
        <artifactId>quarkus-operator-sdk-bom</artifactId>
        <version>6.6.7</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>

      <!-- other dependencies as needed by your project -->

    </dependencies>
  </dependencyManagement>

If you do use the BOM, please do make sure to use the same Quarkus version as the one defined in the BOM when configuring the Quarkus plugin as the Quarkus Dev Mode will not work properly otherwise, failing with an error:

Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalStateException: Hot deployment of the application is not supported when updating the Quarkus version. The application needs to be stopped and dev mode started up again
        at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:138)
        at io.quarkus.deployment.dev.DevModeMain.main(DevModeMain.java:62)

If you want to use the Bundle generator, you will first need to use Quarkus 2.3.0.Final or above and add the quarkus-operator-sdk-bundle-generator extension first:

<dependency>
    <groupId>io.quarkiverse.operatorsdk</groupId>
    <artifactId>quarkus-operator-sdk-bundle-generator</artifactId>
    <version>6.6.7</version>
</dependency>