david.perez
david.perez

Reputation: 7012

Read-only folder to be shared to another pod

I have a pod that needs to create a lot of jobs. I'd like to share a read-only folder. How can I do it?

Several ideas I can imagine (I'm newbie to Kubernetes):

What would be the better solution for this?

Upvotes: 1

Views: 1050

Answers (1)

Taimoor Mirza
Taimoor Mirza

Reputation: 1117

You can use a PersistentVolume and mount it as read only volume inside the pod via PersistentVolumeClaim. To mount a read only volume, set .spec.containers[*].volumeMounts[*].readOnly to true.

apiVersion: v1
kind: Pod
metadata:
  name: mypod
spec:
  containers:
    - name: myfrontend
      image: nginx
      volumeMounts:
      - mountPath: "/var/www/html"
        name: mypd
        readOnly: true
  volumes:
    - name: mypd
      persistentVolumeClaim:
        claimName: myclaim

Check out these links:

  1. https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims
  2. https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistent-volumes

Upvotes: 5

Related Questions