<p>I have an application that relies on 4 docker data containers for the data it needs to run some tests. At the moment I have their docker-compose file and their images but I don't have access to the data containers Dockerfile or actual data.</p>

<p>How this application works in docker-compose is as below:
The application is called <code>rtsp_server</code> and it loads different volumes from the data containers such as <code>st-andries4</code>(I just wrote one of them).</p>

<p>This is their docker-compose:</p>

<pre><code># The application
rtsp_server:
  image: rtsp_server_image
  volumes_from:
    - rtsp_data_st_andries4:ro
  ports:
    - "8554:8554"
  command: python ./rtsp-server.py /rtsp_data/st-andries-4 st_andries_4

# Data container
rtsp_data_st_andries4:
  image: st_andries_4:1
  volumes:
    - /rtsp_data/st-andries-4
  command: /bin/true
  mem_limit: 10000000000
</code></pre>

<p>I already brought the application, <code>rtsp_server</code>, to Kubernetes and it works fine but I need to also bring the data containers to k8s but I don't know how to do it.</p>

AVarf
<p>I'm not exactly sure if you want to create a Persistent Volume on Kubernetes or move date from existing Docker data containers.</p>

<p>Here is a Kubernetes documentation on how to <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/" rel="nofollow noreferrer">Configure a Pod to Use a PersistentVolume for Storage</a>.</p>

<p>First you should create a <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/#create-a-persistentvolume" rel="nofollow noreferrer"><code>PersistentVolume</code></a>:</p>

<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: task-pv-volume
  labels:
    type: local
spec:
  storageClassName: manual
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/mnt/data"
</code></pre>

<p>Then <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/#create-a-persistentvolumeclaim" rel="nofollow noreferrer"><code>PersistentVolumeClaim</code></a> because this is was <code>pod</code> uses to request physical storage.</p>

<pre><code>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: task-pv-claim
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 3Gi
</code></pre>

<p>And finally you can add a <code>volumeMounts</code> inside your pod that might look like the following:</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: task-pv-pod
spec:
  volumes:
    - name: task-pv-storage
      persistentVolumeClaim:
        claimName: task-pv-claim
  containers:
    - name: task-pv-container
      image: nginx
      ports:
        - containerPort: 80
          name: "http-server"
      volumeMounts:
        - mountPath: "/usr/share/nginx/html"
          name: task-pv-storage
</code></pre>

<p><strong>Update</strong></p>

<p>To share PVC between many pods you would have to set up:</p>

<pre><code>spec:
    accessModes:
      - ReadWriteMany
</code></pre>

<p>I would also recommend checking this blog <a href="https://medium.com/asl19-developers/create-readwritemany-persistentvolumeclaims-on-your-kubernetes-cluster-3a8db51f98e3" rel="nofollow noreferrer">Create ReadWriteMany PersistentVolumeClaims on your Kubernetes Cluster</a> and choosing which solution fits your needs.</p>

<p>You might be also interested in project <a href="https://rook.io/docs/rook/v1.1/" rel="nofollow noreferrer">Rook</a> which is Open-Source, Cloud-Native Storage for Kubernetes.</p>
