Open philippart-s opened 2 years ago
It's generated during the compile phase, or, at least, it should be!
This is what I remember but for one day the CRD is generated only in the package phase. I test with the sample (joke) of the extension and I have the same behavior.
What trigger the CRD generation ?
Here is a simple project generateed with the operator SDK:
operator-sdk init --plugins quarkus --domain fr.wilda --project-name hello-world-quarkus
Next: define a resource with:
operator-sdk create api --version v1 --kind HelloWorld
The mvn clean compile
command doesn't generate a CRD:
mvn clean compile
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------< wilda.fr:hello-world-quarkus >--------------------
[INFO] Building hello-world-quarkus 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ hello-world-quarkus ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ hello-world-quarkus ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ hello-world-quarkus ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to /Users/sphilipp/dev/talks/cloud-sud/hello-world-quarkus/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.400 s
[INFO] Finished at: 2022-03-12T23:49:20+01:00
[INFO] ------------------------------------------------------------------------
❯ ll target/classes
total 8
-rw-r--r-- 1 sphilipp staff 344B Mar 12 23:49 application.properties
drwxr-xr-x 3 sphilipp staff 96B Mar 12 23:49 wilda
❯ ll target/
total 0
drwxr-xr-x 4 sphilipp staff 128B Mar 12 23:49 classes
drwxr-xr-x 3 sphilipp staff 96B Mar 12 23:49 generated-sources
drwxr-xr-x 3 sphilipp staff 96B Mar 12 23:49 maven-status
The mvn clean package
command generates the CRD:
mvn clean package
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------< wilda.fr:hello-world-quarkus >--------------------
[INFO] Building hello-world-quarkus 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ hello-world-quarkus ---
[INFO] Deleting /Users/sphilipp/dev/talks/cloud-sud/hello-world-quarkus/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ hello-world-quarkus ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ hello-world-quarkus ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to /Users/sphilipp/dev/talks/cloud-sud/hello-world-quarkus/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ hello-world-quarkus ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/sphilipp/dev/talks/cloud-sud/hello-world-quarkus/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ hello-world-quarkus ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ hello-world-quarkus ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ hello-world-quarkus ---
[INFO] Building jar: /Users/sphilipp/dev/talks/cloud-sud/hello-world-quarkus/target/hello-world-quarkus-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- quarkus-maven-plugin:2.6.3.Final:build (default) @ hello-world-quarkus ---
[INFO] [org.jboss.threads] JBoss Threads version 3.4.2.Final
[WARNING] [io.quarkus.kubernetes.deployment.KubernetesDeployer] A Kubernetes deployment was requested, but the container image to be built will not be pushed to any registry because "quarkus.container-image.registry" has not been set. The Kubernetes deployment will only work properly if the cluster is using the local Docker daemon. For that reason 'ImagePullPolicy' is being force-set to 'IfNotPresent'.
[WARNING] Found multiple Kubernetes config files [[/Users/sphilipp/dev/ovh/k8s/kubeconfig.yml, /Users/sphilipp/dev/ovh/k8s/k8s-colima.yml, /Users/sphilipp/dev/ovh/k8s/kubeconfig-trillio.yml]], using the first one: [/Users/sphilipp/dev/ovh/k8s/kubeconfig.yml]. If not desired file, please change it by doing `export KUBECONFIG=/path/to/kubeconfig` on Unix systems or `$Env:KUBECONFIG=/path/to/kubeconfig` on Windows.
[WARNING] Found multiple Kubernetes config files [[/Users/sphilipp/dev/ovh/k8s/kubeconfig.yml, /Users/sphilipp/dev/ovh/k8s/k8s-colima.yml, /Users/sphilipp/dev/ovh/k8s/kubeconfig-trillio.yml]], using the first one: [/Users/sphilipp/dev/ovh/k8s/kubeconfig.yml]. If not desired file, please change it by doing `export KUBECONFIG=/path/to/kubeconfig` on Unix systems or `$Env:KUBECONFIG=/path/to/kubeconfig` on Windows.
[WARNING] Found multiple Kubernetes config files [[/Users/sphilipp/dev/ovh/k8s/kubeconfig.yml, /Users/sphilipp/dev/ovh/k8s/k8s-colima.yml, /Users/sphilipp/dev/ovh/k8s/kubeconfig-trillio.yml]], using the first one: [/Users/sphilipp/dev/ovh/k8s/kubeconfig.yml]. If not desired file, please change it by doing `export KUBECONFIG=/path/to/kubeconfig` on Unix systems or `$Env:KUBECONFIG=/path/to/kubeconfig` on Windows.
[WARNING] Found multiple Kubernetes config files [[/Users/sphilipp/dev/ovh/k8s/kubeconfig.yml, /Users/sphilipp/dev/ovh/k8s/k8s-colima.yml, /Users/sphilipp/dev/ovh/k8s/kubeconfig-trillio.yml]], using the first one: [/Users/sphilipp/dev/ovh/k8s/kubeconfig.yml]. If not desired file, please change it by doing `export KUBECONFIG=/path/to/kubeconfig` on Unix systems or `$Env:KUBECONFIG=/path/to/kubeconfig` on Windows.
[WARNING] [io.quarkus.kubernetes.deployment.KubernetesDeployer] An openshift deployment was requested, but the container image group:sphilipp is not aligned with the currently selected project:default.it is strongly advised to align them, or else the image might not be reachable.
[WARNING] Found multiple Kubernetes config files [[/Users/sphilipp/dev/ovh/k8s/kubeconfig.yml, /Users/sphilipp/dev/ovh/k8s/k8s-colima.yml, /Users/sphilipp/dev/ovh/k8s/kubeconfig-trillio.yml]], using the first one: [/Users/sphilipp/dev/ovh/k8s/kubeconfig.yml]. If not desired file, please change it by doing `export KUBECONFIG=/path/to/kubeconfig` on Unix systems or `$Env:KUBECONFIG=/path/to/kubeconfig` on Windows.
[INFO] [io.quarkiverse.operatorsdk.deployment.OperatorSDKProcessor] Registered 'wilda.fr.HelloWorld' for reflection
[INFO] [io.quarkiverse.operatorsdk.deployment.OperatorSDKProcessor] Registered 'wilda.fr.HelloWorldSpec' for reflection
[INFO] [io.quarkiverse.operatorsdk.deployment.OperatorSDKProcessor] Registered 'wilda.fr.HelloWorldStatus' for reflection
[INFO] [io.quarkiverse.operatorsdk.deployment.OperatorSDKProcessor] Processed 'wilda.fr.HelloWorldReconciler' reconciler named 'helloworldreconciler' for 'helloworlds.fr.wilda' resource (version 'fr.wilda/v1')
[INFO] Generating 'helloworlds.fr.wilda' version 'v1' with wilda.fr.HelloWorld (spec: wilda.fr.HelloWorldSpec / status wilda.fr.HelloWorldStatus)...
[INFO] [io.quarkiverse.operatorsdk.deployment.OperatorSDKProcessor] Generated helloworlds.fr.wilda CRD:
[INFO] [io.quarkiverse.operatorsdk.deployment.OperatorSDKProcessor] - v1 -> /Users/sphilipp/dev/talks/cloud-sud/hello-world-quarkus/target/kubernetes/helloworlds.fr.wilda-v1.yml
[INFO] Checking for existing resources in: /Users/sphilipp/dev/talks/cloud-sud/hello-world-quarkus/src/main/kubernetes.
[WARNING] [io.quarkiverse.operatorsdk.deployment.OperatorSDKProcessor] 'helloworldreconciler' controller is configured to watch all namespaces, this requires a ClusterRoleBinding for which we MUST specify the namespace of the operator ServiceAccount. This can be specified by setting the 'quarkus.kubernetes.namespace' property. However, as this property is not set, we are leaving the namespace blank to be provided by the user by editing the 'helloworldreconciler-cluster-role-binding' ClusterRoleBinding to provide the namespace in which the operator will be deployed.
[WARNING] [io.quarkiverse.operatorsdk.deployment.OperatorSDKProcessor] 'helloworldreconciler' controller is configured to validate CRDs, this requires a ClusterRoleBinding for which we MUST specify the namespace of the operator ServiceAccount. This can be specified by setting the 'quarkus.kubernetes.namespace' property. However, as this property is not set, we are leaving the namespace blank to be provided by the user by editing the 'helloworldreconciler-crd-validating-role-binding' ClusterRoleBinding to provide the namespace in which the operator will be deployed.
[INFO] [io.quarkus.container.image.jib.deployment.JibProcessor] Starting container image build
[WARNING] [io.quarkus.container.image.jib.deployment.JibProcessor] Base image 'fabric8/java-alpine-openjdk11-jre' does not use a specific image digest - build may not be reproducible
[INFO] [io.quarkus.container.image.jib.deployment.JibProcessor] The base image requires auth. Trying again for fabric8/java-alpine-openjdk11-jre...
[INFO] [io.quarkus.container.image.jib.deployment.JibProcessor] LogEvent [level=INFO, message=Docker config auths section defines credentials for index.docker.io]
[INFO] [io.quarkus.container.image.jib.deployment.JibProcessor] LogEvent [level=LIFECYCLE, message=Using credentials from Docker config (/Users/sphilipp/.docker/config.json) for fabric8/java-alpine-openjdk11-jre]
[INFO] [io.quarkus.container.image.jib.deployment.JibProcessor] Using base image with digest: sha256:b459cc59d6c7ddc9fd52f981fc4c187f44a401f2433a1b4110810d2dd9e98a07
[INFO] [io.quarkus.container.image.jib.deployment.JibProcessor] Container entrypoint set to [java, -Djava.util.logging.manager=org.jboss.logmanager.LogManager, -jar, quarkus-run.jar]
[INFO] [io.quarkus.container.image.jib.deployment.JibProcessor] Created container image sphilipp/hello-world-quarkus-operator:0.0.1-SNAPSHOT (sha256:5209c306034d6a1f09b450665468ef35d8a2586d7b7e698228b8836e3a9f6eaa)
[INFO] [io.quarkus.deployment.QuarkusAugmentor] Quarkus augmentation completed in 6212ms
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.322 s
[INFO] Finished at: 2022-03-12T23:53:56+01:00
[INFO] ------------------------------------------------------------------------
ll target/kubernetes
total 40
-rw-r--r-- 1 sphilipp staff 557B Mar 12 23:53 helloworlds.fr.wilda-v1.yml
-rw-r--r-- 1 sphilipp staff 5.8K Mar 12 23:53 kubernetes.json
-rw-r--r-- 1 sphilipp staff 4.6K Mar 12 23:53 kubernetes.yml
I try with my laptop and with gitpod with the same result.
My settings:
mvn -v
Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: /Users/sphilipp/Applications/homebrew/Cellar/maven/3.8.4/libexec
Java version: 17.0.2, vendor: Homebrew, runtime: /Users/sphilipp/Applications/homebrew/Cellar/openjdk/17.0.2/libexec/openjdk.jdk/Contents/Home
Default locale: en_FR, platform encoding: UTF-8
OS name: "mac os x", version: "12.1", arch: "aarch64", family: "mac"
The project can be found here: https://github.com/philippart-s/hello-world-quarkus
I'll look into it, thanks for the report!
I mostly use the Quarkus dev mode and almost never do a "simple" compile (and I mistook compile
to mean a more generic build, as in "generated at build time" 😓).
After looking more into it, the behavior is actually expected since the Quarkus maven plugin is only triggered by default on the package
phase. Any particular reason why you'd want it to be triggered on compile
?
Any particular reason why you'd want it to be triggered on
compile
?
Not specially but, just when my code is note quite stable I like just to compile to see if it's ok and the state of the CRD.
Is it possible to generate by default the CRD on the compile phase with maven ?
If I well understand the CRD is generated in the package phase or when we use the dev mode. I think it will be more convenient to generate it also in the compile phase.