Volume storage of K8S

1. Temporary storage volume: emptyDir

Create an empty volume to the Pod, delete the Pod, the volume is also deleted

The default storage path is : /var/lib/kubelet/pods/<Pod ID>/volumes/kubernetes.io~empty-dir/

spec:
  containers:
  - name: empty
    image: nginx
    imagePullPolicy: IfNotPresent
    ports:
    - containerPort: 80
    volumeMounts:
      - name: data
        mountPath: /data
  volumes:
  - name: data
    emptyDir: {
    
    }

Two, node storage volume hostPath

Mount the directory or file on the node to the Pod container

Mount the /tmp directory of the host to the /data directory of the Pod container

spec:
  containers:
  - name: empty
    image: nginx
    imagePullPolicy: IfNotPresent
    ports:
    - containerPort: 80
    volumeMounts:
      - name: data
        mountPath: /data
  volumes:
  - name: data
    hostPath:
      path: /tmp

Three, network storage volume NFS

spec:
  containers:
  - name: empty
    image: nginx
    imagePullPolicy: IfNotPresent
    ports:
    - containerPort: 80
    volumeMounts:
      - name: data
        mountPath: /data
  volumes:
  - name: data
    nfs:
      server: 192.168.1.10			#NFS服务器地址
      path: /app					#NFS共享的目录

Guess you like

Origin blog.csdn.net/anqixiang/article/details/108817679