Mounting a Kubernetes Volume with Quarkus

7/8/2020

I am trying to mount a volume to a Pod so that one deployment can write to it, and another deployment can read from it. I am using MiniKube with Docker on Ubuntu. I am running ./mvnw clean package -Dquarkus.kubernetes.deploy=true.

From the Quarkus documentation, it seems pretty straightforward, but I'm running into trouble.

When I add this line quarkus.kubernetes.mounts.my-volume.path=/volumePath to my application.properties, I get the following error:

[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:1.6.0.Final:build (default) on project getting-started: 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://IP:8443/apis/apps/v1/namespaces/default/deployments. Message: Deployment.apps "getting-started" is invalid: spec.template.spec.containers[0].volumeMounts[0].name: Not found: "my-volume". Received status: Status(apiVersion=v1, code=422, details=StatusDetails(causes=[StatusCause(field=spec.template.spec.containers[0].volumeMounts[0].name, message=Not found: "my-volume", reason=FieldValueNotFound, additionalProperties={})], group=apps, kind=Deployment, name=getting-started, retryAfterSeconds=null, uid=null, additionalProperties={}), kind=Status, message=Deployment.apps "getting-started" is invalid: spec.template.spec.containers[0].volumeMounts[0].name: Not found: "my-volume", metadata=ListMeta(_continue=null, remainingItemCount=null, resourceVersion=null, selfLink=null, additionalProperties={}), reason=Invalid, status=Failure, additionalProperties={}).

When I add quarkus.kubernetes.config-map-volumes.my-volume.config-map-name=my-volume (along with the previous statement), the error goes away, but the pod does not start. Running "kubectl describe pods" returns:

Normal   Scheduled    <unknown>          default-scheduler  Successfully assigned default/getting-started-859d89fc8-tbg6w to minikube
  Warning  FailedMount  14s (x6 over 30s)  kubelet, minikube  MountVolume.SetUp failed for volume "my-volume" : configmap "my-volume" not found

Does it look like the volume is not being set in the YAML file?

So my question is, how can I set the name of the volume in application.properties, so I can have a volume mounted in the Pod?

-- mjm
kubernetes
persistent-volumes
quarkus

1 Answer

7/8/2020

I recommend you look at your kubernetes.yml and kubernetes.json files under target/kubernetes

For the first error. It looks like my-volume needs to exist in your cluster either as a Persistent Volume.

For the second error quarkus.kubernetes.config-map-volumes.my-volume.config-map-name=my-volume is meant to be used as a ConfigMap so the actual ConfigMap needs to be defined/exist in your cluster.

-- Rico
Source: StackOverflow