Raphael
Raphael

Reputation: 10579

emptyDir volume not empty after pod restart?

We're trying run a PostgreSQL in a minikube (1.18.1) Kubernetes (1.16.15) cluster so that the database is reset on every pod redeployment.

In our deployment template, we have:

containers:
- name: mock-db  
  image: postgres:13
  imagePullPolicy: "IfNotPresent"
  ports:
    - name: postgres
      containerPort: 5432
  volumeMounts:
    - mountPath: /docker-entrypoint-initdb.d
      name: postgresql-init
    - mountPath: /var/lib/postgresql/data
      name: postgresql-data
volumes:
- name: postgresql-init
  configMap:
    name: "mock-db-init-scripts"
    optional: false
- name: postgresql-data
  emptyDir:
    medium: Memory

Based on the docs, this should work as intended:

When a Pod is removed from a node for any reason, the data in the emptyDir is deleted permanently.

However, after helm uninstall and subsequent helm upgrade --install, I'm getting this in the container logs:

PostgreSQL Database directory appears to contain a database; Skipping initialization

So apparently, that volume is not being cleared. Why? Do I need to change something in the configuration?

Upvotes: 1

Views: 1561

Answers (1)

Raphael
Raphael

Reputation: 10579

Here is what I missed:

  • the init script failed and
  • the container immediately restarted.

No problem with the volume, at all.

Upvotes: 3

Related Questions