apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: nginx-pv-demo
  name: nginx-pv-demo
spec:
  replicas: 2 
  selector:
    matchLabels:
      app: nginx-pv-demo
  template:
    metadata:
      labels:
        app: nginx-pv-demo
    spec:
      containers:
      - image: nginx 
        name: nginx
        volumeMounts: 
        - name: html
          mountPath: /usr/share/nginx/html
      volumes:
        - name: html 
          nfs: 
            server: 139.xxx.xxx.xxx 
            path: /export/nfs 

其中

          nfs: 
            server: 139.xxx.xxx.xxx 
            path: /export/nfs 

是nfs 服务器的目录配置

如果提示:

k8s need a /sbin/mount.<type> helper program)

则需要在所有结点安装nfs

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐