<p>Is it possible to mount disk to gke pod and compute engine at the same time.</p>
<p>I have a ubunut disk of 10 gb</p>
<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-demo
spec:
  capacity:
    storage: 10G
  accessModes:
    - ReadWriteOnce
  claimRef:
    name: pv-claim-demo
  gcePersistentDisk:
    pdName: pv-test1

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pv-claim-demo
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10G
</code></pre>
<p>deploment.yaml</p>
<pre><code>spec:
  containers:
    - image: wordpress
      name: wordpress
      ports:
        - containerPort: 80
          name: wordpress
      volumeMounts:
        - name: wordpress-persistent-storage
          mountPath: /app/logs
  volumes:
    - name: wordpress-persistent-storage
      persistentVolumeClaim:
        claimName: pv-claim-demo
</code></pre>
<p>The idea is to mount the logs files generated by pod to disk and access it from compute engine.
I cannot use NFS or hostpath to solve the problem. The other challenge is multiple pod will be writting to same pv.</p>

pythonhmmm
<blockquote>
<p>The other challenge is multiple pod will be writing to same PV.</p>
</blockquote>
<p>Yes, this does not work well, unless you have a storage class similar to NFS. The default <a href="https://kubernetes.io/docs/concepts/storage/storage-classes/" rel="nofollow noreferrer">storageClass</a> in Google Kubernetes Engine only support <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes" rel="nofollow noreferrer">access mode</a> ReadWriteOnce when dynamically provisioned - so only one replica can mount it.</p>
<blockquote>
<p>The idea is to mount the logs files generated by pod to disk and access it from compute engine.</p>
</blockquote>
<p>This is not a recommended solution for logs when using Kubernetes. An app on Kubernetes should follow the <a href="https://12factor.net/" rel="nofollow noreferrer">12 factor principles</a>, and for this problem there is a specific item about <a href="https://12factor.net/logs" rel="nofollow noreferrer">logs</a> - the app should log to <code>stdout</code>. For apps that does not follow the 12 factor principles, this can be solved by a <a href="https://kubernetes.io/docs/concepts/cluster-administration/logging/#using-a-sidecar-container-with-the-logging-agent" rel="nofollow noreferrer">sidecar that tails the log files</a> and then print them on <code>stdout</code>.</p>
<p>Logs that are printed to <code>stdout</code> is typically forwarded by the platform to a log collection system - as a service. So this is not anything the app developer need to be responsible for.</p>
<p>For how logs is handled by the platform in Google Kubernetes Engine, see <a href="https://cloud.google.com/stackdriver/docs/solutions/gke" rel="nofollow noreferrer">Google Cloud Operations suite for GKE</a></p>
