使用Quarkus挂载Kubernetes卷

时间:2020-07-08 19:19:49

标签: kubernetes quarkus persistent-volumes

我正在尝试将卷挂载到Pod,以便一个部署可以写入它,而另一个部署可以从其中读取。我在Ubuntu上使用MiniKube和Docker。我正在运行<span id="fontSizeSpan" onDoubleClick={this.resetSize.bind(this)} style={{color: this.state.color}}>{this.state.size}</span>

从Quarkus文档看来,这似乎很简单,但是我遇到了麻烦。

当我将此行./mvnw clean package -Dquarkus.kubernetes.deploy=true添加到a​​pplication.properties中时,出现以下错误:

quarkus.kubernetes.mounts.my-volume.path=/volumePath

当我添加[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={}). (以及上一条语句)时,错误消失了,但是吊舱没有启动。运行“ kubectl describe pods”返回:

quarkus.kubernetes.config-map-volumes.my-volume.config-map-name=my-volume

看起来好像没有在YAML文件中设置卷吗?

所以我的问题是,如何在application.properties中设置卷的名称,以便可以在Pod中挂载卷?

1 个答案:

答案 0 :(得分:1)

我建议您看看您的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。