0

如何将 FileStorage 挂载到 GCP 中的 Kubernetes pod

我确实遵循了文档,但豆荚仍在等待中

我做了:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: <some name>
spec:
  capacity:
    storage: 50Gi
  accessModes:
  - ReadWriteMany
  nfs:
    path: /
    server: <filestorage_ip with this format xx.xxx.xxx.xx>
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: <some name>
  namespace: <some name>
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: ""
  resources:
    requests:
      storage: 50Gi
apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: <some name>
  name: <some name>
  labels:
    app: <some name>
spec:
  replicas: 2
  selector:
    matchLabels:
      app: <some name>
  template:
    metadata:
      labels:
        app: <some name>
    spec:
      containers:
      - name: <some name>
        image: gcr.io/somepath/<some name>@sha256:<some hash>
        ports:
        - containerPort: 80 
        volumeMounts:
          - name: <some name>
            mountPath: /var/www/html
        imagePullPolicy: Always
      restartPolicy: Always
      volumes:
        - name: <some name>
          persistentVolumeClaim:
            claimName: <some name>
            readOnly: false

运行kubectl -n <some name> describe pods返回:

Events:
  Type     Reason       Age                     From                                                        Message
  ----     ------       ----                    ----                                                        -------
  Warning  FailedMount  23m (x52 over 3h21m)    kubelet, gke-<some name>-default-pool-<some hash>  Unable to mount volumes for pod "<some name>-<some hash>_<some name>(<some hash>)": timeout expired waiting for volumes to attach or mount for pod "<some name>"/"<some name>-<some hash>". list of unmounted volumes=[<some name>-persistent-storage]. list of unattached volumes=[<some name>-persistent-storage default-token-<some hash>]
  Warning  FailedMount  3m5s (x127 over 3h21m)  kubelet, gke-<some name>-default-pool-<some hash>  (combined from similar events): MountVolume.SetUp failed for volume "<some name>-storage" : mount failed: exit status 1
Mounting command: systemd-run
Mounting arguments: --description=Kubernetes transient mount for /var/lib/kubelet/pods/<some path>/volumes/kubernetes.io~nfs/<some name>-storage --scope -- /home/kubernetes/containerized_mounter/mounter mount -t nfs <filestorage_ip with this format xx.xxx.xxx.xx>:/ /var/lib/kubelet/pods/<some hash>/volumes/kubernetes.io~nfs/<some name>-storage
Output: Running scope as unit: run-<some hash>.scope
Mount failed: mount failed: exit status 32
Mounting command: chroot
Mounting arguments: [/home/kubernetes/containerized_mounter/rootfs mount -t nfs <filestorage_ip with this format xx.xxx.xxx.xx>:/ /var/lib/kubelet/pods/<some hash>/volumes/kubernetes.io~nfs/<some name>-storage]
Output: mount.nfs: access denied by server while mounting <filestorage_ip with this format xx.xxx.xxx.xx>:/

似乎 pod 无法访问 FileStorage 服务的 IP 在文档中说需要在同一个 VPC 上

“授权网络 * Filestore 实例只能从授权 VPC 网络上的机器访问。选择您需要访问的网络。”

但是不知道怎么把Kubernetes集群加入VPC

有什么建议么?

4

1 回答 1

1

我发现了问题

PersistentVolume无法挂载它需要“path: / 文件共享属性”字段,让您填写创建现在可以与多个 pod 一起使用!

于 2019-07-05T08:32:23.547 回答