pod 应用程序存储在 PV 持久存储上的文件在主机上不可见。配置显示没有错误。配置 - 单个 pv、pvc、pod。 我对这个环境还很陌生。
PV:
apiVersion: v1
kind: PersistentVolume
metadata:
name: notowania-pv
spec:
storageClassName: manual
capacity:
storage: 10Gi #Size of the volume
accessModes:
- ReadWriteOnce #type of access
hostPath:
path: "/home/user1684/dane" #host location
光伏状态:
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
notowania-pv 10Gi RWO Retain Bound default/notowania-pv manual 22m
聚氯乙烯:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: notowania-pv
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
PVC状态:
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
notowania-pv Bound notowania-pv 10Gi RWO manual 24m
pods :
apiVersion: "apps/v1"
kind: "Deployment"
metadata:
name: "notowania"
namespace: "default"
labels:
app: "notowania"
spec:
replicas: 1
selector:
matchLabels:
app: "notowania"
template:
metadata:
labels:
app: "notowania"
spec:
containers:
- name: "selenium-docker-sha256"
image: "eu.gcr.io/firstapp-249912/selenium_docker@sha256:da15e666c3472e93979d821c912c2855951e579a91238f35f0e339b85343ed6b"
volumeMounts:
- name: notowania
mountPath: /notowania
volumes:
- name: notowania
persistentVolumeClaim:
claimName: notowania-pv
容器状态:
NAME READY STATUS RESTARTS AGE
notowania-79d68c8c56-79q55 1/1 Running 0 25m
pod 上的文件:
user1684@cloudshell:~ (firstapp-249912)$ kubectl exec -it notowania-79d68c8c56-79q55 -- /bin/bash
root@notowania-79d68c8c56-79q55:/usr/src/app# ll /notowania/
total 8
drwxr-xr-x 2 root root 4096 Sep 18 12:54 ./
drwxr-xr-x 1 root root 4096 Sep 18 12:51 ../
-rw-r--r-- 1 root root 0 Sep 18 12:54 aaa
主机上的文件:
user1684@cloudshell:~ (firstapp-249912)$ pwd
/home/user1684
user1684@cloudshell:~ (firstapp-249912)$ ll dane
total 8
drwxr-xr-x 2 user1684 user1684 4096 Sep 17 23:13 ./
drwxr-xr-x 15 user1684 user1684 4096 Sep 18 14:47 ../
所以我不知道为什么 aaa 在谷歌云的主机上不可见 - 因为我认为“aaa”文件应该在这里。
最佳答案
我认为问题是由您在哪个主机上检查目录内容引起的。
- 您已在“cloudshell”虚拟机上执行了最后一条命令,该虚拟机仅用于与 GCP 交互,并非集群节点。
- 您应该在集群节点上检查它。
- 要检查集群节点的状态,您应该执行以下操作:
$ gcloud compute instances list
NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS
gke-tt-test1-default-pool-a4cf7d86-rgt2 europe-west3-a g1-small 10.156.0.2 1.2.3.4 RUNNING
$ gcloud compute ssh gke-tt-test1-default-pool-a4cf7d86-rgt2
user@gke-tt-test1-default-pool-a4cf7d86-rgt2 ~ $ ls -la /home/user1684/dane
total 8
drwxr-xr-x 2 root root 4096 Sep 18 14:16 .
drwxr-xr-x 3 root root 4096 Sep 18 14:12 ..
-rw-r--r-- 1 root root 0 Sep 18 14:16 aaa
关于kubernetes - pod 应用程序存储在 PV 持久存储上的文件在主机上不可见 [GKE],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57993834/