kubernetes中的常用存储类型


这里介绍hostPath

利用hostPath的挂载卷

假如容器希望使用主机目录下的/opt/etcd/ssl/下的认证文件,可以像如下这样定义:

apiVersion: v1
kind: Pod
metadata:
  name: test-pd
spec:
  containers:
  - image: k8s.gcr.io/test-webserver
    name: test-container
    env:
    - name: ETCD_KEY_FILE
      value: "/opt/etcd/ssl/server-key.pem"
    volumeMounts:
    - mountPath: /opt/etcd/ssl/  #容器中文件所在位置
      name: etcd-ssl             #卷名称,要和volumes中的一致
  volumes:
  - name: etcd-ssl
    hostPath:
      # directory location on host
      path: /opt/etcd/ssl        #主机文件所在的位置
      # this field is optional
      type: Directory
      readOnly: true


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM