k8s之pod多个挂载点写法

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了k8s之pod多个挂载点写法相关的知识,希望对你有一定的参考价值。

docker run -p 80:80 --name mynginx -v $PWD/www:/www -v $PWD/conf/nginx.conf:/etc/nginx/nginx.conf -v $PWD/logs:/wwwlogs -d nginx

cat nginx-pod.yaml

apiVersion: v1
kind: Pod
metadata:
 name: nginx-pod
 labels:
  name: nginx-pod
spec:
 containers:
 - name: nginx
   image: nginx
   volumeMounts:
   - mountPath: /www
     name: www
   - mountPath: /etc/nginx/nginx.conf
     name: conf
   - mountPath: /wwwlogs
     name: logs
   ports:
   - containerPort: 80
 volumes:
 - name: www
   hostPath: 
     path: "/root/nginx/www"
 - name: conf
   hostPath:
     path: "/root/nginx/conf/nginx.conf"
 - name: logs
   hostPath:
     path: "/root/nginx/logs"

以上是关于k8s之pod多个挂载点写法的主要内容,如果未能解决你的问题,请参考以下文章

k8s日志收集 - 利用HOSTNAME环境变量对多个pod挂载不同目录方案

k8s之存储抽象nfs挂载

k8s核心资源对象& NameSpace(指定版本回滚)

K8S之Pod

K8S之Pod

k8s之存储卷及pvc