这里介绍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

相关文章:

  • 2021-04-02
  • 2021-09-19
  • 2022-12-23
  • 2021-08-10
  • 2022-01-15
  • 2022-12-23
猜你喜欢
  • 2021-12-01
  • 2022-12-23
  • 2021-11-03
  • 2021-06-12
  • 2021-11-19
  • 2022-02-20
相关资源
相似解决方案