【发布时间】:2023-03-18 09:38:01
【问题描述】:
我正在尝试将卷安装到 Pod,以便一个部署可以写入它,而另一个部署可以从中读取。我在 Ubuntu 上使用 MiniKube 和 Docker。我正在运行./mvnw clean package -Dquarkus.kubernetes.deploy=true。
从 Quarkus 文档来看,这似乎很简单,但我遇到了麻烦。
当我将此行 quarkus.kubernetes.mounts.my-volume.path=/volumePath 添加到我的 application.properties 时,我收到以下错误:
[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={}).
当我添加quarkus.kubernetes.config-map-volumes.my-volume.config-map-name=my-volume(连同前面的语句)时,错误消失了,但 pod 没有启动。运行“kubectl describe pods”返回:
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
看起来好像没有在 YAML 文件中设置音量?
所以我的问题是,如何在 application.properties 中设置卷的名称,以便在 Pod 中挂载卷?
【问题讨论】:
标签: kubernetes quarkus persistent-volumes