snowdrop-zen / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
1 stars 0 forks source link

Knative deployments do not generate proper volume mounts for secrets volumes #232

Closed snowdrop-bot closed 3 years ago

snowdrop-bot commented 3 years ago

Describe the bug When deploying as a knative service, the kubernetes/openshift extension does not generate secrets volume mounts properly.

Expected behavior The declared secrets are mounted in the container running as a knative service

Actual behavior

[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:1.8.0.Final:build (default) on project infinispan-client-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.dekorate.deps.kubernetes.client.KubernetesClientException: Failure executing: POST at: https://api.cluster-462c.462c.example.opentlc.com:6443/apis/serving.knative.dev/v1/namespaces/dgdemo/services. Message: admission webhook "validation.webhook.serving.knative.dev" denied the request: validation failed: volumeMount has no matching volume: spec.template.spec.containers[0].volumeMounts[0].name. Received status: Status(apiVersion=v1, code=400, details=null, kind=Status, message=admission webhook "validation.webhook.serving.knative.dev" denied the request: validation failed: volumeMount has no matching volume: spec.template.spec.containers[0].volumeMounts[0].name, metadata=ListMeta(_continue=null, remainingItemCount=null, resourceVersion=null, selfLink=null, additionalProperties={}), reason=BadRequest, status=Failure, additionalProperties={}).

To Reproduce Steps to reproduce the behavior:

  1. Add the following to application.properties:
quarkus.kubernetes.deployment-target=knative
quarkus.knative.mounts.my-volume.path=/mnt
quarkus.knative.secret-volumes.my-volume.secret-name=clientcerts

Along with other necessary bits to deploy a Quarkus app as a knative service

  1. Run mvn clean package -Pnative -DskipTests
  2. Observe failure above
  3. Observe values in target/kubernetes/knative.yml show that the volume mount is properly declared:
        volumeMounts:
        - mountPath: /mnt
          name: my-volume
          readOnly: false
          subPath: ""

But there is no corresponding volume: declared on the Service object.

When deploying as a regular non-knative deployment I do see the volume in openshift.yml:

      volumes:
      - name: my-volume
        secret:
          defaultMode: 384
          optional: false
          secretName: clientcerts

Configuration

quarkus.infinispan-client.server-list=example-infinispan:11222

# Auth
quarkus.infinispan-client.auth-server-name=example-infinispan
quarkus.infinispan-client.auth-realm=default
quarkus.infinispan-client.auth-username=developer
quarkus.infinispan-client.auth-password=XXXXXXX
quarkus.infinispan-client.sasl-mechanism=PLAIN
quarkus.infinispan-client.client-intelligence=BASIC

# cert stuff
quarkus.infinispan-client.trust-store=/mnt/clientcerts
quarkus.infinispan-client.trust-store-password=password
quarkus.infinispan-client.trust-store-type=jks

quarkus.openshift.mounts.my-volume.path=/mnt
quarkus.openshift.secret-volumes.my-volume.secret-name=clientcerts

quarkus.knative.mounts.my-volume.path=/mnt
quarkus.knative.secret-volumes.my-volume.secret-name=clientcerts

quarkus.native.container-build=true
quarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-mandrel:20.1-java11
quarkus.container-image.build=true
quarkus.kubernetes.deploy=true
quarkus.openshift.expose=true
quarkus.kubernetes-client.trust-certs=true
quarkus.kubernetes.deployment-target=knative
quarkus.container-image.registry=image-registry.openshift-image-registry.svc:5000
quarkus.container-image.group=dgdemo

Environment (please complete the following information):

openjdk version "11.0.6" 2020-01-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.6+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.6+10, mixed mode)

using Mandrel


https://github.com/quarkusio/quarkus/issues/12121


$upstream:12121$