带有GCP存储磁盘的Pod Volume Mount(PV / PVC)从POD删除现有文件/文件夹

时间:2019-04-03 08:52:48

标签: kubernetes google-cloud-platform google-kubernetes-engine persistent-volumes gce-persistent-disk

https://github.com/jchowdhary/k8volume

# This POD volume is mounted to PD
apiVersion: v1
kind: Pod
metadata:
  name: apppod
spec:
  containers:
  - name: apppod
    image: gcr.io/kubeapps-234209/appshell:1.0
    imagePullPolicy: Always
    resources: {}
    securityContext:
      allowPrivilegeEscalation: true
      capabilities:
        add:
        - ALL
      privileged: true
    stdin: true
    terminationMessagePath: /dev/termination-log
    terminationMessagePolicy: File
    tty: true
    volumeMounts:
    - name: app-persistent-storage
      mountPath: /home/e-smith/db
      subPath: home/e-smith/db
  volumes:
  - name: app-persistent-storage
    persistentVolumeClaim:
      claimName: app-volumeclaim
---
apiVersion: v1
kind: PersistentVolume
metadata:
  annotations:
    pv.kubernetes.io/bound-by-controller: "yes"
  finalizers:
  - kubernetes.io/pv-protection
  labels:
    failure-domain.beta.kubernetes.io/region: us-central1
    failure-domain.beta.kubernetes.io/zone: us-central1-a
  name: app-pv
  selfLink: /api/v1/persistentvolumes/app-pv
spec:
  accessModes:
  - ReadWriteMany
  capacity:
    storage: 100Gi
  gcePersistentDisk:
    fsType: ext4
    pdName: apppd
  persistentVolumeReclaimPolicy: Retain
  storageClassName: standard
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  annotations:
    pv.kubernetes.io/bind-completed: "yes"
    pv.kubernetes.io/bound-by-controller: "yes"
  finalizers:
  - kubernetes.io/pvc-protection
  name: app-volumeclaim
  selfLink: /api/v1/persistentvolumeclaims/app-volumeclaim
spec:
  accessModes:
  - ReadWriteMany
  resources:
    requests:
      storage: 100Gi
  storageClassName: standard
  volumeName: app-pv
---   

pl检查app.yaml,其中包含创建以下用例所需的所有特定配置。您需要创建具有100G空间的存储磁盘“ apppd”才能使用此用例。

将Pod Volume目录安装到Google PD时出现奇怪的行为。从已挂载的POD目录中删除现有文件。

我正在使用GCP创建的Kubernetes集群中启动POD。此pod是使用CentOS基本映像创建的。当我不执行任何卷挂载时,我可以从POD shell中查看目录结构及其文件。当我在POD的某个目录(包含子目录和文件)上进行卷挂载时,当我们启动POD时,所有现有的文件和文件夹都会被删除。 PV和PVC已成功创建,并与Google PD POD when NO Volume is Mounted, all files can be browsed

绑定并对齐

POD when Volume is mounted with Google PD, all files are deleted except configuration here

0 个答案:

没有答案