- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 Kubernetes 中有一个部署。在此部署中,我可以指定持久卷声明,如下所示:
volumes:
- name: my-volume
persistentVolumeClaim:
claimName: my-claim
我有一个磁盘(准确地说是 Azure 磁盘),其中包含大量预处理数据,我可以在 Kubernetes 中将其公开为名为 my-claim
的 PVC。在下一步中,我将其链接到部署,如上所示。这种方法的问题是,我无法将部署扩展到多个 pod。
如何扩展此设置?我尝试复制该磁盘并将其创建为具有不同名称的第二个 PVC。这有效,但现在我没有找到一种方法来告诉 Kubernetes 部署,每个 pod 应该挂载这两个 PVC 之一。
我希望有一个选项可以使用通用标签来标记两个 PVC,然后将我的部署链接到该标签而不是 PVC 名称。是否存在类似的情况,或者我的方法完全错误?
谢谢!
最佳答案
I have a disk (an Azure disk to be precise) with lots of preprocessed data, which I can expose in Kubernetes as PVC with name my-claim. In the next step I link it to the deployment as shown above. The problem with this approach is, that I cannot scale the deployment to more than one pod.
在这里,您使用带有 Access Mode 的 PersistentVolumeClaim
ReadWriteOnce
(这是 Azure 磁盘的唯一选项,请参阅访问模式链接)
How can I scale this setup? I tried to duplicate the disk and create it as second PVC with a different name. This worked, but now I don't see a way to tell the Kubernetes deployment, that each pod should mount one of these two PVCs.
在这里,听起来您想要一个具有访问模式的卷ReadOnlyMany
- 因此您需要考虑支持此访问模式的存储系统>.
I tried to duplicate the disk and create it as second PVC with a different name. This worked, but now I don't see a way to tell the Kubernetes deployment, that each pod should mount one of these two PVCs.
这不适用于 Deployment因为每个 pod 的模板
都是相同的。但你可以用 StatefulSet 来做到这一点,使用 volumeClaimTemplates
声明您的 PVC - 然后每个 Pod 的 PVC 都具有唯一的、众所周知的身份。
StatefulSet 的示例部分:
volumeClaimTemplates:
- metadata:
name: my-pvc
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: "my-storage-class"
resources:
requests:
storage: 1Gi
然后,如果您有 StatefulSet 的两个副本,它们将为您提供一个名为 my-pvc-0
和 my-pvc-1
的 PVC,其中编号称为“序数”。 volumeClaimTemplate
仅在新的 PVC 不存在时创建它,因此,如果您创建了具有正确名称的 PVC - 将使用现有的 PVC。
Azure 磁盘的替代存储解决方案是 Azure 文件。 Azure 文件支持访问模式ReadWriteOnce
、ReadOnlyMany
和ReadWriteMany
。请参阅Dynamically create and use a persistent volume with Azure Files in Azure Kubernetes Service (AKS) .
可能还有其他更适合您的应用程序的存储替代方案。
关于azure - 我可以通过标签或选择器而不是名称将 K8s 部署链接到 PVC 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64936298/
我正在开发一个 voip 调用应用程序。我需要做的是在接到来电时将 Activity 带到前台。我在应用程序中使用 Twilio,并在收到推送消息时开始调用。 问题是我试图在接到任何电话时显示 Act
我是一名优秀的程序员,十分优秀!