Gr3*_*3at 5 kubernetes persistent-volumes persistent-volume-claims
我想在readOnly容器内利用持久卷中的数据。readOnly在volumeMounts部署下设置flag与在部署下设置flag有什么区别volumes.persistentVolumeClaim?
结果似乎是一样的。两者之一是否多余?
---
kind: Deployment
apiVersion: apps/v1
metadata:
name: ${ORDERER_ORG_NAME}-delpoyment
namespace: ${NS}
labels:
app: ${ORDERER_ORG_NAME}
spec:
replicas: 1
selector:
matchLabels:
app: ${ORDERER_ORG_NAME}
template:
metadata:
labels:
app: ${ORDERER_ORG_NAME}
spec:
initContainers:
- name: prepare-tls-certs
image: busybox
imagePullPolicy: IfNotPresent
command: ["/bin/sh", "wait-for-certs.sh"]
volumeMounts:
- name: fabric-volume
mountPath: ${ORDERER_ORG_PATH}
subPath: var/hyperledger/config/tls
readOnly: true
containers: # other containers
volumes:
- name: fabric-volume
persistentVolumeClaim:
readOnly: true
claimName: fabric-pvc
Run Code Online (Sandbox Code Playgroud)
就你而言,是的,结果是一样的。但这个功能并不是多余的,因为readOnly在卷上和readOnly在 a 上mountPoint有不同的含义。例如,
readOnly: trueon avolumeMount表示ro在安装端点时设置安装选项。这是在container level. 您可以mount options 在此处阅读更多相关信息。readOnly: true在卷上意味着该卷是只读的。即使您不将其安装为readOnly,您也无法对其进行写入。这是在 Pod 级别上,任何将挂载此卷的容器都将无法写入。然而,它不一定是 readOnly。readOnly:false您也可以设置您的volume意愿,writeable但安装的位置filesystem可以readOnly。这样,其他容器就可以挂载该卷并readOnly: false能够对其进行写入。例如,这可以用来确保某些容器不允许修改卷,但其他容器可以。为了将其提升到“堆栈下层”,您可以将PersistentVolumes其跨多个 Pod(跨多个节点)共享。在这里,该字段与的readOnly一起发挥作用。您可以有一个含义,即 1可以让 pod 附加此卷,而许多 pod 只能从中获取。超过 1 个的 pod 将无法写入此卷。您可以在这里阅读更多相关内容。AccessModePersistentVolumeAccessModeWriteOnceReadManynodewritingreadnodeAccessModesPersistentVolumes
总之,权限通常总是AND与最严格的权限一起编辑up the stack。因此,一般来说,anAccessMode会更宽松,aVolume权限会更宽松,而这些volumeMount权限在设计上会是最不宽松的。这就是您设计资源访问的方式。
| 归档时间: |
|
| 查看次数: |
11738 次 |
| 最近记录: |