简体   繁体   English

Kubernetes从外部访问Persistance卷

[英]Kubernetes access Persistance volume mount externally

I have setup kubernetes Cluster and mounted volume mount as gcePersistentDisk in Google Cloud, It claims and mount successfully in Pods. 我已经在Google Cloud中将kubernetes Cluster设置为gcePersistentDisk并安装了卷安装,它声称并成功在Pods中安装。 But i want to access this volume externally so that i can write it through git/ssh or manual. 但是我想从外部访问该卷,以便我可以通过git / ssh或手动编写它。 As disk is Already used and mounted i cannot access it. 由于磁盘已被使用和安装,因此无法访问它。 How to write files through externally? 如何通过外部写入文件?

gcePersistentDisk is a network-based disk, and provisioned volumes can only be used by GCE instances in the same project and zone. gcePersistentDisk是基于网络的磁盘,预配置的卷只能由同一项目和区域中的GCE实例使用。

The fact is that this kind of resource supports readWriteOnce and ReadOnlyMany . 事实是这种资源支持readWriteOnceReadOnlyMany You can use a GCE persistent storage to share data as read-only between multiple pods in the same zone. 您可以使用GCE永久存储在同一区域中的多个Pod之间以只读方式共享数据。

Back to your question: you can write on this volume only from one pod . 回到您的问题: 您只能从一个pod上在该卷上进行书写 No other pods can use it as write storage - neither external nor from the same project. 没有其他Pod可以将其用作写存储-既不是外部的,也不是来自同一项目的。

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: php
  labels:
    app: php
spec:
  replicas: 1
  selector:
    matchLabels:
      app: php
  template:
    metadata:
      labels:
        app: php
    spec:
      containers:
        - image: php:7.1-apache
          imagePullPolicy: Always
          name: php
          resources:
            requests:
              cpu: 200m
          ports:
            - containerPort: 80
              name: php
          volumeMounts:
            - name: php-persistent-storage
              mountPath: /var/www
      volumes:
        - name: php-persistent-storage
          gcePersistentDisk:
            pdName: php-phantomjs-disk
            fsType: ext4

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM