gpt4 book ai didi

kubernetes - 使用Quarkus挂载Kubernetes卷

转载 作者:行者123 更新时间:2023-12-02 12:11:20 24 4
gpt4 key购买 nike

我正在尝试将卷挂载到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(以及前面的语句)时,错误消失了,但是 pods 没有启动。运行“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.yml and kubernetes.json files under target/kubernetes
对于第一个错误。看来my-volume需要作为Persistent Volume存在于您的集群中。
对于第二个错误,quarkus.kubernetes.config-map-volumes.my-volume.config-map-name=my-volume打算用作ConfigMap,因此需要在集群中定义/存在实际的ConfigMap。

关于kubernetes - 使用Quarkus挂载Kubernetes卷,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62802175/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com