我可以依靠volumeClaimTemplates命名约定吗? [英] Can I rely on volumeClaimTemplates naming convention?

查看:2043
本文介绍了我可以依靠volumeClaimTemplates命名约定吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用本地PV 启用.我有三个工作节点.我在每个节点上创建本地PV并成功部署有状态集(使用一些复杂的脚本来设置Postgres复制).

I want to setup a pre-defined PostgreSQL cluster in a bare meta kubernetes 1.7 with local PV enable. I have three work nodes. I create local PV on each node and deploy the stateful set successfully (with some complex script to setup Postgres replication).

但是我注意到在volumeClaimTemplates和PersistentVolumeClaim之间存在一种命名约定. 例如

However I'm noticed that there's a kind of naming convention between the volumeClaimTemplates and PersistentVolumeClaim. For example

apiVersion: apps/v1beta1 
kind: StatefulSet
  metadata:   
     name: postgres
  volumeClaimTemplates:
  - metadata:
      name: pgvolume

创建的pvc是pgvolume-postgres-0pgvolume-postgres-1pgvolume-postgres-2.

使用一些 tricky ,我手动创建PVC并将其绑定到通过选择器确定目标PV.我再次测试有状态集.有状态集似乎很高兴使用这些PVC.

With some tricky, I manually create PVC and bind to the target PV by selector. I test the stateful set again. It seems the stateful set is very happy to use these PVC.

我成功完成了考试,但是我仍然有这个问题.我可以依靠volumeClaimTemplates命名约定吗?这是未记录的功能吗?

I finish my test successfully but I still have this question. Can I rely on volumeClaimTemplates naming convention? Is this an undocumented feature?

推荐答案

基于状态集

volumeClaimTemplates是允许pod引用的声明的列表. StatefulSet控制器负责以维护容器身份的方式将网络身份映射到声明.此列表中的每个声明都必须在模板的一个容器中至少有一个匹配的(按名称)volumeMount.此列表中的声明优先于模板中具有相同名称的所有卷.

volumeClaimTemplates is a list of claims that pods are allowed to reference. The StatefulSet controller is responsible for mapping network identities to claims in a way that maintains the identity of a pod. Every claim in this list must have at least one matching (by name) volumeMount in one container in the template. A claim in this list takes precedence over any volumes in the template, with the same name.

所以我想你可以依靠它.

So I guess you can rely on it.

此外,您可以定义存储类以利用持久性卷的动态配置,因此您不必手动创建它们.

Moreover, you can define a storage class to leverage dynamic provisioning of persistent volumes, so you won't have to create them manually.

  volumeClaimTemplates:
  - metadata:
      name: www
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: my-storage-class
      resources:
        requests:
          storage: 1Gi

请参考动态配置和存储类在Kubernetes中了解详情.

这篇关于我可以依靠volumeClaimTemplates命名约定吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆