<p>Need to create a single pod with multiple containers for MySQL, MongoDB, MySQL. My question is should I need to create persistence volume and persistence volume claim for each container and specify the volume in pod configuration <strong>or</strong> single PV &amp; PVC is enough for all the containers in a single pod-like below configs.</p>
<p>Could you verify below configuration is enough or not?</p>
<p><strong>PV:</strong></p>
<pre><code>    apiVersion: v1
kind: PersistentVolume
metadata:
  name: mypod-pv
  labels:
    type: local
spec:
  storageClassName: manual
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: &quot;/mnt/data&quot;
---
</code></pre>
<p><strong>PVC</strong></p>
<pre><code>    apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mypod-pvc
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 3Gi
---
</code></pre>
<p><strong>Deployment:</strong></p>
<pre><code>    apiVersion: apps/v1
kind: Deployment
metadata:
  name: mypod
  labels:
    app: mypod
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mypod
  template:
    metadata:
      labels:
        app: mypod
    spec:
      volumes:
        - name: task-pv-storage
          persistentVolumeClaim:
            claimName: mypod-pvc
      containers:
        - name: mysql
          image: mysql/mysql-server:latest
          ports:
            - containerPort: 3306
          imagePullPolicy: IfNotPresent
          volumeMounts:
            - mountPath: &quot;/var/lib/mysql&quot;
              name: task-pv-storage
        - name: mongodb
          image: openshift/mongodb-24-centos7
          ports:
            - containerPort: 27017
          imagePullPolicy: IfNotPresent
          volumeMounts:
            - mountPath: &quot;/var/lib/mongodb&quot;
              name: task-pv-storage
        - name: mssql
          image: mcr.microsoft.com/mssql/server
          ports:
            - containerPort: 1433
          imagePullPolicy: IfNotPresent
          volumeMounts:
            - mountPath: &quot;/var/opt/mssql&quot;
              name: task-pv-storage
      imagePullSecrets:
        - name: devplat
</code></pre>

KARTHICK SANKAR
<p>You should not be running multiple database containers inside a single pod.</p>
<p>Consider running each database in a separate statefulset.</p>
<p>follow below reference for mysql</p>
<p><a href="https://kubernetes.io/docs/tasks/run-application/run-replicated-stateful-application/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/run-application/run-replicated-stateful-application/</a></p>
<p>You need to adopt similar approach for mongodb or other databases as well.</p>
