Missing spec.template.metadata.labels in deployment
Closed this issue · 2 comments
SKSniperSK commented
Describe the bug
Following the OpenShift Guide (https://quarkus.io/guides/deploying-to-openshift) I tried to switch from the default DeploymentConfig to Deployment but ended up with the error:
Message: Deployment.apps "openshift-quickstart" is invalid: spec.template.metadata.labels: Invalid value: map[string]string(nil): `selector` does not match template `labels`.
Looking at the produced openshift.yml I saw that there seems to be missing metadata labels in the spec template:
---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
app.openshift.io/vcs-url: <<unknown>>
app.quarkus.io/build-timestamp: 2022-11-25 - 17:08:22 +0000
labels:
app.kubernetes.io/version: 1.0.0-SNAPSHOT
app.kubernetes.io/name: openshift-quickstart
app.openshift.io/runtime: quarkus
name: openshift-quickstart
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: openshift-quickstart
app.kubernetes.io/version: 1.0.0-SNAPSHOT
template:
spec:
containers:
- env:
- name: JAVA_APP_JAR
value: /deployments/quarkus-run.jar
image: image-registry.openshift-image-registry.svc:5000/quarkus-test/openshift-quickstart:1.0.0-SNAPSHOT
imagePullPolicy: Always
name: openshift-quickstart
ports:
- containerPort: 8080
name: http
protocol: TCP
---
Expected behavior
Ending up with a working Deployment when using the config "quarkus.openshift.deployment-kind=Deployment"
Actual behavior
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 49.388 s
[INFO] Finished at: 2022-11-25T18:08:46+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.quarkus.platform:quarkus-maven-plugin:2.14.1.Final:build (default) on project openshift-quickstart: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[ERROR] [error]: Build step io.quarkus.kubernetes.deployment.KubernetesDeployer#deploy threw an exception: io.fabric8.kubernetes.client.KubernetesClientException: Failure executing: POST at: https://api.crc.testing:6443/apis/apps/v1/namespaces/quarkus-test/deployments. Message: Deployment.apps "openshift-quickstart" is invalid: spec.template.metadata.labels: Invalid value: map[string]string(nil): `selector` does not match template `labels`. Received status: Status(apiVersion=v1, code=422, details=StatusDetails(causes=[StatusCause(field=spec.template.metadata.labels, message=Invalid value: map[string]string(nil): `selector` does not match template `labels`, reason=FieldValueInvalid, additionalProperties={})], group=apps, kind=Deployment, name=openshift-quickstart, retryAfterSeconds=null, uid=null, additionalProperties={}), kind=Status, message=Deployment.apps "openshift-quickstart" is invalid: spec.template.metadata.labels: Invalid value: map[string]string(nil): `selector` does not match template `labels`, metadata=ListMeta(_continue=null, remainingItemCount=null, resourceVersion=null, selfLink=null, additionalProperties={}), reason=Invalid, status=Failure, additionalProperties={}).
[ERROR] at io.fabric8.kubernetes.client.KubernetesClientException.copyAsCause(KubernetesClientException.java:238)
[ERROR] at io.fabric8.kubernetes.client.dsl.internal.OperationSupport.waitForResult(OperationSupport.java:517)
[ERROR] at io.fabric8.kubernetes.client.dsl.internal.OperationSupport.handleResponse(OperationSupport.java:551)
[ERROR] at io.fabric8.kubernetes.client.dsl.internal.OperationSupport.handleResponse(OperationSupport.java:535)
[ERROR] at io.fabric8.kubernetes.client.dsl.internal.OperationSupport.handleCreate(OperationSupport.java:328)
[ERROR] at io.fabric8.kubernetes.client.dsl.internal.BaseOperation.handleCreate(BaseOperation.java:675)
[ERROR] at io.fabric8.kubernetes.client.dsl.internal.BaseOperation.handleCreate(BaseOperation.java:88)
[ERROR] at io.fabric8.kubernetes.client.dsl.internal.CreateOnlyResourceOperation.create(CreateOnlyResourceOperation.java:42)
[ERROR] at io.fabric8.kubernetes.client.utils.internal.CreateOrReplaceHelper.createOrReplace(CreateOrReplaceHelper.java:50)
[ERROR] at io.fabric8.kubernetes.client.dsl.internal.BaseOperation.createOrReplace(BaseOperation.java:296)
[ERROR] at io.fabric8.kubernetes.client.dsl.internal.BaseOperation.createOrReplace(BaseOperation.java:88)
[ERROR] at io.fabric8.kubernetes.client.extension.ResourceAdapter.createOrReplace(ResourceAdapter.java:121)
[ERROR] at io.quarkus.kubernetes.deployment.KubernetesDeployer.lambda$deploy$5(KubernetesDeployer.java:251)
[ERROR] at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
[ERROR] at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
[ERROR] at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
[ERROR] at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
[ERROR] at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
[ERROR] at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
[ERROR] at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
[ERROR] at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
[ERROR] at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
[ERROR] at io.quarkus.kubernetes.deployment.KubernetesDeployer.deploy(KubernetesDeployer.java:226)
[ERROR] at io.quarkus.kubernetes.deployment.KubernetesDeployer.deploy(KubernetesDeployer.java:135)
[ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
[ERROR] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.base/java.lang.reflect.Method.invoke(Method.java:568)
[ERROR] at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:909)
[ERROR] at io.quarkus.builder.BuildContext.run(BuildContext.java:281)
[ERROR] at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
[ERROR] at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
[ERROR] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
[ERROR] at java.base/java.lang.Thread.run(Thread.java:833)
[ERROR] at org.jboss.threads.JBossThread.run(JBossThread.java:501)
[ERROR] Caused by: io.fabric8.kubernetes.client.KubernetesClientException: Failure executing: POST at: https://api.crc.testing:6443/apis/apps/v1/namespaces/quarkus-test/deployments. Message: Deployment.apps "openshift-quickstart" is invalid: spec.template.metadata.labels: Invalid value: map[string]string(nil): `selector` does not match template `labels`. Received status: Status(apiVersion=v1, code=422, details=StatusDetails(causes=[StatusCause(field=spec.template.metadata.labels, message=Invalid value: map[string]string(nil): `selector` does not match template `labels`, reason=FieldValueInvalid, additionalProperties={})], group=apps, kind=Deployment, name=openshift-quickstart, retryAfterSeconds=null, uid=null, additionalProperties={}), kind=Status, message=Deployment.apps "openshift-quickstart" is invalid: spec.template.metadata.labels: Invalid value: map[string]string(nil): `selector` does not match template `labels`, metadata=ListMeta(_continue=null, remainingItemCount=null, resourceVersion=null, selfLink=null, additionalProperties={}), reason=Invalid, status=Failure, additionalProperties={}).
[ERROR] at io.fabric8.kubernetes.client.dsl.internal.OperationSupport.requestFailure(OperationSupport.java:709)
[ERROR] at io.fabric8.kubernetes.client.dsl.internal.OperationSupport.requestFailure(OperationSupport.java:689)
[ERROR] at io.fabric8.kubernetes.client.dsl.internal.OperationSupport.assertResponseCode(OperationSupport.java:640)
[ERROR] at io.fabric8.kubernetes.client.dsl.internal.OperationSupport.lambda$handleResponse$0(OperationSupport.java:576)
[ERROR] at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
[ERROR] at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
[ERROR] at java.base/java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2147)
[ERROR] at io.fabric8.kubernetes.client.dsl.internal.OperationSupport.lambda$retryWithExponentialBackoff$2(OperationSupport.java:618)
[ERROR] at java.base/java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:863)
[ERROR] at java.base/java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:841)
[ERROR] at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
[ERROR] at java.base/java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2147)
[ERROR] at io.fabric8.kubernetes.client.okhttp.OkHttpClientImpl$4.onResponse(OkHttpClientImpl.java:277)
[ERROR] at okhttp3.RealCall$AsyncCall.execute(RealCall.java:174)
[ERROR] at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
[ERROR] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[ERROR] at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[ERROR] at java.base/java.lang.Thread.run(Thread.java:833)
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
How to Reproduce?
- mvn io.quarkus.platform:quarkus-maven-plugin:2.14.1.Final:create -DprojectGroupId=org.acme -DprojectArtifactId=openshift-quickstart -Dextensions="resteasy-reactive,openshift"
- cd openshift-quickstart
- mvnw install -Dquarkus.kubernetes.deploy=true -Dquarkus.openshift.deployment-kind=Deployment -Dquarkus.container-image.group=quarkus-test
Output of uname -a
or ver
No response
Output of java -version
Java version: 17.0.3
GraalVM version (if different from Java)
No response
Quarkus version or git rev
No response
Build tool (ie. output of mvnw --version
or gradlew --version
)
Apache Maven 3.8.6
Additional information
No response
quarkus-bot commented
geoand commented
I can reproduce the problem indeed.