Kubernetes开发

kubernetes如何挂载指定文件

2018-07-29  本文已影响940人  BleyeShine

kubernetes的volume中没有直接挂载文件的配置,需要使用subPath来实现文件的挂载。

pod使用subPath挂载文件

如下:将宿主机目录/home/busybox/busybox.conf挂载到容器到/home目录

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: busybox-deploy
spec:
  replicas: 1
  template:
    metadata:
      labels:
        deploy: busybox
    spec:
      containers:
      - name: busybox
        image: hub.docker.com/google_containers/busybox:latest
        command:
        - sleep
        - "3600"
        volumeMounts:
        - mountPath: /home/busybox.conf
          name: conf
          subPath: busybox.conf
      volumes:
      - name: conf
        hostPath:
          path: /home/busybox/
上一篇 下一篇

猜你喜欢

热点阅读