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