<ul>
<li>I have Azure Machine (kubernetes) who have Agent of 2 core, 1 GB. My two services are running on this Machine each have its own Postgres (Deplyment, Service, Pv, PVC).</li>
<li>I want to host my third service too on same machine.</li>
<li>So when I tried to create Postgres Deployment (this too have its own service, PV, PVC) but Pod was stuck in <code>status=ContainerCreating</code> .</li>
<li>After some digging I got to know that my <code>VM</code> only Supports <code>data-disks</code>. </li>
</ul>

<p>So i thought why not use <code>PVC</code> of earlier deployment in current service like:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: third-postgres
  labels:
    name: third-postgres
spec:
  replicas: 1
  template:
    metadata:
      labels:
         name: third-postgres
    spec:
      containers:
      - name: third-postgres
        image: postgres
        env:
          - name: PGDATA
            value: /var/lib/postgresql/data/pgdata
          - name: POSTGRES_USER
            value: third-user
          - name: POSTGRES_PASSWORD
            value: &lt;password&gt;
          - name: POSTGRES_DB
            value: third_service_db
        ports:
          - containerPort: 5432
        volumeMounts:
        - name: third-postgresdata
      mountPath: /var/lib/postgresql/data
  volumes:
  - name: third-postgresdata
    persistentVolumeClaim:
      claimName: &lt;second-postgres-data&gt;
</code></pre>

<ul>
<li>Now this Deployment was successfully running but it doesn't create new database <code>third_service_db</code> </li>
<li>May be because second <code>PVC</code> was already exists so it skips the Db create part ? </li>
<li>So is their any way I can use same <code>PVC</code> for my all services and same <code>PVC</code> can have multiple databases. So that when I run <code>kubectl create -f &lt;path-to-thirst-postgres.yaml&gt;</code> it takes name Database configuration from env Variables and create DB in same <code>PVC</code> </li>
</ul>

<p>You have to create one PVC per Deployment. Once a PVC has been <em>claimed</em>, it must be released before it can be used again.</p>

<p>In the case of AzureDisk, the auto-created volumes can only be mounted by a single node (<em>ReadWriteOnce</em> access mode) so there's one more constraint: each of your Deployments can have at most <strong>1</strong> replica.</p>
