Kubernetes access Persistance volume mount externally

7/3/2018

I have setup kubernetes Cluster and mounted volume mount as gcePersistentDisk in Google Cloud, It claims and mount successfully in Pods. But i want to access this volume externally so that i can write it through git/ssh or manual. As disk is Already used and mounted i cannot access it. How to write files through externally?

-- Rupesh kumar
docker
docker-volume
google-cloud-platform
kubernetes

1 Answer

7/4/2018

gcePersistentDisk is a network-based disk, and provisioned volumes can only be used by GCE instances in the same project and zone.

The fact is that this kind of resource supports readWriteOnce and ReadOnlyMany. You can use a GCE persistent storage to share data as read-only between multiple pods in the same zone.

Back to your question: you can write on this volume only from one pod. No other pods can use it as write storage - neither external nor from the same project.

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
-- d0bry
Source: StackOverflow