简体   繁体   English

在Kubernetes中保持Pod Volume Mount的可配置性

[英]Keeping pod volume mount configurable in Kubernetes

Is it possible to keep the volume mount configurable, such that I can choose to mount any specific persistent volume claim during POD creation? 是否可以保持卷挂载的可配置性,以便我可以选择在POD创建期间挂载任何特定的持久卷声明?

I have a list of volume claims and I'm looking to configure my PodSpec in a way that will let me decide which claim to use as a volume mount without having to modify the YAML every time. 我有一个批量声明列表,并且我正在寻找一种配置PodSpec的方法,该方法可以让我决定将哪个声明用作批量挂载,而不必每次都修改YAML。

It is fine with me to run an additional kubectl command on the cluster before creating a new pod. 在创建新的Pod之前,可以在集群上运行附加的kubectl命令对我来说是很好的。

Based on your description here and in slack https://kubernetes.slack.com/archives/C09NXKJKA/p1559740826069800 根据您的描述在这里和松弛https://kubernetes.slack.com/archives/C09NXKJKA/p1559740826069800

Firstly, there is no interactive way to deploy yamls which will let you choose during run-time. 首先,没有交互式的方式来部署Yaml,这会让您在运行时进行选择。 Yaml are delarative therefore, you declare and then apply. Yaml是delarative,因此,您声明然后申请。 NO questions asked, unless you have syntax errors! 除非您有语法错误,否则不会提出任何问题!

Secondly, if you are looking for a kubectl command which the Sysadm will apply on production. 其次,如果您正在寻找kubectl命令,则Sysadm将在生产中应用该命令。 Then right after deploying the dev yaml, you can use a (something similar to your use case) kubectl patch [resource name example pod] --patch '{"spec":{"volumes":[{"name": "glusterfsvol","persistentVolumeClaim": {"claimName": "nameOfNewVolumeClaim"}}]}}' 然后,在部署开发人员yaml之后,您可以使用(类似于您的用例) kubectl patch [资源名称示例pod] --patch '{"spec":{"volumes":[{"name": "glusterfsvol","persistentVolumeClaim": {"claimName": "nameOfNewVolumeClaim"}}]}}'

Lastly, What would be more concrete in your use case is to use a different storageclass in your dev and another one in production. 最后,什么是在你的使用情况更具体的是使用不同的storageclass在你的开发,另一个生产。 In that you can have the same pvc which point to a different storage as it is defined in that k8s cluster. 这样,您可以拥有相同的pvc,该pvc指向与该k8s集群中定义的存储不同的存储。 refer docs 参考文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM